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

Criteria with is and another filter for the same field creates invalid query doucment #4850

Open
fstorz opened this issue Dec 9, 2024 · 1 comment
Assignees
Labels
status: waiting-for-triage An issue we've not yet triaged

Comments

@fstorz
Copy link

fstorz commented Dec 9, 2024

Description
When using the method is in the Criteria class together with any other filter element (without the and operator), then the created filter document is invalid.

Relevant code:

if (!NOT_SET.equals(isValue)) {
queryCriteria.put(this.key, this.isValue);
queryCriteria.putAll(document);
} else {

How to reproduce
The following Criteria object

Criteria.where("name")
    .is(123)
    .type(JsonSchemaObject.Type.INT_64)

creates

{"name": 123, "$type": ["long"]}

which is invalid.

Using the following Criteria object

Criteria.where("name")
    .in(123)
    .type(JsonSchemaObject.Type.INT_64)

creates

{"name": {"$in": [123], "$type": ["long"]}}

which is valid and more or less the same, just does not use "is".

Expected
When using is in combination with other filters for the same property, all filters should be combined into a sub-document using $eq for the equality check of the value provided to the is method.

Criteria.where("name")
    .is(123)
    .type(JsonSchemaObject.Type.INT_64)

should create

{"name": {"$eq": 123, "$type": ["long"]}}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 9, 2024
@christophstrobl
Copy link
Member

thanks for reporting, well look into this.

@christophstrobl christophstrobl self-assigned this Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

No branches or pull requests

3 participants