-
Notifications
You must be signed in to change notification settings - Fork 255
Update mongodb native to 2.0. Issue #233. #260
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
Changes from all commits
feac98f
6bc8b23
c0a4dc2
544f26d
65d9697
559b2da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,13 @@ | ||
| language: node_js | ||
| node_js: | ||
| - "0.11" | ||
| - "0.10" | ||
| - "0.8" | ||
| - "0.12" | ||
| before_script: | ||
| - sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | ||
| - echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list | ||
| - sudo apt-get update | ||
| - sudo apt-get install -y mongodb-org=2.6.5 mongodb-org-server=2.6.5 mongodb-org-shell=2.6.5 mongodb-org-mongos=2.6.5 mongodb-org-tools=2.6.5 | ||
| - sleep 15 #mongo may not be responded directly. See http://docs.travis-ci.com/user/database-setup/#MongoDB | ||
| - mongo --version | ||
| services: | ||
| - mongodb | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -291,6 +291,12 @@ Query.prototype.parseValue = function parseValue(field, modifier, val) { | |
| "use strict"; | ||
| var self = this; | ||
|
|
||
| // Omit adding regex value to these modifiers | ||
| var omitRegExModifiers = ['$ne', 'greaterThan', '>', 'gt', 'greaterThanOrEqual', | ||
| '>=', 'gte', '$gt', '$gte', '<', 'lessThan', '<=', | ||
| 'lessThanOrEqual' | ||
| ]; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should '<', 'lessThan', '<=', 'lessThanOrEqual' also be here?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dmarcelino I didn't add the lessthan operator because waterline adapter test didn't complain. However, with my curiosity I just ran a few query for the lessthan operator with regex and it barf with error same as the above operators "BadValue Can't have RegEx as arg to predicate over field". I will add the lessthan to the list. Thanks. |
||
|
|
||
| // Look and see if the key is in the schema, id attribute and all association | ||
| // attributes are objectid type by default (@see { @link collection._parseDefinition }). | ||
| if (hop(self.schema, field) && self.schema[field].type === 'objectid') { | ||
|
|
@@ -344,13 +350,12 @@ Query.prototype.parseValue = function parseValue(field, modifier, val) { | |
| if (self.schema[field].type === 'date') { | ||
| return new Date(val); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| if(modifier === '$ne') { | ||
| if (omitRegExModifiers.indexOf(modifier) > -1) { | ||
| return val; | ||
| } | ||
|
|
||
| // Replace Percent Signs, work in a case insensitive fashion by default | ||
| val = utils.caseInsensitive(val); | ||
| val = val.replace(/%/g, '.*'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -213,6 +213,22 @@ describe('Query', function () { | |
| assert(_.isEqual(actual, expect)); | ||
| }); | ||
|
|
||
| it('should accept `$gt` selector without turning string value to a RegExp', function () { | ||
| var where = { name: { $gt: 'banana' } }; | ||
| var expect = _.cloneDeep(where); | ||
| var Q = new Query({ where: where }, { name: 'string' }); | ||
| var actual = Q.criteria.where; | ||
| assert(_.isEqual(actual, expect)); | ||
| }); | ||
|
|
||
| it('should accept `$gte` selector without turning string value to a RegExp', function () { | ||
| var where = { name: { $gte: 'apple' } }; | ||
| var expect = _.cloneDeep(where); | ||
| var Q = new Query({ where: where }, { name: 'string' }); | ||
| var actual = Q.criteria.where; | ||
| assert(_.isEqual(actual, expect)); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
|
|
||
|
|
@@ -233,12 +249,12 @@ describe('Query', function () { | |
| var where = { | ||
| or: [{ name: { $exists: false } }, { name: { '!': 'clark' } }] | ||
| }; | ||
| var expect = { $or: [ { name: { $exists: false } }, { name: { $ne: /^clark$/i } } ] }; | ||
| var expect = { $or: [ { name: { $exists: false } }, { name: { $ne: 'clark' } } ] }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just curious why this changed. |
||
| var Q = new Query({ where: where }, { name: 'string', age: 'integer' }); | ||
| var actual = Q.criteria.where; | ||
| assert(_.isEqual(actual, expect)); | ||
| }); | ||
|
|
||
| }); | ||
|
|
||
| }); | ||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason we wont test against 0.11? I'm not sure if it matters, but I know other waterline repos test against 0.11.
Edit I saw the discussion around this, nevermind!