Postgres: Properly initialize database on startup and debugger (#7255)
* PG: Properly initialize database * fix flaky tests * flaky test * correct test * no idea * clean up debugger
This commit is contained in:
87
package-lock.json
generated
87
package-lock.json
generated
@@ -4672,7 +4672,6 @@
|
|||||||
"version": "0.10.53",
|
"version": "0.10.53",
|
||||||
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz",
|
"resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.53.tgz",
|
||||||
"integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==",
|
"integrity": "sha512-Xs2Stw6NiNHWypzRTY1MtaG/uJlwCk8kH81920ma8mvN8Xq1gsfhZvpkImLQArw8AHnv8MT2I45J3c0R8slE+Q==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"es6-iterator": "~2.0.3",
|
"es6-iterator": "~2.0.3",
|
||||||
"es6-symbol": "~3.1.3",
|
"es6-symbol": "~3.1.3",
|
||||||
@@ -4689,7 +4688,6 @@
|
|||||||
"version": "2.0.3",
|
"version": "2.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.3.tgz",
|
||||||
"integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
|
"integrity": "sha1-p96IkUGgWpSwhUQDstCg+/qY87c=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"d": "1",
|
"d": "1",
|
||||||
"es5-ext": "^0.10.35",
|
"es5-ext": "^0.10.35",
|
||||||
@@ -4700,7 +4698,6 @@
|
|||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"es5-ext": "^0.10.50",
|
"es5-ext": "^0.10.50",
|
||||||
"type": "^1.0.1"
|
"type": "^1.0.1"
|
||||||
@@ -4725,7 +4722,6 @@
|
|||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.3.tgz",
|
||||||
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
"integrity": "sha512-NJ6Yn3FuDinBaBRWl/q5X/s4koRHBrgKAu+yGI6JCBeiu3qrcbJhwT2GeR/EXVfylRk8dpQVJoLEFhK+Mu31NA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"d": "^1.0.1",
|
"d": "^1.0.1",
|
||||||
"ext": "^1.1.2"
|
"ext": "^1.1.2"
|
||||||
@@ -4735,7 +4731,6 @@
|
|||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"es5-ext": "^0.10.50",
|
"es5-ext": "^0.10.50",
|
||||||
"type": "^1.0.1"
|
"type": "^1.0.1"
|
||||||
@@ -5070,7 +5065,6 @@
|
|||||||
"version": "0.3.5",
|
"version": "0.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz",
|
||||||
"integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=",
|
"integrity": "sha1-34xp7vFkeSPHFXuc6DhAYQsCzDk=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"d": "1",
|
"d": "1",
|
||||||
"es5-ext": "~0.10.14"
|
"es5-ext": "~0.10.14"
|
||||||
@@ -5080,7 +5074,6 @@
|
|||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||||
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"es5-ext": "^0.10.50",
|
"es5-ext": "^0.10.50",
|
||||||
"type": "^1.0.1"
|
"type": "^1.0.1"
|
||||||
@@ -5232,7 +5225,6 @@
|
|||||||
"version": "1.4.0",
|
"version": "1.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/ext/-/ext-1.4.0.tgz",
|
||||||
"integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==",
|
"integrity": "sha512-Key5NIsUxdqKg3vIsdw9dSuXpPCQ297y6wBjL30edxwPgt2E44WcWBZey/ZvUc6sERLTxKdyCu4gZFmUbk1Q7A==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"type": "^2.0.0"
|
"type": "^2.0.0"
|
||||||
},
|
},
|
||||||
@@ -5240,8 +5232,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/type/-/type-2.1.0.tgz",
|
||||||
"integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA==",
|
"integrity": "sha512-G9absDWvhAWCV2gmF1zKud3OyC61nZDwWvBL2DApaVFogI07CprggiQAOOjvp2NRjYWFzPyu7vwtDrQFq8jeSA=="
|
||||||
"dev": true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -8281,7 +8272,6 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz",
|
||||||
"integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=",
|
"integrity": "sha1-Jzi9nw089PhEkMVzbEhpmsYyzaM=",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"es5-ext": "~0.10.2"
|
"es5-ext": "~0.10.2"
|
||||||
}
|
}
|
||||||
@@ -8917,8 +8907,7 @@
|
|||||||
"next-tick": {
|
"next-tick": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.0.0.tgz",
|
||||||
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw=",
|
"integrity": "sha1-yobR/ogoFpsBICCOPchCS524NCw="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"nice-try": {
|
"nice-try": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
@@ -9611,6 +9600,74 @@
|
|||||||
"resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.6.2.tgz",
|
"resolved": "https://registry.npmjs.org/pg-minify/-/pg-minify-1.6.2.tgz",
|
||||||
"integrity": "sha512-1KdmFGGTP6jplJoI8MfvRlfvMiyBivMRP7/ffh4a11RUFJ7kC2J0ZHlipoKiH/1hz+DVgceon9U2qbaHpPeyPg=="
|
"integrity": "sha512-1KdmFGGTP6jplJoI8MfvRlfvMiyBivMRP7/ffh4a11RUFJ7kC2J0ZHlipoKiH/1hz+DVgceon9U2qbaHpPeyPg=="
|
||||||
},
|
},
|
||||||
|
"pg-monitor": {
|
||||||
|
"version": "1.4.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/pg-monitor/-/pg-monitor-1.4.1.tgz",
|
||||||
|
"integrity": "sha512-HLLPPC/2yn7+fOpvatAAMFQMzk/8JwaVS7ATp70Uy+7aTiTvlzIqsTixc6E14L/EGk8fvhu/FJ7qiFbxygbwIA==",
|
||||||
|
"requires": {
|
||||||
|
"cli-color": "2.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"cli-color": {
|
||||||
|
"version": "2.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/cli-color/-/cli-color-2.0.0.tgz",
|
||||||
|
"integrity": "sha512-a0VZ8LeraW0jTuCkuAGMNufareGHhyZU9z8OGsW0gXd1hZGi1SRuNRXdbGkraBBKnhyUhyebFWnRbp+dIn0f0A==",
|
||||||
|
"requires": {
|
||||||
|
"ansi-regex": "^2.1.1",
|
||||||
|
"d": "^1.0.1",
|
||||||
|
"es5-ext": "^0.10.51",
|
||||||
|
"es6-iterator": "^2.0.3",
|
||||||
|
"memoizee": "^0.4.14",
|
||||||
|
"timers-ext": "^0.1.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"d": {
|
||||||
|
"version": "1.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/d/-/d-1.0.1.tgz",
|
||||||
|
"integrity": "sha512-m62ShEObQ39CfralilEQRjH6oAMtNCV1xJyEx5LpRYUVN+EviphDgUc/F3hnYbADmkiNs67Y+3ylmlG7Lnu+FA==",
|
||||||
|
"requires": {
|
||||||
|
"es5-ext": "^0.10.50",
|
||||||
|
"type": "^1.0.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"es6-weak-map": {
|
||||||
|
"version": "2.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/es6-weak-map/-/es6-weak-map-2.0.3.tgz",
|
||||||
|
"integrity": "sha512-p5um32HOTO1kP+w7PRnB+5lQ43Z6muuMuIMffvDN8ZB4GcnjLBV6zGStpbASIMk4DCAvEaamhe2zhyCb/QXXsA==",
|
||||||
|
"requires": {
|
||||||
|
"d": "1",
|
||||||
|
"es5-ext": "^0.10.46",
|
||||||
|
"es6-iterator": "^2.0.3",
|
||||||
|
"es6-symbol": "^3.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"is-promise": {
|
||||||
|
"version": "2.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz",
|
||||||
|
"integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ=="
|
||||||
|
},
|
||||||
|
"memoizee": {
|
||||||
|
"version": "0.4.15",
|
||||||
|
"resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.4.15.tgz",
|
||||||
|
"integrity": "sha512-UBWmJpLZd5STPm7PMUlOw/TSy972M+z8gcyQ5veOnSDRREz/0bmpyTfKt3/51DhEBqCZQn1udM/5flcSPYhkdQ==",
|
||||||
|
"requires": {
|
||||||
|
"d": "^1.0.1",
|
||||||
|
"es5-ext": "^0.10.53",
|
||||||
|
"es6-weak-map": "^2.0.3",
|
||||||
|
"event-emitter": "^0.3.5",
|
||||||
|
"is-promise": "^2.2.2",
|
||||||
|
"lru-queue": "^0.1.0",
|
||||||
|
"next-tick": "^1.1.0",
|
||||||
|
"timers-ext": "^0.1.7"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"next-tick": {
|
||||||
|
"version": "1.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/next-tick/-/next-tick-1.1.0.tgz",
|
||||||
|
"integrity": "sha512-CXdUiJembsNjuToQvxayPZF9Vqht7hewsvy2sOWafLvi2awflj9mOC6bHIg50orX8IJvWKY9wYQ/zB2kogPslQ=="
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"pg-pool": {
|
"pg-pool": {
|
||||||
"version": "3.2.2",
|
"version": "3.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.2.2.tgz",
|
||||||
@@ -11241,7 +11298,6 @@
|
|||||||
"version": "0.1.7",
|
"version": "0.1.7",
|
||||||
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
"resolved": "https://registry.npmjs.org/timers-ext/-/timers-ext-0.1.7.tgz",
|
||||||
"integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
|
"integrity": "sha512-b85NUNzTSdodShTIbky6ZF02e8STtVVfD+fu4aXXShEELpozH+bCpJLYMPZbsABN2wDH7fJpqIoXxJpzbf0NqQ==",
|
||||||
"dev": true,
|
|
||||||
"requires": {
|
"requires": {
|
||||||
"es5-ext": "~0.10.46",
|
"es5-ext": "~0.10.46",
|
||||||
"next-tick": "1"
|
"next-tick": "1"
|
||||||
@@ -11401,8 +11457,7 @@
|
|||||||
"type": {
|
"type": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz",
|
||||||
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg==",
|
"integrity": "sha512-+5nt5AAniqsCnu2cEQQdpzCAh33kVx8n0VoFidKpB1dVVLAN/F+bgVOqOJqOnEnrhp222clB5p3vUlD+1QAnfg=="
|
||||||
"dev": true
|
|
||||||
},
|
},
|
||||||
"type-check": {
|
"type-check": {
|
||||||
"version": "0.3.2",
|
"version": "0.3.2",
|
||||||
|
|||||||
@@ -50,6 +50,7 @@
|
|||||||
"mongodb": "3.6.3",
|
"mongodb": "3.6.3",
|
||||||
"mustache": "4.1.0",
|
"mustache": "4.1.0",
|
||||||
"parse": "3.1.0",
|
"parse": "3.1.0",
|
||||||
|
"pg-monitor": "1.4.1",
|
||||||
"pg-promise": "10.9.2",
|
"pg-promise": "10.9.2",
|
||||||
"pluralize": "8.0.0",
|
"pluralize": "8.0.0",
|
||||||
"redis": "3.0.2",
|
"redis": "3.0.2",
|
||||||
|
|||||||
@@ -230,10 +230,10 @@ describe('Auth', () => {
|
|||||||
const role2 = new Parse.Role('role2loadtest' + i, acl2);
|
const role2 = new Parse.Role('role2loadtest' + i, acl2);
|
||||||
role.getUsers().add([user]);
|
role.getUsers().add([user]);
|
||||||
role2.getUsers().add([user2]);
|
role2.getUsers().add([user2]);
|
||||||
roles.push(role.save());
|
roles.push(role);
|
||||||
roles.push(role2.save());
|
roles.push(role2);
|
||||||
}
|
}
|
||||||
const savedRoles = await Promise.all(roles);
|
const savedRoles = await Parse.Object.saveAll(roles);
|
||||||
expect(savedRoles.length).toBe(rolesNumber * 2);
|
expect(savedRoles.length).toBe(rolesNumber * 2);
|
||||||
const cloudRoles = await userAuth.getRolesForUser();
|
const cloudRoles = await userAuth.getRolesForUser();
|
||||||
const cloudRoles2 = await user2Auth.getRolesForUser();
|
const cloudRoles2 = await user2Auth.getRolesForUser();
|
||||||
|
|||||||
@@ -170,6 +170,7 @@ describe('miscellaneous', function () {
|
|||||||
const config = Config.get('test');
|
const config = Config.get('test');
|
||||||
// Remove existing data to clear out unique index
|
// Remove existing data to clear out unique index
|
||||||
TestUtils.destroyAllDataPermanently()
|
TestUtils.destroyAllDataPermanently()
|
||||||
|
.then(() => config.database.adapter.performInitialization({ VolatileClassesSchemas: [] }))
|
||||||
.then(() => config.database.adapter.createClass('_User', userSchema))
|
.then(() => config.database.adapter.createClass('_User', userSchema))
|
||||||
.then(() =>
|
.then(() =>
|
||||||
config.database.adapter
|
config.database.adapter
|
||||||
@@ -210,6 +211,7 @@ describe('miscellaneous', function () {
|
|||||||
const config = Config.get('test');
|
const config = Config.get('test');
|
||||||
// Remove existing data to clear out unique index
|
// Remove existing data to clear out unique index
|
||||||
TestUtils.destroyAllDataPermanently()
|
TestUtils.destroyAllDataPermanently()
|
||||||
|
.then(() => config.database.adapter.performInitialization({ VolatileClassesSchemas: [] }))
|
||||||
.then(() => config.database.adapter.createClass('_User', userSchema))
|
.then(() => config.database.adapter.createClass('_User', userSchema))
|
||||||
.then(() =>
|
.then(() =>
|
||||||
config.database.adapter.createObject('_User', userSchema, {
|
config.database.adapter.createObject('_User', userSchema, {
|
||||||
|
|||||||
@@ -54,8 +54,6 @@ describe('ParseGraphQLSchema', () => {
|
|||||||
const graphQLSchema = await parseGraphQLSchema.load();
|
const graphQLSchema = await parseGraphQLSchema.load();
|
||||||
const updatedGraphQLSchema = await parseGraphQLSchema.load();
|
const updatedGraphQLSchema = await parseGraphQLSchema.load();
|
||||||
expect(graphQLSchema).toBe(updatedGraphQLSchema);
|
expect(graphQLSchema).toBe(updatedGraphQLSchema);
|
||||||
await new Promise(resolve => setTimeout(resolve, 200));
|
|
||||||
expect(graphQLSchema).toBe(await parseGraphQLSchema.load());
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should load a brand new GraphQL Schema if Parse Schema changes', async () => {
|
it('should load a brand new GraphQL Schema if Parse Schema changes', async () => {
|
||||||
|
|||||||
@@ -275,32 +275,26 @@ describe('Parse.Query testing', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('query with limit equal to maxlimit', function (done) {
|
it('query with limit equal to maxlimit', async () => {
|
||||||
const baz = new TestObject({ foo: 'baz' });
|
const baz = new TestObject({ foo: 'baz' });
|
||||||
const qux = new TestObject({ foo: 'qux' });
|
const qux = new TestObject({ foo: 'qux' });
|
||||||
reconfigureServer({ maxLimit: 1 });
|
await reconfigureServer({ maxLimit: 1 });
|
||||||
Parse.Object.saveAll([baz, qux]).then(function () {
|
await Parse.Object.saveAll([baz, qux]);
|
||||||
const query = new Parse.Query(TestObject);
|
const query = new Parse.Query(TestObject);
|
||||||
query.limit(1);
|
query.limit(1);
|
||||||
query.find().then(function (results) {
|
const results = await query.find();
|
||||||
equal(results.length, 1);
|
equal(results.length, 1);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('query with limit exceeding maxlimit', function (done) {
|
it('query with limit exceeding maxlimit', async () => {
|
||||||
const baz = new TestObject({ foo: 'baz' });
|
const baz = new TestObject({ foo: 'baz' });
|
||||||
const qux = new TestObject({ foo: 'qux' });
|
const qux = new TestObject({ foo: 'qux' });
|
||||||
reconfigureServer({ maxLimit: 1 });
|
await reconfigureServer({ maxLimit: 1 });
|
||||||
Parse.Object.saveAll([baz, qux]).then(function () {
|
await Parse.Object.saveAll([baz, qux]);
|
||||||
const query = new Parse.Query(TestObject);
|
const query = new Parse.Query(TestObject);
|
||||||
query.limit(2);
|
query.limit(2);
|
||||||
query.find().then(function (results) {
|
const results = await query.find();
|
||||||
equal(results.length, 1);
|
equal(results.length, 1);
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('containedIn object array queries', function (done) {
|
it('containedIn object array queries', function (done) {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ const ParseServerRESTController = require('../lib/ParseServerRESTController')
|
|||||||
.ParseServerRESTController;
|
.ParseServerRESTController;
|
||||||
const ParseServer = require('../lib/ParseServer').default;
|
const ParseServer = require('../lib/ParseServer').default;
|
||||||
const Parse = require('parse/node').Parse;
|
const Parse = require('parse/node').Parse;
|
||||||
const TestUtils = require('../lib/TestUtils');
|
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
|
|
||||||
let RESTController;
|
let RESTController;
|
||||||
@@ -183,10 +182,6 @@ describe('ParseServerRESTController', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestUtils.destroyAllDataPermanently(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle a batch request with transaction = true', done => {
|
it('should handle a batch request with transaction = true', done => {
|
||||||
const myObject = new Parse.Object('MyObject'); // This is important because transaction only works on pre-existing collections
|
const myObject = new Parse.Object('MyObject'); // This is important because transaction only works on pre-existing collections
|
||||||
myObject
|
myObject
|
||||||
|
|||||||
@@ -19,10 +19,11 @@ const dropTable = (client, className) => {
|
|||||||
|
|
||||||
describe_only_db('postgres')('PostgresStorageAdapter', () => {
|
describe_only_db('postgres')('PostgresStorageAdapter', () => {
|
||||||
let adapter;
|
let adapter;
|
||||||
beforeEach(() => {
|
beforeEach(async () => {
|
||||||
const config = Config.get('test');
|
const config = Config.get('test');
|
||||||
adapter = config.database.adapter;
|
adapter = config.database.adapter;
|
||||||
return adapter.deleteAllClasses();
|
await adapter.deleteAllClasses();
|
||||||
|
await adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('schemaUpgrade, upgrade the database schema when schema changes', done => {
|
it('schemaUpgrade, upgrade the database schema when schema changes', done => {
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ describe('SchemaController', () => {
|
|||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await config.database.schemaCache.clear();
|
await config.database.schemaCache.clear();
|
||||||
await TestUtils.destroyAllDataPermanently(false);
|
await TestUtils.destroyAllDataPermanently(false);
|
||||||
|
await config.database.adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can validate one object', done => {
|
it('can validate one object', done => {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
const batch = require('../lib/batch');
|
const batch = require('../lib/batch');
|
||||||
const request = require('../lib/request');
|
const request = require('../lib/request');
|
||||||
const TestUtils = require('../lib/TestUtils');
|
|
||||||
const semver = require('semver');
|
const semver = require('semver');
|
||||||
|
|
||||||
const originalURL = '/parse/batch';
|
const originalURL = '/parse/batch';
|
||||||
@@ -187,10 +186,6 @@ describe('batch', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestUtils.destroyAllDataPermanently(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should handle a batch request with transaction = true', done => {
|
it('should handle a batch request with transaction = true', done => {
|
||||||
const myObject = new Parse.Object('MyObject'); // This is important because transaction only works on pre-existing collections
|
const myObject = new Parse.Object('MyObject'); // This is important because transaction only works on pre-existing collections
|
||||||
myObject
|
myObject
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ const reconfigureServer = changedConfiguration => {
|
|||||||
const Parse = require('parse/node');
|
const Parse = require('parse/node');
|
||||||
Parse.serverURL = 'http://localhost:' + port + '/1';
|
Parse.serverURL = 'http://localhost:' + port + '/1';
|
||||||
|
|
||||||
beforeEach(done => {
|
beforeEach(async () => {
|
||||||
try {
|
try {
|
||||||
Parse.User.enableUnsafeCurrentUser();
|
Parse.User.enableUnsafeCurrentUser();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -175,23 +175,10 @@ beforeEach(done => {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TestUtils.destroyAllDataPermanently(true)
|
await reconfigureServer();
|
||||||
.catch(error => {
|
|
||||||
// For tests that connect to their own mongo, there won't be any data to delete.
|
Parse.initialize('test', 'test', 'test');
|
||||||
if (error.message === 'ns not found' || error.message.startsWith('connect ECONNREFUSED')) {
|
Parse.serverURL = 'http://localhost:' + port + '/1';
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
fail(error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.then(reconfigureServer)
|
|
||||||
.then(() => {
|
|
||||||
Parse.initialize('test', 'test', 'test');
|
|
||||||
Parse.serverURL = 'http://localhost:' + port + '/1';
|
|
||||||
done();
|
|
||||||
})
|
|
||||||
.catch(done.fail);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function (done) {
|
afterEach(function (done) {
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ describe('schemas', () => {
|
|||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await config.database.schemaCache.clear();
|
await config.database.schemaCache.clear();
|
||||||
await TestUtils.destroyAllDataPermanently(false);
|
await TestUtils.destroyAllDataPermanently(false);
|
||||||
|
await config.database.adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('requires the master key to get all schemas', done => {
|
it('requires the master key to get all schemas', done => {
|
||||||
@@ -2816,7 +2817,11 @@ describe('schemas', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('index management', () => {
|
describe('index management', () => {
|
||||||
beforeEach(() => require('../lib/TestUtils').destroyAllDataPermanently());
|
beforeEach(async () => {
|
||||||
|
await TestUtils.destroyAllDataPermanently(false);
|
||||||
|
await config.database.adapter.performInitialization({ VolatileClassesSchemas: [] });
|
||||||
|
});
|
||||||
|
|
||||||
it('cannot create index if field does not exist', done => {
|
it('cannot create index if field does not exist', done => {
|
||||||
request({
|
request({
|
||||||
url: 'http://localhost:8378/1/schemas/NewClass',
|
url: 'http://localhost:8378/1/schemas/NewClass',
|
||||||
|
|||||||
@@ -18,6 +18,11 @@ export function createClient(uri, databaseOptions) {
|
|||||||
const pgp = require('pg-promise')(initOptions);
|
const pgp = require('pg-promise')(initOptions);
|
||||||
const client = pgp(dbOptions);
|
const client = pgp(dbOptions);
|
||||||
|
|
||||||
|
if (process.env.PARSE_SERVER_LOG_LEVEL === 'debug') {
|
||||||
|
const monitor = require('pg-monitor');
|
||||||
|
monitor.attach(initOptions);
|
||||||
|
}
|
||||||
|
|
||||||
if (dbOptions.pgOptions) {
|
if (dbOptions.pgOptions) {
|
||||||
for (const key in dbOptions.pgOptions) {
|
for (const key in dbOptions.pgOptions) {
|
||||||
pgp.pg.defaults[key] = dbOptions.pgOptions[key];
|
pgp.pg.defaults[key] = dbOptions.pgOptions[key];
|
||||||
|
|||||||
@@ -852,9 +852,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setClassLevelPermissions(className: string, CLPs: any) {
|
async setClassLevelPermissions(className: string, CLPs: any) {
|
||||||
const self = this;
|
|
||||||
await this._client.task('set-class-level-permissions', async t => {
|
await this._client.task('set-class-level-permissions', async t => {
|
||||||
await self._ensureSchemaCollectionExists(t);
|
|
||||||
const values = [className, 'schema', 'classLevelPermissions', JSON.stringify(CLPs)];
|
const values = [className, 'schema', 'classLevelPermissions', JSON.stringify(CLPs)];
|
||||||
await t.none(
|
await t.none(
|
||||||
`UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className" = $1`,
|
`UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className" = $1`,
|
||||||
@@ -917,7 +915,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
if (deletedIndexes.length > 0) {
|
if (deletedIndexes.length > 0) {
|
||||||
await self.dropIndexes(className, deletedIndexes, t);
|
await self.dropIndexes(className, deletedIndexes, t);
|
||||||
}
|
}
|
||||||
await self._ensureSchemaCollectionExists(t);
|
|
||||||
await t.none(
|
await t.none(
|
||||||
'UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className" = $1',
|
'UPDATE "_SCHEMA" SET $2:name = json_object_set_key($2:name, $3::text, $4::jsonb) WHERE "className" = $1',
|
||||||
[className, 'schema', 'indexes', JSON.stringify(existingIndexes)]
|
[className, 'schema', 'indexes', JSON.stringify(existingIndexes)]
|
||||||
@@ -948,8 +945,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
// Just create a table, do not insert in schema
|
// Just create a table, do not insert in schema
|
||||||
async createTable(className: string, schema: SchemaType, conn: any) {
|
async createTable(className: string, schema: SchemaType, conn: any) {
|
||||||
conn = conn || this._client;
|
conn = conn || this._client;
|
||||||
const self = this;
|
debug('createTable');
|
||||||
debug('createTable', className, schema);
|
|
||||||
const valuesArray = [];
|
const valuesArray = [];
|
||||||
const patternsArray = [];
|
const patternsArray = [];
|
||||||
const fields = Object.assign({}, schema.fields);
|
const fields = Object.assign({}, schema.fields);
|
||||||
@@ -987,10 +983,8 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
const qs = `CREATE TABLE IF NOT EXISTS $1:name (${patternsArray.join()})`;
|
const qs = `CREATE TABLE IF NOT EXISTS $1:name (${patternsArray.join()})`;
|
||||||
const values = [className, ...valuesArray];
|
const values = [className, ...valuesArray];
|
||||||
|
|
||||||
debug(qs, values);
|
|
||||||
return conn.task('create-table', async t => {
|
return conn.task('create-table', async t => {
|
||||||
try {
|
try {
|
||||||
await self._ensureSchemaCollectionExists(t);
|
|
||||||
await t.none(qs, values);
|
await t.none(qs, values);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.code !== PostgresDuplicateRelationError) {
|
if (error.code !== PostgresDuplicateRelationError) {
|
||||||
@@ -1012,7 +1006,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async schemaUpgrade(className: string, schema: SchemaType, conn: any) {
|
async schemaUpgrade(className: string, schema: SchemaType, conn: any) {
|
||||||
debug('schemaUpgrade', { className, schema });
|
debug('schemaUpgrade');
|
||||||
conn = conn || this._client;
|
conn = conn || this._client;
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
@@ -1034,7 +1028,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
|
|
||||||
async addFieldIfNotExists(className: string, fieldName: string, type: any, conn: any) {
|
async addFieldIfNotExists(className: string, fieldName: string, type: any, conn: any) {
|
||||||
// TODO: Must be revised for invalid logic...
|
// TODO: Must be revised for invalid logic...
|
||||||
debug('addFieldIfNotExists', { className, fieldName, type });
|
debug('addFieldIfNotExists');
|
||||||
conn = conn || this._client;
|
conn = conn || this._client;
|
||||||
const self = this;
|
const self = this;
|
||||||
await conn.tx('add-field-if-not-exists', async t => {
|
await conn.tx('add-field-if-not-exists', async t => {
|
||||||
@@ -1153,7 +1147,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
|
|
||||||
// Returns a Promise.
|
// Returns a Promise.
|
||||||
async deleteFields(className: string, schema: SchemaType, fieldNames: string[]): Promise<void> {
|
async deleteFields(className: string, schema: SchemaType, fieldNames: string[]): Promise<void> {
|
||||||
debug('deleteFields', className, fieldNames);
|
debug('deleteFields');
|
||||||
fieldNames = fieldNames.reduce((list: Array<string>, fieldName: string) => {
|
fieldNames = fieldNames.reduce((list: Array<string>, fieldName: string) => {
|
||||||
const field = schema.fields[fieldName];
|
const field = schema.fields[fieldName];
|
||||||
if (field.type !== 'Relation') {
|
if (field.type !== 'Relation') {
|
||||||
@@ -1185,9 +1179,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
// schemas cannot be retrieved, returns a promise that rejects. Requirements for the
|
// schemas cannot be retrieved, returns a promise that rejects. Requirements for the
|
||||||
// rejection reason are TBD.
|
// rejection reason are TBD.
|
||||||
async getAllClasses() {
|
async getAllClasses() {
|
||||||
const self = this;
|
|
||||||
return this._client.task('get-all-classes', async t => {
|
return this._client.task('get-all-classes', async t => {
|
||||||
await self._ensureSchemaCollectionExists(t);
|
|
||||||
return await t.map('SELECT * FROM "_SCHEMA"', null, row =>
|
return await t.map('SELECT * FROM "_SCHEMA"', null, row =>
|
||||||
toParseSchema({ className: row.className, ...row.schema })
|
toParseSchema({ className: row.className, ...row.schema })
|
||||||
);
|
);
|
||||||
@@ -1198,7 +1190,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
// this adapter doesn't know about the schema, return a promise that rejects with
|
// this adapter doesn't know about the schema, return a promise that rejects with
|
||||||
// undefined as the reason.
|
// undefined as the reason.
|
||||||
async getClass(className: string) {
|
async getClass(className: string) {
|
||||||
debug('getClass', className);
|
debug('getClass');
|
||||||
return this._client
|
return this._client
|
||||||
.any('SELECT * FROM "_SCHEMA" WHERE "className" = $<className>', {
|
.any('SELECT * FROM "_SCHEMA" WHERE "className" = $<className>', {
|
||||||
className,
|
className,
|
||||||
@@ -1219,7 +1211,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
object: any,
|
object: any,
|
||||||
transactionalSession: ?any
|
transactionalSession: ?any
|
||||||
) {
|
) {
|
||||||
debug('createObject', className, object);
|
debug('createObject');
|
||||||
let columnsArray = [];
|
let columnsArray = [];
|
||||||
const valuesArray = [];
|
const valuesArray = [];
|
||||||
schema = toPostgresSchema(schema);
|
schema = toPostgresSchema(schema);
|
||||||
@@ -1340,7 +1332,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
|
|
||||||
const qs = `INSERT INTO $1:name (${columnsPattern}) VALUES (${valuesPattern})`;
|
const qs = `INSERT INTO $1:name (${columnsPattern}) VALUES (${valuesPattern})`;
|
||||||
const values = [className, ...columnsArray, ...valuesArray];
|
const values = [className, ...columnsArray, ...valuesArray];
|
||||||
debug(qs, values);
|
|
||||||
const promise = (transactionalSession ? transactionalSession.t : this._client)
|
const promise = (transactionalSession ? transactionalSession.t : this._client)
|
||||||
.none(qs, values)
|
.none(qs, values)
|
||||||
.then(() => ({ ops: [object] }))
|
.then(() => ({ ops: [object] }))
|
||||||
@@ -1376,7 +1367,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
query: QueryType,
|
query: QueryType,
|
||||||
transactionalSession: ?any
|
transactionalSession: ?any
|
||||||
) {
|
) {
|
||||||
debug('deleteObjectsByQuery', className, query);
|
debug('deleteObjectsByQuery');
|
||||||
const values = [className];
|
const values = [className];
|
||||||
const index = 2;
|
const index = 2;
|
||||||
const where = buildWhereClause({
|
const where = buildWhereClause({
|
||||||
@@ -1390,7 +1381,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
where.pattern = 'TRUE';
|
where.pattern = 'TRUE';
|
||||||
}
|
}
|
||||||
const qs = `WITH deleted AS (DELETE FROM $1:name WHERE ${where.pattern} RETURNING *) SELECT count(*) FROM deleted`;
|
const qs = `WITH deleted AS (DELETE FROM $1:name WHERE ${where.pattern} RETURNING *) SELECT count(*) FROM deleted`;
|
||||||
debug(qs, values);
|
|
||||||
const promise = (transactionalSession ? transactionalSession.t : this._client)
|
const promise = (transactionalSession ? transactionalSession.t : this._client)
|
||||||
.one(qs, values, a => +a.count)
|
.one(qs, values, a => +a.count)
|
||||||
.then(count => {
|
.then(count => {
|
||||||
@@ -1419,7 +1409,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
update: any,
|
update: any,
|
||||||
transactionalSession: ?any
|
transactionalSession: ?any
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
debug('findOneAndUpdate', className, query, update);
|
debug('findOneAndUpdate');
|
||||||
return this.updateObjectsByQuery(className, schema, query, update, transactionalSession).then(
|
return this.updateObjectsByQuery(className, schema, query, update, transactionalSession).then(
|
||||||
val => val[0]
|
val => val[0]
|
||||||
);
|
);
|
||||||
@@ -1433,7 +1423,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
update: any,
|
update: any,
|
||||||
transactionalSession: ?any
|
transactionalSession: ?any
|
||||||
): Promise<[any]> {
|
): Promise<[any]> {
|
||||||
debug('updateObjectsByQuery', className, query, update);
|
debug('updateObjectsByQuery');
|
||||||
const updatePatterns = [];
|
const updatePatterns = [];
|
||||||
const values = [className];
|
const values = [className];
|
||||||
let index = 2;
|
let index = 2;
|
||||||
@@ -1658,7 +1648,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
index += 2;
|
index += 2;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
debug('Not supported update', fieldName, fieldValue);
|
debug('Not supported update', { fieldName, fieldValue });
|
||||||
return Promise.reject(
|
return Promise.reject(
|
||||||
new Parse.Error(
|
new Parse.Error(
|
||||||
Parse.Error.OPERATION_FORBIDDEN,
|
Parse.Error.OPERATION_FORBIDDEN,
|
||||||
@@ -1678,7 +1668,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
|
|
||||||
const whereClause = where.pattern.length > 0 ? `WHERE ${where.pattern}` : '';
|
const whereClause = where.pattern.length > 0 ? `WHERE ${where.pattern}` : '';
|
||||||
const qs = `UPDATE $1:name SET ${updatePatterns.join()} ${whereClause} RETURNING *`;
|
const qs = `UPDATE $1:name SET ${updatePatterns.join()} ${whereClause} RETURNING *`;
|
||||||
debug('update: ', qs, values);
|
|
||||||
const promise = (transactionalSession ? transactionalSession.t : this._client).any(qs, values);
|
const promise = (transactionalSession ? transactionalSession.t : this._client).any(qs, values);
|
||||||
if (transactionalSession) {
|
if (transactionalSession) {
|
||||||
transactionalSession.batch.push(promise);
|
transactionalSession.batch.push(promise);
|
||||||
@@ -1694,7 +1683,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
update: any,
|
update: any,
|
||||||
transactionalSession: ?any
|
transactionalSession: ?any
|
||||||
) {
|
) {
|
||||||
debug('upsertOneObject', { className, query, update });
|
debug('upsertOneObject');
|
||||||
const createValue = Object.assign({}, query, update);
|
const createValue = Object.assign({}, query, update);
|
||||||
return this.createObject(className, schema, createValue, transactionalSession).catch(error => {
|
return this.createObject(className, schema, createValue, transactionalSession).catch(error => {
|
||||||
// ignore duplicate value errors as it's upsert
|
// ignore duplicate value errors as it's upsert
|
||||||
@@ -1711,14 +1700,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
query: QueryType,
|
query: QueryType,
|
||||||
{ skip, limit, sort, keys, caseInsensitive, explain }: QueryOptions
|
{ skip, limit, sort, keys, caseInsensitive, explain }: QueryOptions
|
||||||
) {
|
) {
|
||||||
debug('find', className, query, {
|
debug('find');
|
||||||
skip,
|
|
||||||
limit,
|
|
||||||
sort,
|
|
||||||
keys,
|
|
||||||
caseInsensitive,
|
|
||||||
explain,
|
|
||||||
});
|
|
||||||
const hasLimit = limit !== undefined;
|
const hasLimit = limit !== undefined;
|
||||||
const hasSkip = skip !== undefined;
|
const hasSkip = skip !== undefined;
|
||||||
let values = [className];
|
let values = [className];
|
||||||
@@ -1785,7 +1767,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
|
|
||||||
const originalQuery = `SELECT ${columns} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern}`;
|
const originalQuery = `SELECT ${columns} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern}`;
|
||||||
const qs = explain ? this.createExplainableQuery(originalQuery) : originalQuery;
|
const qs = explain ? this.createExplainableQuery(originalQuery) : originalQuery;
|
||||||
debug(qs, values);
|
|
||||||
return this._client
|
return this._client
|
||||||
.any(qs, values)
|
.any(qs, values)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -1933,7 +1914,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
readPreference?: string,
|
readPreference?: string,
|
||||||
estimate?: boolean = true
|
estimate?: boolean = true
|
||||||
) {
|
) {
|
||||||
debug('count', className, query, readPreference, estimate);
|
debug('count');
|
||||||
const values = [className];
|
const values = [className];
|
||||||
const where = buildWhereClause({
|
const where = buildWhereClause({
|
||||||
schema,
|
schema,
|
||||||
@@ -1969,7 +1950,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async distinct(className: string, schema: SchemaType, query: QueryType, fieldName: string) {
|
async distinct(className: string, schema: SchemaType, query: QueryType, fieldName: string) {
|
||||||
debug('distinct', className, query);
|
debug('distinct');
|
||||||
let field = fieldName;
|
let field = fieldName;
|
||||||
let column = fieldName;
|
let column = fieldName;
|
||||||
const isNested = fieldName.indexOf('.') >= 0;
|
const isNested = fieldName.indexOf('.') >= 0;
|
||||||
@@ -1996,7 +1977,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
if (isNested) {
|
if (isNested) {
|
||||||
qs = `SELECT DISTINCT ${transformer}($1:raw) $2:raw FROM $3:name ${wherePattern}`;
|
qs = `SELECT DISTINCT ${transformer}($1:raw) $2:raw FROM $3:name ${wherePattern}`;
|
||||||
}
|
}
|
||||||
debug(qs, values);
|
|
||||||
return this._client
|
return this._client
|
||||||
.any(qs, values)
|
.any(qs, values)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
@@ -2035,7 +2015,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
hint: ?mixed,
|
hint: ?mixed,
|
||||||
explain?: boolean
|
explain?: boolean
|
||||||
) {
|
) {
|
||||||
debug('aggregate', className, pipeline, readPreference, hint, explain);
|
debug('aggregate');
|
||||||
const values = [className];
|
const values = [className];
|
||||||
let index: number = 2;
|
let index: number = 2;
|
||||||
let columns: string[] = [];
|
let columns: string[] = [];
|
||||||
@@ -2216,7 +2196,6 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
.filter(Boolean)
|
.filter(Boolean)
|
||||||
.join()} FROM $1:name ${wherePattern} ${skipPattern} ${groupPattern} ${sortPattern} ${limitPattern}`;
|
.join()} FROM $1:name ${wherePattern} ${skipPattern} ${groupPattern} ${sortPattern} ${limitPattern}`;
|
||||||
const qs = explain ? this.createExplainableQuery(originalQuery) : originalQuery;
|
const qs = explain ? this.createExplainableQuery(originalQuery) : originalQuery;
|
||||||
debug(qs, values);
|
|
||||||
return this._client.any(qs, values).then(a => {
|
return this._client.any(qs, values).then(a => {
|
||||||
if (explain) {
|
if (explain) {
|
||||||
return a;
|
return a;
|
||||||
@@ -2244,6 +2223,7 @@ export class PostgresStorageAdapter implements StorageAdapter {
|
|||||||
async performInitialization({ VolatileClassesSchemas }: any) {
|
async performInitialization({ VolatileClassesSchemas }: any) {
|
||||||
// TODO: This method needs to be rewritten to make proper use of connections (@vitaly-t)
|
// TODO: This method needs to be rewritten to make proper use of connections (@vitaly-t)
|
||||||
debug('performInitialization');
|
debug('performInitialization');
|
||||||
|
await this._ensureSchemaCollectionExists();
|
||||||
const promises = VolatileClassesSchemas.map(schema => {
|
const promises = VolatileClassesSchemas.map(schema => {
|
||||||
return this.createTable(schema.className, schema)
|
return this.createTable(schema.className, schema)
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
|
|||||||
@@ -1666,7 +1666,10 @@ class DatabaseController {
|
|||||||
|
|
||||||
// TODO: create indexes on first creation of a _User object. Otherwise it's impossible to
|
// TODO: create indexes on first creation of a _User object. Otherwise it's impossible to
|
||||||
// have a Parse app without it having a _User collection.
|
// have a Parse app without it having a _User collection.
|
||||||
performInitialization() {
|
async performInitialization() {
|
||||||
|
await this.adapter.performInitialization({
|
||||||
|
VolatileClassesSchemas: SchemaController.VolatileClassesSchemas,
|
||||||
|
});
|
||||||
const requiredUserFields = {
|
const requiredUserFields = {
|
||||||
fields: {
|
fields: {
|
||||||
...SchemaController.defaultColumns._Default,
|
...SchemaController.defaultColumns._Default,
|
||||||
@@ -1777,10 +1780,6 @@ class DatabaseController {
|
|||||||
|
|
||||||
const indexPromise = this.adapter.updateSchemaWithIndexes();
|
const indexPromise = this.adapter.updateSchemaWithIndexes();
|
||||||
|
|
||||||
// Create tables for volatile classes
|
|
||||||
const adapterInit = this.adapter.performInitialization({
|
|
||||||
VolatileClassesSchemas: SchemaController.VolatileClassesSchemas,
|
|
||||||
});
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
usernameUniqueness,
|
usernameUniqueness,
|
||||||
usernameCaseInsensitiveIndex,
|
usernameCaseInsensitiveIndex,
|
||||||
@@ -1789,7 +1788,6 @@ class DatabaseController {
|
|||||||
roleUniqueness,
|
roleUniqueness,
|
||||||
idempotencyRequestIdIndex,
|
idempotencyRequestIdIndex,
|
||||||
idempotencyExpireIndex,
|
idempotencyExpireIndex,
|
||||||
adapterInit,
|
|
||||||
indexPromise,
|
indexPromise,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,11 +75,11 @@ class ParseServer {
|
|||||||
this.config = Config.put(Object.assign({}, options, allControllers));
|
this.config = Config.put(Object.assign({}, options, allControllers));
|
||||||
|
|
||||||
logging.setLogger(loggerController);
|
logging.setLogger(loggerController);
|
||||||
const dbInitPromise = databaseController.performInitialization();
|
|
||||||
const hooksLoadPromise = hooksController.load();
|
|
||||||
|
|
||||||
// Note: Tests will start to fail if any validation happens after this is called.
|
// Note: Tests will start to fail if any validation happens after this is called.
|
||||||
Promise.all([dbInitPromise, hooksLoadPromise])
|
databaseController
|
||||||
|
.performInitialization()
|
||||||
|
.then(() => hooksController.load())
|
||||||
.then(() => {
|
.then(() => {
|
||||||
if (serverStartComplete) {
|
if (serverStartComplete) {
|
||||||
serverStartComplete();
|
serverStartComplete();
|
||||||
|
|||||||
Reference in New Issue
Block a user