Skip to content

Postgres: $all, $and CLP and more #2551

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 17 commits into from
Aug 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions spec/InstallationsRouter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ describe('InstallationsRouter', () => {
expect(results.length).toEqual(1);
done();
}).catch((err) => {
console.error(err);
fail(JSON.stringify(err));
jfail(err);
done();
});
});
Expand Down
11 changes: 6 additions & 5 deletions spec/ParseAPI.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('miscellaneous', function() {
.catch(done);
});

it_exclude_dbs(['postgres'])('ensure that email is uniquely indexed', done => {
it('ensure that email is uniquely indexed', done => {
let numFailed = 0;
let numCreated = 0;
let user1 = new Parse.User();
Expand Down Expand Up @@ -212,7 +212,7 @@ describe('miscellaneous', function() {
});
});

it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a unique username and email, but duplicates in some other field that has a uniqueness constraint, you get a regular duplicate value error', done => {
it('ensure that if you try to sign up a user with a unique username and email, but duplicates in some other field that has a uniqueness constraint, you get a regular duplicate value error', done => {
let config = new Config('test');
config.database.adapter.addFieldIfNotExists('_User', 'randomField', { type: 'String' })
.then(() => config.database.adapter.ensureUniqueness('_User', userSchema, ['randomField']))
Expand All @@ -233,7 +233,6 @@ it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a un
return user.signUp()
})
.catch(error => {
console.error(error);
expect(error.code).toEqual(Parse.Error.DUPLICATE_VALUE);
done();
});
Expand Down Expand Up @@ -1363,7 +1362,7 @@ it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a un
});
});

