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

Fix select exclude queries #7242

Merged
merged 45 commits into from
Jun 3, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
d5e1c9f
fix keys and excludeKeys to work with JSON array strings
cbaker6 Mar 5, 2021
65a109a
make excludeKeys test more robust
cbaker6 Mar 5, 2021
b4920a6
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 5, 2021
82ee9c9
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 5, 2021
5640cd5
add changelog
cbaker6 Mar 5, 2021
c300e4d
add select([]) functionality to fix)
cbaker6 Mar 5, 2021
97103bd
update changelog
cbaker6 Mar 5, 2021
c91142d
update keys
cbaker6 Mar 6, 2021
e8a14cf
add exclude test
cbaker6 Mar 7, 2021
e98d689
add select REST test and exclude JS SDK test
cbaker6 Mar 7, 2021
2601334
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 7, 2021
e97398c
add more tests
cbaker6 Mar 7, 2021
ea4b294
Merge branch 'fixSelectExclude' of https://github.com/cbaker6/parse-s…
cbaker6 Mar 7, 2021
c058451
add additional exclude test
cbaker6 Mar 7, 2021
0b72a7a
improved select test for testing JSON string array in REST
cbaker6 Mar 7, 2021
8e15e90
improved exclude test for testing JSON string array in REST
cbaker6 Mar 7, 2021
a05b56f
check for parse keys
cbaker6 Mar 7, 2021
a722ae0
make include look like keys and excludeKeys
cbaker6 Mar 9, 2021
855ecc6
nit
cbaker6 Mar 9, 2021
02fa52b
Exclude nexted child fields
cbaker6 Mar 10, 2021
0f59285
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 10, 2021
521a5f5
add updates and show failing testcases
cbaker6 Mar 10, 2021
638b184
Merge branch 'fixSelectExclude' of https://github.com/cbaker6/parse-s…
cbaker6 Mar 10, 2021
4de0acf
working
cbaker6 Mar 10, 2021
c5aa3b3
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 13, 2021
88cd07f
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 13, 2021
b36eb6b
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 15, 2021
151d674
add more tests
cbaker6 Mar 16, 2021
50fe6cf
Merge branch 'fixSelectExclude' of https://github.com/cbaker6/parse-s…
cbaker6 Mar 16, 2021
c4ea3fd
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 16, 2021
0896fd6
Merge branch 'master' into fixSelectExclude
cbaker6 Mar 18, 2021
1e931af
even more test cases
cbaker6 Mar 19, 2021
bdd1af6
Merge branch 'fixSelectExclude' of https://github.com/cbaker6/parse-s…
cbaker6 Mar 19, 2021
b829b96
Merge remote-tracking branch 'upstream/master' into fixSelectExclude
cbaker6 Mar 19, 2021
4b27848
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 2, 2021
d65430f
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 9, 2021
57abc4e
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 10, 2021
2c26f03
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 23, 2021
9f74718
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 25, 2021
51874b5
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 28, 2021
ac42142
Merge branch 'master' into fixSelectExclude
cbaker6 Apr 29, 2021
4563861
Merge remote-tracking branch 'upstream/master' into fixSelectExclude
cbaker6 Jun 1, 2021
d8f0bce
use await for added tests
cbaker6 Jun 1, 2021
91b5592
lint
cbaker6 Jun 1, 2021
b06bf76
Add suggestions
cbaker6 Jun 3, 2021
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
24 changes: 21 additions & 3 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3140,7 +3140,7 @@ describe('Parse.Query testing', () => {
});

it('select keys query', function (done) {
const obj = new TestObject({ foo: 'baz', bar: 1 });
const obj = new TestObject({ foo: 'baz', bar: 1, qux: 2 });

obj
.save()
Expand All @@ -3157,23 +3157,28 @@ describe('Parse.Query testing', () => {
ok(!result.dirty(), 'expected result not to be dirty');
strictEqual(result.get('foo'), 'baz');
strictEqual(result.get('bar'), undefined, "expected 'bar' field to be unset");
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
return result.fetch();
})
.then(function (result) {
strictEqual(result.get('foo'), 'baz');
strictEqual(result.get('bar'), 1);
strictEqual(result.get('qux'), 2);
})
.then(function () {
obj._clearServerData();
const query = new Parse.Query(TestObject);
query.select([]);
cbaker6 marked this conversation as resolved.
Show resolved Hide resolved
query.select(['foo']);
return query.first();
})
.then(function (result) {
ok(result.id, 'expected object id to be set');
ok(result.createdAt, 'expected object createdAt to be set');
ok(result.updatedAt, 'expected object updatedAt to be set');
ok(!result.dirty(), 'expected result not to be dirty');
strictEqual(result.get('foo'), undefined, "expected 'foo' field to be unset");
strictEqual(result.get('foo'), 'baz');
strictEqual(result.get('bar'), undefined, "expected 'bar' field to be unset");
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
})
.then(function () {
obj._clearServerData();
Expand All @@ -3186,6 +3191,7 @@ describe('Parse.Query testing', () => {
ok(!result.dirty(), 'expected result not to be dirty');
strictEqual(result.get('foo'), 'baz');
strictEqual(result.get('bar'), 1);
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
cbaker6 marked this conversation as resolved.
Show resolved Hide resolved
})
.then(function () {
obj._clearServerData();
Expand All @@ -3198,6 +3204,7 @@ describe('Parse.Query testing', () => {
ok(!result.dirty(), 'expected result not to be dirty');
strictEqual(result.get('foo'), 'baz');
strictEqual(result.get('bar'), 1);
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
})
.then(
function () {
Expand All @@ -3224,6 +3231,17 @@ describe('Parse.Query testing', () => {
});
expect(response.data.results[0].foo).toBeUndefined();
expect(response.data.results[0].hello).toBe('world');

const response2 = await request({
cbaker6 marked this conversation as resolved.
Show resolved Hide resolved
url: Parse.serverURL + '/classes/TestObject',
qs: {
excludeKeys: ['foo', 'hello'],
where: JSON.stringify({ objectId: obj.id }),
},
headers: masterKeyHeaders,
});
expect(response2.data.results[0].foo).toBeUndefined();
expect(response2.data.results[0].hello).toBeUndefined();
});

it('exclude keys with select same key', async () => {
Expand Down
16 changes: 8 additions & 8 deletions src/Routers/ClassesRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ export class ClassesRouter extends PromiseRouter {
}
}

if (typeof body.keys === 'string') {
cbaker6 marked this conversation as resolved.
Show resolved Hide resolved
options.keys = body.keys;
if (body.keys) {
options.keys = String(body.keys);
}
if (body.include) {
options.include = String(body.include);
}
if (typeof body.excludeKeys == 'string') {
options.excludeKeys = body.excludeKeys;
if (body.excludeKeys) {
options.excludeKeys = String(body.excludeKeys);
}
if (typeof body.readPreference === 'string') {
options.readPreference = body.readPreference;
Expand Down Expand Up @@ -187,11 +187,11 @@ export class ClassesRouter extends PromiseRouter {
if (body.count) {
options.count = true;
}
if (typeof body.keys == 'string') {
options.keys = body.keys;
if (body.keys) {
options.keys = String(body.keys);
}
if (typeof body.excludeKeys == 'string') {
options.excludeKeys = body.excludeKeys;
if (body.excludeKeys) {
cbaker6 marked this conversation as resolved.
Show resolved Hide resolved
options.excludeKeys = String(body.excludeKeys);
}
if (body.include) {
options.include = String(body.include);
Expand Down