Skip to content

New query condition support to match all strings that starts with some other given strings #3864

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

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0379019
feat: Convert $regex value to RegExp object
May 24, 2017
810b7ec
feat: Add lib folder
May 24, 2017
77580a0
Revert "feat: Add lib folder"
May 26, 2017
e209087
feat: Add $regex test in $all array
May 26, 2017
d7194c7
test: Test regex with $all only in MongoDB
May 28, 2017
59a57f7
Revert "test: Test regex with $all only in MongoDB"
May 28, 2017
132b0d6
feat: Add tests for containsAllStartingWith
Jun 15, 2017
ee84d53
feat: Add postgres support
Jul 7, 2017
52a394e
feat: Check that all values in $all must be regex or none
Jul 7, 2017
3432fc8
test: Check that $all vaules must be regex or none
Jul 7, 2017
81ecf4d
feat: Update tests to use only REST API
Jul 8, 2017
a891a0c
refactor: Move $all regex check to adapter
Jul 8, 2017
0dcdf83
feat: Check for valid $all values in progres
Jul 8, 2017
d6763d3
refactor: Update function name
Jul 8, 2017
556787b
fix: Postgres $all values regex checking
Jul 8, 2017
7ca8128
fix: Check starts with as string
Jul 8, 2017
b88d2e7
fix: Define contains all regex sql function
Jul 9, 2017
bbb7e67
fix: Wrong value check
Jul 9, 2017
c0e9a9b
Merge commit '8ec07b83d0b74b00153b7b414aa73d7247c55f85' into feat/con…
Jan 11, 2018
4fe6cb8
Merge commit '550b69e271f2d754b7ff774ffa66b2673bdb14a0' into feat/con…
Jan 30, 2018
c36854b
fix: Check valid data
Feb 4, 2018
1c54ede
fix: Check regex when there is only one value
Feb 4, 2018
c8fb446
fix: Constains all starting with string returns empty with bad params
Feb 4, 2018
d6b8a74
fix: Pass correct regex value
Feb 4, 2018
80772cf
feat: Add missing tests
Feb 16, 2018
4a75023
feat: Add missing tests
eduardbosch Feb 16, 2018
efc43ed
feat: Add more tests
eduardbosch Feb 16, 2018
cc0ed3f
fix: Unify MongoDB and PostgreSQL functionality
eduardbosch May 5, 2018
6381fdd
Merge commit '3acb3e7a9b19a7b4e43eae1fd8ad84d0a1b3c53e' into feat/con…
eduardbosch May 5, 2018
79f1f32
fix: Lint checks
eduardbosch May 5, 2018
c14ffd0
Merge commit 'bb1641419fb3708ac975ad7959dacb7318c65717' into feat/con…
eduardbosch May 5, 2018
da76c18
fix: Test broken
eduardbosch May 5, 2018
07a4d69
test for empty $all
dplewis May 16, 2018
917ec15
Merge branch 'master' into feat/contains-all-starting-with
dplewis May 16, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions spec/MongoTransform.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,21 @@ describe('parseObjectToMongoObjectForCreate', () => {
expect(output.ts.iso).toEqual('2017-01-18T00:00:00.000Z');
done();
});

});

describe_only_db('mongo')('parseObjectToMongoObjectForCreate', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about an edge to edge test case, with proper data (create multiple objects and run the query). Do you think that's possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was writing you to ask if this was what you where asking for. I don't know how to make this tests. Is there any edge to edge test case in the repository? Sorry, I'm not really familiar with Jasmine.

If you tell me how to make this tests or where to take an idea, I'll take a look for sure.

Do you think I should rollback this change??

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think I should rollback this change??

You can roll it back, but that doesn't really change anything.

The edge to edge test would look like:

it('should match all strings that starts with string', (done) => {
  let object = new Parse.Object('Object');
  object.set('strings', ['the', 'brown', 'fox', 'jumps']);
  let object2 = new Parse.Object('Object');
  object2.set('strings', ['over', 'the', 'lazy', 'dog']);
  Parse.Object.saveAll([object, object2]).then(() => {
   return request.get({
      url: Parse.serverURL + 'classes/Object',
      json: true,
      query: ... // build the JSON query
   });
  }).then((results) => {
     expect(....) // TODO: validate the results
  });
}); 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @flovilmart

I'll make this tests when I have some time!

it('$regex in $all list', (done) => {
var input = {
arrayField: {'$all': [{$regex: '^\\Qone\\E'}, {$regex: '^\\Qtwo\\E'}, {$regex: '^\\Qthree\\E'}]},
};
var outputValue = {
arrayField: {'$all': [/^\Qone\E/, /^\Qtwo\E/, /^\Qthree\E/]},
};
var output = transform.transformWhere(null, input);
jequal(outputValue.arrayField, output.arrayField);
done();
});
});

describe('transformUpdate', () => {
Expand Down
2 changes: 2 additions & 0 deletions src/Adapters/Storage/Mongo/MongoTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,8 @@ const transformInteriorAtom = atom => {
return DateCoder.JSONToDatabase(atom);
} else if (BytesCoder.isValidJSON(atom)) {
return BytesCoder.JSONToDatabase(atom);
} else if (typeof atom === 'object' && atom && atom.$regex !== undefined) {
return new RegExp(atom.$regex);
} else {
return atom;
}
Expand Down