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

Already on GitHub? Sign in to your account

MongoDB 2.6: Ensure $in argument is a real BSON array #174

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

danez commented Apr 16, 2014

This PR targets the same error as the first commit in doctrine/mongodb-odm#741

When doing a custom query with doctrine against MongoDB 2.6 and using the QueryBuilder this exception is thrown:
MongoCursorException: localhost:27017: Can't canonicalize query: BadValue $in needs an array

I'm not sure if it is the right place for the array_values() call, but you should see what I tried to fix with this. :)

Owner

jwage commented Apr 16, 2014

I think the right fix would in the ODM where the bad array is being generated.

Contributor

danez commented Apr 17, 2014

The array is neither generated in doctrine/mongodb nor doctrine/odm. The array is comming from somewhere and is set in the Query\Builder:in() method.
But still i think doctrine/mongodb or doctrine/odm should make sure that it sends correct data to mongodb.

Owner

jwage commented Apr 17, 2014

Is the array generated by your app code?

Owner

jmikola commented Apr 18, 2014

@jwage: This looks related to PHP-1051. MongoDB 2.6 got much stricter with type checking it the query engine, so people who were inadvertently sending associative arrays (usually numeric arrays that had a key unset) are now seeing an error.

This actually shouldn't be a problem in ODM, as (a) we don't use the query builder much internally and (b) I fixed what I believe was the one place where we used $in in doctrine/mongodb-odm#743.

I'm going to look into back-porting this to 1.0.x and then merge up to 1.1.x and master, since it doesn't break BC at all.

EDIT: Scratch that. I'll only be back-porting to 1.1.x, as the Expr code in 1.0.x is structured very differently and there aren't any tests (I cleaned things up for 1.1.x).

jmikola added a commit that referenced this pull request Apr 18, 2014

Owner

jmikola commented Apr 18, 2014

I rebased this PRs commits into 2a5d5c4 and merged it to 1.1.x in e9dc1ea. Thanks, @danez.

@jmikola jmikola closed this Apr 18, 2014

@jmikola jmikola added this to the 1.1.6 milestone Apr 18, 2014

@jmikola jmikola added the bug label Apr 18, 2014

@danez danez deleted the danez:patch-1 branch Apr 22, 2014

@jmikola jmikola referenced this pull request in doctrine/mongodb-odm Jun 8, 2015

Closed

BadValue $in needs an array is misleading #1122

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