From f001af1e04e72cc340793921459a14cce2e564d7 Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Tue, 4 Oct 2022 17:44:26 +0530 Subject: [PATCH] fix(api): oracledb - identify identity column and mark it as autoincrement --- .../nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts | 3 ++- .../src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts b/packages/nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts index 98f55eb64e..7db5dcf0a4 100644 --- a/packages/nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts +++ b/packages/nocodb/src/lib/db/sql-client/lib/oracle/OracleClient.ts @@ -483,7 +483,8 @@ class OracleClient extends KnexClient { seq.sequence_name, CASE WHEN seq.sequence_name IS NOT NULL - AND p.constraint_type = 'P' THEN 1 + AND p.constraint_type = 'P' THEN 1 + WHEN c.IDENTITY_COLUMN = 'YES' THEN 1 ELSE 0 END as ai, c.table_name as tn, diff --git a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts index 5ac240bc74..3532e43572 100644 --- a/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts +++ b/packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts @@ -1607,9 +1607,7 @@ class BaseModelSqlv2 { if (this.isSqlite || this.isOracle) { // sqlite doesnt return id after insert id = ( - await this.dbDriver(this.tnPath) - .select(ai.column_name) - .max(ai.column_name, { as: 'id' }) + await this.dbDriver(this.tnPath).max(ai.column_name, { as: 'id' }) )[0].id; } else if (this.isSnowflake) { id = (