Browse Source

fix: mssql & pg knex binding logic

pull/2424/head
Wing-Kam Wong 2 years ago
parent
commit
3e27b3b088
  1. 14
      packages/nocodb/package-lock.json
  2. 2
      packages/nocodb/package.json
  3. 10
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

14
packages/nocodb/package-lock.json generated

@ -70,7 +70,7 @@
"mysql2": "^2.2.5",
"nanoid": "^3.1.20",
"nc-common": "0.0.6",
"nc-help": "0.2.65",
"nc-help": "0.2.67",
"nc-lib-gui": "0.91.10",
"nc-plugin": "0.1.2",
"ncp": "^2.0.0",
@ -16352,9 +16352,9 @@
}
},
"node_modules/nc-help": {
"version": "0.2.65",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.65.tgz",
"integrity": "sha512-Sia+ZhfrCCFu70khjVCUMJ7B8xYlSyfatKt7WERDzqiykC7rOGFxfyhKPfhDzep+X1CDT3R+psd4lTi4d52wdg==",
"version": "0.2.67",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.67.tgz",
"integrity": "sha512-O9eXHrpO0dBdFv6zUZAos+63JZEGhZ2lG+MduGZ+/BL7M5b0qU7d9b95Pmgq6Gd5wO3txT/7x7uPBHZxeSgvHQ==",
"dependencies": {
"@rudderstack/rudder-sdk-node": "^1.1.3",
"axios": "^0.21.1",
@ -38040,9 +38040,9 @@
"integrity": "sha512-3AryS9uwa5NfISLxMciUonrH7YfXp+nlahB9T7girXIsLQrmwX4MdnuKs32akduCOGpKmjTJSWmATULbuMkbfw=="
},
"nc-help": {
"version": "0.2.65",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.65.tgz",
"integrity": "sha512-Sia+ZhfrCCFu70khjVCUMJ7B8xYlSyfatKt7WERDzqiykC7rOGFxfyhKPfhDzep+X1CDT3R+psd4lTi4d52wdg==",
"version": "0.2.67",
"resolved": "https://registry.npmjs.org/nc-help/-/nc-help-0.2.67.tgz",
"integrity": "sha512-O9eXHrpO0dBdFv6zUZAos+63JZEGhZ2lG+MduGZ+/BL7M5b0qU7d9b95Pmgq6Gd5wO3txT/7x7uPBHZxeSgvHQ==",
"requires": {
"@rudderstack/rudder-sdk-node": "^1.1.3",
"axios": "^0.21.1",

2
packages/nocodb/package.json

@ -154,7 +154,7 @@
"mysql2": "^2.2.5",
"nanoid": "^3.1.20",
"nc-common": "0.0.6",
"nc-help": "0.2.65",
"nc-help": "0.2.67",
"nc-lib-gui": "0.91.10",
"nc-plugin": "0.1.2",
"ncp": "^2.0.0",

10
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -1259,12 +1259,11 @@ class BaseModelSqlv2 {
// const driver = trx ? trx : this.dbDriver;
const query = this.dbDriver(this.tnPath).insert(insertObj);
if (this.isPg || this.isMssql) {
query.returning(
`${this.model.primaryKey.column_name} as ${this.model.primaryKey.title}`
);
response = await query;
response = await this.extractRawQueryAndExec(query);
}
const ai = this.model.columns.find(c => c.ai);
@ -2035,7 +2034,12 @@ class BaseModelSqlv2 {
}
private async extractRawQueryAndExec(qb: QueryBuilder) {
const query = unsanitize(qb.toQuery());
let query = qb.toQuery();
if (!this.isPg && !this.isMssql) {
query = unsanitize(qb.toQuery());
} else {
query = sanitize(query);
}
return this.isPg
? (await this.dbDriver.raw(query))?.rows
: query.slice(0, 6) === 'select'

Loading…
Cancel
Save