Skip to content

Commit d5e1c9f

Browse files
committed
fix keys and excludeKeys to work with JSON array strings
1 parent d789ca6 commit d5e1c9f

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

spec/ParseQuery.spec.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3140,7 +3140,7 @@ describe('Parse.Query testing', () => {
31403140
});
31413141

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

31453145
obj
31463146
.save()
@@ -3157,23 +3157,28 @@ describe('Parse.Query testing', () => {
31573157
ok(!result.dirty(), 'expected result not to be dirty');
31583158
strictEqual(result.get('foo'), 'baz');
31593159
strictEqual(result.get('bar'), undefined, "expected 'bar' field to be unset");
3160+
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
31603161
return result.fetch();
31613162
})
31623163
.then(function (result) {
31633164
strictEqual(result.get('foo'), 'baz');
31643165
strictEqual(result.get('bar'), 1);
3166+
strictEqual(result.get('qux'), 2);
31653167
})
31663168
.then(function () {
31673169
obj._clearServerData();
31683170
const query = new Parse.Query(TestObject);
3169-
query.select([]);
3171+
query.select(['foo']);
31703172
return query.first();
31713173
})
31723174
.then(function (result) {
31733175
ok(result.id, 'expected object id to be set');
3176+
ok(result.createdAt, 'expected object createdAt to be set');
3177+
ok(result.updatedAt, 'expected object updatedAt to be set');
31743178
ok(!result.dirty(), 'expected result not to be dirty');
3175-
strictEqual(result.get('foo'), undefined, "expected 'foo' field to be unset");
3179+
strictEqual(result.get('foo'), 'baz');
31763180
strictEqual(result.get('bar'), undefined, "expected 'bar' field to be unset");
3181+
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
31773182
})
31783183
.then(function () {
31793184
obj._clearServerData();
@@ -3186,6 +3191,7 @@ describe('Parse.Query testing', () => {
31863191
ok(!result.dirty(), 'expected result not to be dirty');
31873192
strictEqual(result.get('foo'), 'baz');
31883193
strictEqual(result.get('bar'), 1);
3194+
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
31893195
})
31903196
.then(function () {
31913197
obj._clearServerData();
@@ -3198,6 +3204,7 @@ describe('Parse.Query testing', () => {
31983204
ok(!result.dirty(), 'expected result not to be dirty');
31993205
strictEqual(result.get('foo'), 'baz');
32003206
strictEqual(result.get('bar'), 1);
3207+
strictEqual(result.get('qux'), undefined, "expected 'qux' field to be unset");
32013208
})
32023209
.then(
32033210
function () {

src/Routers/ClassesRouter.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ export class ClassesRouter extends PromiseRouter {
5757
}
5858
}
5959

60-
if (typeof body.keys === 'string') {
61-
options.keys = body.keys;
60+
if (body.keys) {
61+
options.keys = String(body.keys);
6262
}
6363
if (body.include) {
6464
options.include = String(body.include);
6565
}
66-
if (typeof body.excludeKeys == 'string') {
67-
options.excludeKeys = body.excludeKeys;
66+
if (body.excludeKeys) {
67+
options.excludeKeys = String(body.excludeKeys);
6868
}
6969
if (typeof body.readPreference === 'string') {
7070
options.readPreference = body.readPreference;
@@ -187,11 +187,11 @@ export class ClassesRouter extends PromiseRouter {
187187
if (body.count) {
188188
options.count = true;
189189
}
190-
if (typeof body.keys == 'string') {
191-
options.keys = body.keys;
190+
if (body.keys) {
191+
options.keys = String(body.keys);
192192
}
193-
if (typeof body.excludeKeys == 'string') {
194-
options.excludeKeys = body.excludeKeys;
193+
if (body.excludeKeys) {
194+
options.excludeKeys = String(body.excludeKeys);
195195
}
196196
if (body.include) {
197197
options.include = String(body.include);

0 commit comments

Comments
 (0)