Skip to content
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

$regex not working as expected with arrays #70

Closed
saadtazi opened this issue Sep 12, 2017 · 0 comments
Closed

$regex not working as expected with arrays #70

saadtazi opened this issue Sep 12, 2017 · 0 comments
Labels

Comments

@saadtazi
Copy link
Contributor

When trying to find() a property that is nested in an array of arrays, the record is not returned if the child array has more than one element and one or more of those elements match.

Repro steps:

// no regex - returns expected list: 1 element - ok
mingo.find([{l1: [{ tags: ['tag1', 'tag2'] }, {'notags': 'yep'}]}], {'l1.tags': 'tag1'}).all()

// with regex - but searched property is not an array: ok
mingo.find([{l1: [{ tags: 'tag1'}, {'notags': 'yep'}]}], {'l1.tags': {$regex: '.*tag.*', $options: 'i'}}).all()

// with regex - but searched property is an array, with all elements matching: not ok - expected 1, returned 0
mingo.find([{l1: [{ tags: ['tag1', 'tag2'] }, {'tags': ['tag66']}]}], {'l1.tags': {$regex: 'tag', $options: 'i'}}).all();

// with regex - but searched property is an array, only one element matching: not ok - returns 0 elements - expected 1
mingo.find([{l1: [{ tags: ['tag1', 'tag2'] }, {'notags': 'yep'}]}], {'l1.tags': {$regex: 'tag', $options: 'i'}}).all();

// 
@kofrasa kofrasa added the bug label Sep 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants