Skip to content

Commit

Permalink
fix: .save repository method not returning generated uuids for auro…
Browse files Browse the repository at this point in the history
…ra-postgres (#8825)

* fix: fixed .save repository method not returning generated uuids for aurora driver

* fix(aurora-postgres): fixed .save repository method not returning generated uuids for aurora driver
  • Loading branch information
ArsenyYankovsky committed Mar 30, 2022
1 parent c5dfc11 commit ed06f4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/driver/DriverUtils.ts
Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions src/query-builder/InsertQueryBuilder.ts
Expand Up @@ -412,7 +412,7 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {

if (
this.alias !== this.getMainTableName() &&
this.connection.driver.options.type === "postgres"
DriverUtils.isPostgresFamily(this.connection.driver)
) {
query += ` AS "${this.alias}"`
}
Expand Down Expand Up @@ -507,7 +507,7 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
if (
Array.isArray(overwrite) &&
skipUpdateIfNoValuesChanged &&
this.connection.driver.options.type === "postgres"
DriverUtils.isPostgresFamily(this.connection.driver)
) {
query += ` WHERE (`
query += overwrite
Expand Down Expand Up @@ -560,7 +560,7 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
// 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))
Expand Down Expand Up @@ -829,8 +829,9 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
expression += `${geomFromText}(${paramName})`
}
} else if (
this.connection.driver.options.type ===
"postgres" &&
DriverUtils.isPostgresFamily(
this.connection.driver,
) &&
this.connection.driver.spatialTypes.indexOf(
column.type,
) !== -1
Expand Down

0 comments on commit ed06f4c

Please sign in to comment.