From aa59ce71f5cede1e6cf685bde2878a1869604eb8 Mon Sep 17 00:00:00 2001 From: Pranav C <61551451+pranavxc@users.noreply.github.com> Date: Wed, 5 Oct 2022 21:30:54 +0530 Subject: [PATCH] fix(api): set default scale and precision --- packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts | 78 +++++++++++++------ .../code/models/xc/ModelXcMetaOracle.ts | 7 ++ 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts b/packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts index 51dc2c994e..71723daf5a 100644 --- a/packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts +++ b/packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts @@ -7,28 +7,22 @@ const dbTypes = [ 'CHAR', 'VARCHAR', 'VARCHAR2', - 'NUMBER', - 'INTEGER', 'SHORTINTEGER', 'LONGINTEGER', 'DECIMAL', 'SHORTDECIMAL', - 'NCHAR', 'NVARCHAR2', 'CLOB', 'NCLOB', 'BINARY_FLOAT', 'BINARY_DOUBLE', - 'DATE', - 'TIMESTAMP', 'TIMESTAMP WITH LOCAL TIME ZONE', 'TIMESTAMP WITH TIME ZONE', - 'BLOB', 'CLOB', 'NCLOB', @@ -116,6 +110,25 @@ export class OracleUi { static getDefaultLengthForDatatype(type) { switch (type) { + case 'NUMBER': + case 'INTEGER': + case 'LONGINTEGER': + return 11; + + case 'DECIMAL': + return 10; + + case 'SHORTDECIMAL': + return 5; + + case 'CHAR': + return 255; + + case 'VARCHAR': + case 'VARCHAR2': + return 255; + case 'NCHAR': + return 255; default: return ''; } @@ -124,11 +137,17 @@ export class OracleUi { static getDefaultLengthIsDisabled(type): any { switch (type) { case 'NUMBER': + case 'INTEGER': + case 'LONGINTEGER': + case 'DECIMAL': + case 'SHORTDECIMAL': + case 'CHAR': case 'VARCHAR': case 'VARCHAR2': - return true; - default: + case 'NCHAR': return false; + default: + return true; } } @@ -141,17 +160,17 @@ export class OracleUi { static getDefaultScaleForDatatype(type): any { switch (type) { - case 'VARCHAR2': - case 'VARCHAR': - case 'NVARCHAR2': - case 'NCHAR': - return 45; + case 'DECIMAL': + case 'SHORTDECIMAL': + return 2; + default: + return ''; } } static colPropAIDisabled(col, columns) { // console.log(col); - if (col.dt === 'NUMBER') { + if (['INTEGER', 'SHORTINTEGER', 'LONGINTEGER'].includes(col.dt)) { for (let i = 0; i < columns.length; ++i) { if (columns[i].cn !== col.cn && columns[i].ai) { return true; @@ -169,13 +188,19 @@ export class OracleUi { static onCheckboxChangeAI(col) { console.log(col); - if (col.dt === 'NUMBER') { + if (['INTEGER', 'SHORTINTEGER', 'LONGINTEGER'].includes(col.dt)) { col.altered = col.altered || 2; } } - static showScale(_columnObj) { - return false; + static showScale(columnObj) { + return ( + columnObj.dt === 'DECIMAL' || + columnObj.dt === 'NUMBER' || + columnObj.dt === 'BINARY_FLOAT' || + columnObj.dt === 'BINARY_DOUBLE' || + columnObj.dt === 'SHORTDECIMAL' + ); } static removeUnsigned(columns) { @@ -463,8 +488,6 @@ export class OracleUi { return 'datetime'; case 'BLOB': - case 'CLOB': - case 'NCLOB': case 'BFILE': return 'blob'; @@ -634,7 +657,7 @@ export class OracleUi { colProp.dt = 'NUMBER'; break; case 'Barcode': - colProp.dt = 'varchar'; + colProp.dt = 'VARCHAR2'; break; case 'Button': colProp.dt = 'VARCHAR2'; @@ -652,7 +675,7 @@ export class OracleUi { if (idType === 'AG') { return ['VARCHAR2', 'VARCHAR', 'NCHAR', 'NVARCHAR2']; } else if (idType === 'AI') { - return ['NUMBER']; + return ['NUMBER', 'INTEGER', 'SHORTINTEGER', 'LONGINTEGER']; } else { return dbTypes; } @@ -692,7 +715,7 @@ export class OracleUi { 'NCLOB', ]; case 'Checkbox': - return ['NUMBER']; + return ['NUMBER', 'INTEGER', 'SHORTINTEGER', 'LONGINTEGER']; case 'MultiSelect': case 'SingleSelect': @@ -728,7 +751,14 @@ export class OracleUi { ]; case 'Number': - return ['INTEGER', 'SHORTINTEGER', 'LONGINTEGER', 'NUMBER']; + return [ + 'INTEGER', + 'SHORTINTEGER', + 'LONGINTEGER', + 'NUMBER', + 'BINARY_FLOAT', + 'BINARY_DOUBLE', + ]; case 'Decimal': return ['DECIMAL', 'SHORTDECIMAL', 'NUMBER']; @@ -742,7 +772,7 @@ export class OracleUi { return ['NUMBER']; case 'Rating': - return ['NUMBER']; + return ['NUMBER', 'SHORTINTEGER', 'LONGINTEGER', 'NUMBER']; case 'Count': return ['NUMBER']; diff --git a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts index c5abdcb7f3..5ffa983e42 100644 --- a/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts +++ b/packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts @@ -280,7 +280,14 @@ class ModelXcMetaOracle extends BaseModelXcMeta { case 'NUMBER': case 'BINARY_FLOAT': case 'BINARY_DOUBLE': + case 'DECIMAL': + case 'SHORTDECIMAL': return 'float'; + + case 'INTEGER': + case 'SHORTINTEGER': + case 'LONGINTEGER': + return 'integer'; case 'CLOB': case 'NCLOB': return 'text';