Fix PG fails (#2957)
* Better support for arrays of objects * No transaction in class creation
This commit is contained in:
@@ -410,11 +410,8 @@ export class PostgresStorageAdapter {
|
||||
}
|
||||
|
||||
createClass(className, schema) {
|
||||
return this._client.tx(t => {
|
||||
const q1 = this.createTable(className, schema);
|
||||
const q2 = this._client.none('INSERT INTO "_SCHEMA" ("className", "schema", "isParseClass") VALUES ($<className>, $<schema>, true)', { className, schema });
|
||||
|
||||
return t.batch([q1, q2]);
|
||||
return this.createTable(className, schema).then(() => {
|
||||
return this._client.none('INSERT INTO "_SCHEMA" ("className", "schema", "isParseClass") VALUES ($<className>, $<schema>, true)', { className, schema });
|
||||
})
|
||||
.then(() => {
|
||||
return toParseSchema(schema)
|
||||
@@ -895,7 +892,14 @@ export class PostgresStorageAdapter {
|
||||
if (expectedType === 'text[]') {
|
||||
updatePatterns.push(`$${index}:name = $${index + 1}::text[]`);
|
||||
} else {
|
||||
updatePatterns.push(`$${index}:name = array_to_json($${index + 1}::text[])::jsonb`);
|
||||
let type = 'text';
|
||||
for (let elt of fieldValue) {
|
||||
if (typeof elt == 'object') {
|
||||
type = 'json';
|
||||
break;
|
||||
}
|
||||
}
|
||||
updatePatterns.push(`$${index}:name = array_to_json($${index + 1}::${type}[])::jsonb`);
|
||||
}
|
||||
values.push(fieldName, fieldValue);
|
||||
index += 2;
|
||||
|
||||
Reference in New Issue
Block a user