@@ -863,8 +863,7 @@ export class PostgresStorageAdapter {
|
|||||||
// rejection reason are TBD.
|
// rejection reason are TBD.
|
||||||
getAllClasses() {
|
getAllClasses() {
|
||||||
return this._ensureSchemaCollectionExists()
|
return this._ensureSchemaCollectionExists()
|
||||||
.then(() => this._client.map('SELECT * FROM "_SCHEMA"', null, row => ({ className: row.className, ...row.schema })))
|
.then(() => this._client.map('SELECT * FROM "_SCHEMA"', null, row => toParseSchema({ className: row.className, ...row.schema })));
|
||||||
.then(res => res.map(toParseSchema))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a promise for the schema with the given name, in Parse format. If
|
// Return a promise for the schema with the given name, in Parse format. If
|
||||||
@@ -1401,7 +1400,7 @@ export class PostgresStorageAdapter {
|
|||||||
const constraintName = `unique_${fieldNames.sort().join('_')}`;
|
const constraintName = `unique_${fieldNames.sort().join('_')}`;
|
||||||
const constraintPatterns = fieldNames.map((fieldName, index) => `$${index + 3}:name`);
|
const constraintPatterns = fieldNames.map((fieldName, index) => `$${index + 3}:name`);
|
||||||
const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${constraintPatterns.join(',')})`;
|
const qs = `ALTER TABLE $1:name ADD CONSTRAINT $2:name UNIQUE (${constraintPatterns.join(',')})`;
|
||||||
return this._client.none(qs,[className, constraintName, ...fieldNames])
|
return this._client.none(qs, [className, constraintName, ...fieldNames])
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
if (error.code === PostgresDuplicateRelationError && error.message.includes(constraintName)) {
|
if (error.code === PostgresDuplicateRelationError && error.message.includes(constraintName)) {
|
||||||
// Index already exists. Ignore error.
|
// Index already exists. Ignore error.
|
||||||
@@ -1552,8 +1551,7 @@ export class PostgresStorageAdapter {
|
|||||||
|
|
||||||
const qs = `SELECT ${columns} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern} ${groupPattern}`;
|
const qs = `SELECT ${columns} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern} ${groupPattern}`;
|
||||||
debug(qs, values);
|
debug(qs, values);
|
||||||
return this._client.any(qs, values)
|
return this._client.map(qs, values, a => this.postgresObjectToParseObject(className, a, schema))
|
||||||
.then(results => results.map(object => this.postgresObjectToParseObject(className, object, schema)))
|
|
||||||
.then(results => {
|
.then(results => {
|
||||||
if (countField) {
|
if (countField) {
|
||||||
results[0][countField] = parseInt(results[0][countField], 10);
|
results[0][countField] = parseInt(results[0][countField], 10);
|
||||||
@@ -1579,7 +1577,7 @@ export class PostgresStorageAdapter {
|
|||||||
});
|
});
|
||||||
return Promise.all(promises)
|
return Promise.all(promises)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return this._client.tx(t => {
|
return this._client.tx('perform-initialization', t => {
|
||||||
return t.batch([
|
return t.batch([
|
||||||
t.none(sql.misc.jsonObjectSetKeys),
|
t.none(sql.misc.jsonObjectSetKeys),
|
||||||
t.none(sql.array.add),
|
t.none(sql.array.add),
|
||||||
|
|||||||
Reference in New Issue
Block a user