diff --git a/src/driver/DriverUtils.ts b/src/driver/DriverUtils.ts index 31c8bd47c3..d60b982053 100644 --- a/src/driver/DriverUtils.ts +++ b/src/driver/DriverUtils.ts @@ -32,6 +32,10 @@ export class DriverUtils { return ["mysql", "mariadb"].includes(driver.options.type) } + static isPostgresFamily(driver: Driver): boolean { + return ["postgres", "aurora-postgres"].includes(driver.options.type) + } + /** * Normalizes and builds a new driver options. * Extracts settings from connection url and sets to a new options object. diff --git a/src/query-builder/InsertQueryBuilder.ts b/src/query-builder/InsertQueryBuilder.ts index 1aa5545de9..044105b32d 100644 --- a/src/query-builder/InsertQueryBuilder.ts +++ b/src/query-builder/InsertQueryBuilder.ts @@ -412,7 +412,7 @@ export class InsertQueryBuilder extends QueryBuilder { if ( this.alias !== this.getMainTableName() && - this.connection.driver.options.type === "postgres" + DriverUtils.isPostgresFamily(this.connection.driver) ) { query += ` AS "${this.alias}"` } @@ -507,7 +507,7 @@ export class InsertQueryBuilder extends QueryBuilder { if ( Array.isArray(overwrite) && skipUpdateIfNoValuesChanged && - this.connection.driver.options.type === "postgres" + DriverUtils.isPostgresFamily(this.connection.driver) ) { query += ` WHERE (` query += overwrite @@ -560,7 +560,7 @@ export class InsertQueryBuilder extends QueryBuilder { // add RETURNING expression if ( returningExpression && - (this.connection.driver.options.type === "postgres" || + (DriverUtils.isPostgresFamily(this.connection.driver) || this.connection.driver.options.type === "oracle" || this.connection.driver.options.type === "cockroachdb" || DriverUtils.isMySQLFamily(this.connection.driver)) @@ -829,8 +829,9 @@ export class InsertQueryBuilder extends QueryBuilder { expression += `${geomFromText}(${paramName})` } } else if ( - this.connection.driver.options.type === - "postgres" && + DriverUtils.isPostgresFamily( + this.connection.driver, + ) && this.connection.driver.spatialTypes.indexOf( column.type, ) !== -1