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

Querying with $in operator on the id field of type BigInteger returns zero results [DATAMONGO-602] #1531

Closed
spring-projects-issues opened this issue Jan 30, 2013 · 4 comments
Assignees
Labels
type: bug
Milestone

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jan 30, 2013

Nemanja Nedic opened DATAMONGO-602 and commented

There is a problem when trying to query for documents with id field is in a given list of BigInteger values. Id field is mapped as a BigInteger.

For example, these lines will work only if given id list contains only one item.

List<BigInteger> profileIds = findProfileIds();
Predicate predicate = QProfileDocument.profileDocument.id.in(profileIds);
Iterable<ProfileDocument> profiles = profileRepository.findAll(predicate);

The underlying MongodbQuery is different if there is only one item in profileIds. The query looks like this for a profileIds with multiple elements

{ "_id" : { "$in" : [ "25069473312490162649510603609" , "25045916045544535958655878835"]}}

and it looks like this when there is only one item in the list.

{ "_id" : { "$oid" : "5100fb776c67e7e092be6b59"}}

In the first case, query will return no results and in the second it will work and return an Iterable with one item.

As you can see, the problem is with the representation of the BigInteger. using decimal format will not work with MongoDB


Affects: 1.1.1

Referenced from: commits 9881ef9, 21352a8

Backported to: 1.2.4

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 7, 2013

Thomas Darimont commented

Hello,

I tested this with the current version and it seems to work fine.
Could you please upgrade your version to see whether this is still a problem?

I added some additional unit-tests to verify that this works as expected.
Here is the gh PR: #59

Cheers,
Thomas

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 7, 2013

Thomas Darimont commented

Hello,

could you please give this a spin with the latest version?

Thanks,
Thomas

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 7, 2013

Nemanja Nedic commented

Sorry, the bug was filed long ago and I'm not on that project so I cannot check it now. I'll ask a colleague of mine to check it later

@spring-projects-issues
Copy link
Author

spring-projects-issues commented Aug 7, 2013

Oliver Drotbohm commented

We've added a test case ensure it's working in current versions

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

No branches or pull requests

2 participants