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

Mongodb: cast with "as" in query produces unexpected result #1427

Closed
jotak opened this Issue Jul 3, 2015 · 1 comment

Comments

Projects
None yet
2 participants
@jotak
Contributor

jotak commented Jul 3, 2015

I'm trying to cast a class in a query on mongodb, but it doesn't work as I would expect.

I wrote some unit tests to illustrate, you can see it here: https://github.com/jotak/querydsl/commit/28756b91c5a3494130f684e19c4266f1bb5300aa

2 of my tests fail:

  • "countCatsWithInstanceOf": quite unrelated, but worth mentioning: "instanceOf" doesn't seem to be supported
  • "countFishFromNameAndBreedWithCast" : this illustrates the bug. When running
    .and(QFood.food.as(QFish.class).breed.eq("unknown"))

the json produced is

{ "name" : "f1" , "food.breed" : "unknown"}

instead of expected:

{ "name" : "f1" , "breed" : "unknown"}

So it returns 0 result

For information, this ticket follows what I wrote on discussion board: https://groups.google.com/forum/#!topic/querydsl/KaUWIUwov6w

@jotak

This comment has been minimized.

Show comment
Hide comment
@jotak

jotak Jul 6, 2015

Contributor

Just made a pull request #1428

I leave the "instanceOf" unsupported operation issue. Looks like the user must handle it his way. Maybe however we could imagine adding a kind "instanceOf" hooks in metadata, written by the user, so that the operation can be supported in mongodb.

Contributor

jotak commented Jul 6, 2015

Just made a pull request #1428

I leave the "instanceOf" unsupported operation issue. Looks like the user must handle it his way. Maybe however we could imagine adding a kind "instanceOf" hooks in metadata, written by the user, so that the operation can be supported in mongodb.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment