-
Notifications
You must be signed in to change notification settings - Fork 230
Description
Issue with Empty Collection Query Results in LiteDB
Description
When executing queries on an empty collection (MyData with 0 rows) in LiteDB, the results are inconsistent and unexpected.
Specifically:
Query 1:
SELECT EXTEND(@KEY, {Total: Count(*)}) FROM MyData GROUP BY { Name };
Returns:
Total | |
---|---|
1 | 0 |
Query 2:
SELECT @KEY AS Group, COUNT(*) as Total FROM MyData GROUP BY { Name };
Returns:
Group | Total | |
---|---|---|
1 | (null) | 0 |
Queries:
SELECT EXTEND(@KEY, {Total: 1}) FROM MyData GROUP BY { Name };
and
SELECT @KEY AS Group, 1 as Total FROM MyData GROUP BY { Name };
Returns:
[no result] |
---|
Expected Behavior
For an empty collection, these queries should consistently return no data. Specifically:
Queries executed on an empty collection (MyData with 0 rows) should return no rows, as there are no entries to group or extend.
Additional Information
The current behavior is inconsistent and may lead to incorrect assumptions about the presence of data in the collection. Ensuring that queries on empty collections return no data will align with typical SQL database behavior and improve predictability.
Is there any plan to improve the consistency of query results for empty collections in future LiteDB releases? Addressing this issue would greatly enhance the reliability and predictability of LiteDB for developers.
Thank you for your attention to this matter.