Always insert hash-mapped types as objects #472

merged 3 commits into from Jan 2, 2013


None yet
2 participants

jmikola commented Jan 2, 2013

While implementing this, I came across an underlying issue in #467, which is also included in the PR.

jmikola added a commit that referenced this pull request Jan 2, 2013

Merge pull request #472 from doctrine/bson-types
Always insert hash-mapped types as objects

@jmikola jmikola merged commit c4ff548 into master Jan 2, 2013

1 check passed

default The Travis build passed

@jmikola jmikola deleted the bson-types branch Jan 2, 2013


MDrollette commented Jan 8, 2013

Is it right that this breaks using $in?

FOSUserBundle stores roles with type="hash" and before I was able to query for anyone with the admin role using:

return $this->createQueryBuilder()->field('roles')->in(array('ROLE_ADMIN'));

This query doesn't find any users that have been persisted since this commit.

@MDrollette MDrollette referenced this pull request in FriendsOfSymfony/FOSUserBundle Jan 9, 2013


change mongodb type for roles to be collection instead of hash #939


jmikola commented Jan 10, 2013

@MDrollette: I replied in the FOSUserBundle thread. When using the $in query operator on an object field, MongoDB will only check if the field's value (i.e. a BSON object) exists in the array specified for $in. Since the document's field is not an array, there is no support for evaluating the query operator against multiple values (described here). The BSON object is treated the same as if we were matching a single scalar value in the field.

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