it_exclude_dbs(['postgres'])('does not change inner objects if the key has the same name as a geopoint field on the class, and the value is an array of length 2, or if the key has the same name as a file field on the class, and the value is a string', done => {
it('does not change inner objects if the key has the same name as a geopoint field on the class, and the value is an array of length 2, or if the key has the same name as a file field on the class, and the value is a string', done => {
let file = new Parse.File('myfile.txt', { base64: 'eAo=' });
file.save()
.then(f => {
Expand Down Expand Up @@ -1495,8 +1494,10 @@ it_exclude_dbs(['postgres'])('ensure that if you try to sign up a user with a un
done();
});
});
});

it_exclude_dbs(['postgres'])('should have _acl when locking down (regression for #2465)', (done) =>  {
describe_only_db('mongo')('legacy _acl', () => {
it('should have _acl when locking down (regression for #2465)', (done) =>  {
let headers = {
'X-Parse-Application-Id': 'test',
'X-Parse-REST-API-Key': 'rest'
Expand Down
2 changes: 1 addition & 1 deletion spec/ParseGeoPoint.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe('Parse.GeoPoint testing', () => {
});
});

it_exclude_dbs(['postgres'])('works with geobox queries', (done) => {
it('works with geobox queries', (done) => {
var inSF = new Parse.GeoPoint(37.75, -122.4);
var southwestOfSF = new Parse.GeoPoint(37.708813, -122.526398);
var northeastOfSF = new Parse.GeoPoint(37.822802, -122.373962);
Expand Down
27 changes: 18 additions & 9 deletions spec/ParseGlobalConfig.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ let Config = require('../src/Config');
describe('a GlobalConfig', () => {
beforeEach(done => {
let config = new Config('test');
let query = on_db('mongo', () => {
// Legacy is with an int...
return { objectId: 1 };
}, () => {
return { objectId: "1" }
})
config.database.adapter.upsertOneObject(
'_GlobalConfig',
{ fields: {} },
{ objectId: 1 },
{ fields: { objectId: { type: 'Number' }, params: {type: 'Object'}} },
query,
{ params: { companies: ['US', 'DK'] } }
).then(done, done);
).then(done, (err) => {
jfail(err);
done();
});
});

it_exclude_dbs(['postgres'])('can be retrieved', (done) => {
it('can be retrieved', (done) => {
request.get({
url : 'http://localhost:8378/1/config',
json : true,
Expand All @@ -32,7 +41,7 @@ describe('a GlobalConfig', () => {
});
});

it_exclude_dbs(['postgres'])('can be updated when a master key exists', (done) => {
it('can be updated when a master key exists', (done) => {
request.put({
url : 'http://localhost:8378/1/config',
json : true,
Expand All @@ -48,7 +57,7 @@ describe('a GlobalConfig', () => {
});
});

it_exclude_dbs(['postgres'])('properly handles delete op', (done) => {
it('properly handles delete op', (done) => {
request.put({
url : 'http://localhost:8378/1/config',
json : true,
Expand Down Expand Up @@ -79,7 +88,7 @@ describe('a GlobalConfig', () => {
});
});

it_exclude_dbs(['postgres'])('fail to update if master key is missing', (done) => {
it('fail to update if master key is missing', (done) => {
request.put({
url : 'http://localhost:8378/1/config',
json : true,
Expand All @@ -95,12 +104,12 @@ describe('a GlobalConfig', () => {
});
});

it_exclude_dbs(['postgres'])('failed getting config when it is missing', (done) => {
it('failed getting config when it is missing', (done) => {
let config = new Config('test');
config.database.adapter.deleteObjectsByQuery(
'_GlobalConfig',
{ fields: { params: { __type: 'String' } } },
{ objectId: 1 }
{ objectId: "1" }
).then(() => {
request.get({
url : 'http://localhost:8378/1/config',
Expand Down
8 changes: 1 addition & 7 deletions spec/ParseObject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,7 @@ describe('Parse.Object testing', () => {
expect(x3.get('stuff')).toEqual([1, {'foo': 'bar'}]);
done();
}, (error) => {
console.error(error);
on_db('mongo', () => {
jfail(error);
});
on_db('postgres', () => {
expect(error.message).toEqual("Postgres does not support Remove operator.");
});
jfail(error);
done();
});
});
Expand Down
18 changes: 9 additions & 9 deletions spec/ParseQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])("containsAll date array queries", function(done) {
it("containsAll date array queries", function(done) {
var DateSet = Parse.Object.extend({ className: "DateSet" });

function parseDate(iso8601) {
Expand Down Expand Up @@ -289,7 +289,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])("containsAll object array queries", function(done) {
it("containsAll object array queries", function(done) {

var MessageSet = Parse.Object.extend({ className: "MessageSet" });

Expand Down Expand Up @@ -872,7 +872,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])("order by descending number and string", function(done) {
it("order by descending number and string", function(done) {
var strings = ["a", "b", "c", "d"];
var makeBoxedNumber = function(num, i) {
return new BoxedNumber({ number: num, string: strings[i] });
Expand Down Expand Up @@ -1579,7 +1579,7 @@ describe('Parse.Query testing', () => {
})
});

it_exclude_dbs(['postgres'])('properly includes array of mixed objects', (done) => {
it('properly includes array of mixed objects', (done) => {
let objects = [];
let total = 0;
while(objects.length != 5) {
Expand Down Expand Up @@ -2270,7 +2270,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])('notEqual with array of pointers', (done) => {
it('notEqual with array of pointers', (done) => {
var children = [];
var parents = [];
var promises = [];
Expand Down Expand Up @@ -2364,7 +2364,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])('query match on array with single object', (done) => {
it('query match on array with single object', (done) => {
var target = {__type: 'Pointer', className: 'TestObject', objectId: 'abc123'};
var obj = new Parse.Object('TestObject');
obj.set('someObjs', [target]);
Expand All @@ -2380,7 +2380,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])('query match on array with multiple objects', (done) => {
it('query match on array with multiple objects', (done) => {
var target1 = {__type: 'Pointer', className: 'TestObject', objectId: 'abc'};
var target2 = {__type: 'Pointer', className: 'TestObject', objectId: '123'};
var obj= new Parse.Object('TestObject');
Expand Down Expand Up @@ -2449,7 +2449,7 @@ describe('Parse.Query testing', () => {
});
});

it_exclude_dbs(['postgres'])('should find objects with array of pointers', (done) => {
it('should find objects with array of pointers', (done) => {
var objects = [];
while(objects.length != 5) {
var object = new Parse.Object('ContainedObject');
Expand Down Expand Up @@ -2488,7 +2488,7 @@ describe('Parse.Query testing', () => {
})
})

it_exclude_dbs(['postgres'])('query with two OR subqueries (regression test #1259)', done => {
it('query with two OR subqueries (regression test #1259)', done => {
let relatedObject = new Parse.Object('Class2');
relatedObject.save().then(relatedObject => {
let anObject = new Parse.Object('Class1');
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseRelation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ describe('Parse.Relation testing', () => {
});
});

it_exclude_dbs(['postgres'])("query on pointer and relation fields with equal", (done) => {
it("query on pointer and relation fields with equal", (done) => {
var ChildObject = Parse.Object.extend("ChildObject");
var childObjects = [];
for (var i = 0; i < 10; i++) {
Expand Down Expand Up @@ -377,7 +377,7 @@ describe('Parse.Relation testing', () => {
});
});

it_exclude_dbs(['postgres'])("or queries on pointer and relation fields", (done) => {
it("or queries on pointer and relation fields", (done) => {
var ChildObject = Parse.Object.extend("ChildObject");
var childObjects = [];
for (var i = 0; i < 10; i++) {
Expand Down
11 changes: 7 additions & 4 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ describe('Parse.User testing', () => {

// What this means is, only one Parse User can be linked to a
// particular Facebook account.
it_exclude_dbs(['postgres'])("link with provider for already linked user", (done) => {
it("link with provider for already linked user", (done) => {
var provider = getMockFacebookProvider();
Parse.User._registerAuthenticationProvider(provider);
var user = new Parse.User();
Expand All @@ -1295,7 +1295,10 @@ describe('Parse.User testing', () => {
user2.signUp(null, {
success: function(model) {
user2._linkWith('facebook', {
success: fail,
success: (err) => {
jfail(err);
done();
},
error: function(model, error) {
expect(error.code).toEqual(
Parse.Error.ACCOUNT_ALREADY_LINKED);
Expand Down Expand Up @@ -2066,7 +2069,7 @@ describe('Parse.User testing', () => {
});
});

it_exclude_dbs(['postgres'])('get session only for current user', (done) => {
it('get session only for current user', (done) => {
Parse.Promise.as().then(() => {
return Parse.User.signUp("test1", "test", { foo: "bar" });
}).then(() => {
Expand Down Expand Up @@ -2094,7 +2097,7 @@ describe('Parse.User testing', () => {
});
});

it_exclude_dbs(['postgres'])('delete session by object', (done) => {
it('delete session by object', (done) => {
Parse.Promise.as().then(() => {
return Parse.User.signUp("test1", "test", { foo: "bar" });
}).then(() => {
Expand Down
16 changes: 8 additions & 8 deletions spec/PointerPermissions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Pointer Permissions', () => {
new Config(Parse.applicationId).database.schemaCache.clear();
});

it_exclude_dbs(['postgres'])('should work with find', (done) => {
it('should work with find', (done) => {
let config = new Config(Parse.applicationId);
let user = new Parse.User();
let user2 = new Parse.User();
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('Pointer Permissions', () => {
});


it_exclude_dbs(['postgres'])('should work with write', (done) => {
it('should work with write', (done) => {
let config = new Config(Parse.applicationId);
let user = new Parse.User();
let user2 = new Parse.User();
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Pointer Permissions', () => {
})
});

it_exclude_dbs(['postgres'])('should let a proper user find', (done) => {
it('should let a proper user find', (done) => {
let config = new Config(Parse.applicationId);
let user = new Parse.User();
let user2 = new Parse.User();
Expand Down Expand Up @@ -199,7 +199,7 @@ describe('Pointer Permissions', () => {
})
});

it_exclude_dbs(['postgres'])('should handle multiple writeUserFields', done => {
it('should handle multiple writeUserFields', done => {
let config = new Config(Parse.applicationId);
let user = new Parse.User();
let user2 = new Parse.User();
Expand Down Expand Up @@ -281,7 +281,7 @@ describe('Pointer Permissions', () => {
})
});

it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL write (PP Locked)', (done) => {
it('tests CLP / Pointer Perms / ACL write (PP Locked)', (done) => {
/*
tests:
CLP: update closed ({})
Expand Down Expand Up @@ -328,7 +328,7 @@ describe('Pointer Permissions', () => {
});
});

it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL write (ACL Locked)', (done) => {
it('tests CLP / Pointer Perms / ACL write (ACL Locked)', (done) => {
/*
tests:
CLP: update closed ({})
Expand Down Expand Up @@ -373,7 +373,7 @@ describe('Pointer Permissions', () => {
});
});

it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL write (ACL/PP OK)', (done) => {
it('tests CLP / Pointer Perms / ACL write (ACL/PP OK)', (done) => {
/*
tests:
CLP: update closed ({})
Expand Down Expand Up @@ -418,7 +418,7 @@ describe('Pointer Permissions', () => {
});
});

it_exclude_dbs(['postgres'])('tests CLP / Pointer Perms / ACL read (PP locked)', (done) => {
it('tests CLP / Pointer Perms / ACL read (PP locked)', (done) => {
/*
tests:
CLP: find/get open ({})
Expand Down
4 changes: 2 additions & 2 deletions spec/PushController.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ describe('PushController', () => {
})
});

it_exclude_dbs(['postgres'])('should support full RESTQuery for increment', (done) => {
it('should support full RESTQuery for increment', (done) => {
var payload = {data: {
alert: "Hello World!",
badge: 'Increment',
Expand Down Expand Up @@ -392,7 +392,7 @@ describe('PushController', () => {
pushController.sendPush(payload, where, config, auth).then((result) => {
done();
}).catch((err) => {
fail('should not fail');
jfail(err);
done();
});
});
Expand Down
Loading