Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent filtering of numeric values #1065

Open
enitram opened this issue Oct 23, 2024 · 1 comment
Open

Inconsistent filtering of numeric values #1065

enitram opened this issue Oct 23, 2024 · 1 comment

Comments

@enitram
Copy link

enitram commented Oct 23, 2024

When comparing numbers of different types, nitrite returns different results depending on the filter (eq, lte, gte) and if the value was indexed.

Here is a small example comparing int and long:

        Nitrite db = Nitrite.builder().openOrCreate();
        NitriteCollection collection = db.getCollection("myCollection");

        Document doc = Document.createDocument("value", 42);
        collection.insert(doc);

//        assert collection.find(FluentFilter.where("value").eq(42L)).size() == 1;  // FAIL
        assert collection.find(FluentFilter.where("value").lte(42L)).size() == 1; // SUCCESS
        assert collection.find(FluentFilter.where("value").gte(42L)).size() == 1; // SUCCESS

        collection.createIndex(IndexOptions.indexOptions(IndexType.NON_UNIQUE), "value");

//        assert collection.find(FluentFilter.where("value").eq(42L)).size() == 1;  // FAIL
//        assert collection.find(FluentFilter.where("value").lte(42L)).size() == 1;  // FAIL
//        assert collection.find(FluentFilter.where("value").gte(42L)).size() == 1; // FAIL

        db.close();

This was tested with nitrite 4.3.0 and also shows the same results when comparing int and double.

@anidotnet
Copy link
Contributor

I'll take a look at it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants