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 5de7820d74..5162315678 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 @@ -1558,6 +1558,8 @@ class BaseModelSqlv2 { let response; // const driver = trx ? trx : this.dbDriver; + this.processInsertObject(insertObj); + const query = this.dbDriver(this.tnPath).insert(insertObj); if ((this.isPg || this.isMssql) && this.model.primaryKey) { query.returning( @@ -1623,6 +1625,24 @@ class BaseModelSqlv2 { } } + private processInsertObject(insertObj: Record) { + // if oracle use `TO_DATE` function to parse date STRING + if (this.isOracle) { + for (const col of this.model.columns) { + if ( + col.dt === 'DATE' && + col.uidt === UITypes.Date && + insertObj[col.column_name] + ) { + insertObj[col.column_name] = this.dbDriver.raw( + `TO_DATE('${insertObj[col.column_name]}','YYYY-MM-DD')` + ); + } + } + } + // todo: do the same for datetime & time + } + async delByPk(id, trx?, cookie?) { try { // retrieve data for handling paramas in hook