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

Incorrect minimongo behavior when using `$in` and regular expressions #1707

Closed
avital opened this Issue Dec 24, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@avital
Contributor

avital commented Dec 24, 2013

Originally reported by @guilhermedecampo.

var coll = new Meteor.Collection("test");
coll.insert({title: "foo"});

// expected: {title: "foo", _id: ...}
// actual: as expected on server, undefined on client
console.log(coll.findOne({$or: [{title: {$in: [/foo/]}}]}));

// expected: {title: "foo", _id: ...}
// actual: as expected on server, undefined on client
console.log(coll.findOne({title: {$in: [/foo/]}}));

// this one works fine
console.log(coll.findOne({title: /foo/}));

raix added a commit to raix/meteor that referenced this issue Dec 24, 2013

Try to fix meteor#1707
Current did not work on the client - returned `undefined`
```js
var coll = new Meteor.Collection("test");
coll.insert({title: "foo"});

coll.findOne({$or: [{title: {$in: [/foo/]}}]}); // returned undefined
on client
```

`EJSON.equals` does a correct 1:1 compare resulting in:
```js
EJSON.equals(‘foo’, ‘foo’); // True
EJSON.equals(/foo/, /foo/); // True
EJSON.equals(/foo/, ‘foo’); // False
```
So the change is applied to `LocalCollection._f._equal` as a simple
test if `operandElt` is a regex - *Not sure if we should crawl `b` in
`_equal` (in case of an object)*
@glasser

This comment has been minimized.

Member

glasser commented Dec 24, 2013

Thanks. I'm doing a round of auditing on minimongo now and I'll try to deal with this as I get to $in.

glasser added a commit that referenced this issue Dec 28, 2013

Move $in to the new model
Implement regexp options for $in. Fixes #1707.

Remaining:
- $nin
- $exists
- $size
- $type
- $regex/$option
- $all
- $elemMatch
- $near/$maxDistance

@glasser glasser closed this in 90e94c8 Dec 31, 2013

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