Skip to content

Commit

Permalink
fix: correctly handle multiple-row insert for SAP HANA driver (#7957)
Browse files Browse the repository at this point in the history
the SAP HANA SQL dialect does not support inserts with multiple values
but it does support `INSERT ... SELECT` as well as a `SELECT ... FROM dummy`

with that in mind, the `InsertQueryBuilder` has been modified to support
this dialect similar to how we do for Oracle
  • Loading branch information
imnotjames committed Feb 16, 2022
1 parent f24822e commit 8f2ae71
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/query-builder/InsertQueryBuilder.ts
Expand Up @@ -484,6 +484,8 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
if (columnIndex === 0) {
if (this.connection.driver instanceof OracleDriver && valueSets.length > 1) {
expression += " SELECT ";
} else if (this.connection.driver instanceof SapDriver && valueSets.length > 1) {
expression += " SELECT ";
} else {
expression += "(";
}
Expand Down Expand Up @@ -597,12 +599,16 @@ export class InsertQueryBuilder<Entity> extends QueryBuilder<Entity> {
if (valueSetIndex === valueSets.length - 1) {
if (this.connection.driver instanceof OracleDriver && valueSets.length > 1) {
expression += " FROM DUAL ";
} else if (this.connection.driver instanceof SapDriver && valueSets.length > 1) {
expression += " FROM dummy ";
} else {
expression += ")";
}
} else {
if (this.connection.driver instanceof OracleDriver && valueSets.length > 1) {
expression += " FROM DUAL UNION ALL ";
} else if (this.connection.driver instanceof SapDriver && valueSets.length > 1) {
expression += " FROM dummy UNION ALL ";
} else {
expression += "), ";
}
Expand Down

0 comments on commit 8f2ae71

Please sign in to comment.