diff --git a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js index eef88d63..0e194752 100644 --- a/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js +++ b/src/Adapters/Storage/Postgres/PostgresStorageAdapter.js @@ -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 ($, $, 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 ($, $, 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;