Skip to content
This repository has been archived by the owner on Nov 11, 2020. It is now read-only.

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

Closed
wants to merge 3 commits into from
Closed

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

wants to merge 3 commits into from

Conversation

danez
Copy link
Contributor

@danez 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. :)

@jwage
Copy link
Member

jwage commented Apr 16, 2014

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

@danez
Copy link
Contributor Author

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.

@jwage
Copy link
Member

jwage commented Apr 17, 2014

Is the array generated by your app code?

@jmikola
Copy link
Member

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
@jmikola
Copy link
Member

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 patch-1 branch April 22, 2014 07:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants