Skip to content

Issue with Empty Collection Query Results in LiteDB (GROUP BY) #87

@fernandozago

Description

@fernandozago

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions