springfilter icon indicating copy to clipboard operation
springfilter copied to clipboard

Fixed bug on (is null/is not null) when using (and/or) with MongoDb

Open Nibell opened this issue 2 years ago • 3 comments

Hi @torshid @marcopag90,

I found a bug when using (and/or) with (is null/is not null) on MongoDb It works correctly when using (is null/is not null) by themselves.

Api input is

date < '2022-10-30T18:35:24.00Z' or date is null

Get the following query when combining it with and/or operators to mongodb

{
    "$or": [
        {
            "date": {
                "$lt": {
                    "$date": "2022-10-30T18:35:24Z"
                }
            }
        },
        {
            "date": null
        }
    ]
}

Should be

{
    "$or": [
        {
            "date": {
                "$lt": {
                    "$date": "2022-10-30T18:35:24Z"
                }
            }
        },
        {
            "date": {
                "$exists": false
            }
        }
    ]
} 

Change to match (is empty/is not empty) because they don't have that problem. It's a bug in BsonNull.VALUE implantation, what I can gather.

//Nibell

Nibell avatar Sep 27 '22 09:09 Nibell

:warning: 3 God Classes were detected by Lift in this project. Visit the Lift web console for more details.

sonatype-lift[bot] avatar Sep 27 '22 10:09 sonatype-lift[bot]

Get the correct query when only using (is not null/is null)

Api input is

date is null

Get the following query to mongodb which is correct

{
    "date": {
        "$exists": false
    }
}

Nibell avatar Sep 27 '22 13:09 Nibell

Hi @Nibell

From what I have read here, using "$exists": true will also bring results with null values which is not equivalent to is not null. It seems that the current behavior is correct, what do you think?

torshid avatar Sep 27 '22 14:09 torshid