Browse Source

fix(api): set default scale and precision

feat/oracle-support
Pranav C 2 years ago committed by Pranav C
parent
commit
aa59ce71f5
  1. 78
      packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts
  2. 7
      packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts

78
packages/nocodb-sdk/src/lib/sqlUi/OracleUi.ts

@ -7,28 +7,22 @@ const dbTypes = [
'CHAR', 'CHAR',
'VARCHAR', 'VARCHAR',
'VARCHAR2', 'VARCHAR2',
'NUMBER', 'NUMBER',
'INTEGER', 'INTEGER',
'SHORTINTEGER', 'SHORTINTEGER',
'LONGINTEGER', 'LONGINTEGER',
'DECIMAL', 'DECIMAL',
'SHORTDECIMAL', 'SHORTDECIMAL',
'NCHAR', 'NCHAR',
'NVARCHAR2', 'NVARCHAR2',
'CLOB', 'CLOB',
'NCLOB', 'NCLOB',
'BINARY_FLOAT', 'BINARY_FLOAT',
'BINARY_DOUBLE', 'BINARY_DOUBLE',
'DATE', 'DATE',
'TIMESTAMP', 'TIMESTAMP',
'TIMESTAMP WITH LOCAL TIME ZONE', 'TIMESTAMP WITH LOCAL TIME ZONE',
'TIMESTAMP WITH TIME ZONE', 'TIMESTAMP WITH TIME ZONE',
'BLOB', 'BLOB',
'CLOB', 'CLOB',
'NCLOB', 'NCLOB',
@ -116,6 +110,25 @@ export class OracleUi {
static getDefaultLengthForDatatype(type) { static getDefaultLengthForDatatype(type) {
switch (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: default:
return ''; return '';
} }
@ -124,11 +137,17 @@ export class OracleUi {
static getDefaultLengthIsDisabled(type): any { static getDefaultLengthIsDisabled(type): any {
switch (type) { switch (type) {
case 'NUMBER': case 'NUMBER':
case 'INTEGER':
case 'LONGINTEGER':
case 'DECIMAL':
case 'SHORTDECIMAL':
case 'CHAR':
case 'VARCHAR': case 'VARCHAR':
case 'VARCHAR2': case 'VARCHAR2':
return true; case 'NCHAR':
default:
return false; return false;
default:
return true;
} }
} }
@ -141,17 +160,17 @@ export class OracleUi {
static getDefaultScaleForDatatype(type): any { static getDefaultScaleForDatatype(type): any {
switch (type) { switch (type) {
case 'VARCHAR2': case 'DECIMAL':
case 'VARCHAR': case 'SHORTDECIMAL':
case 'NVARCHAR2': return 2;
case 'NCHAR': default:
return 45; return '';
} }
} }
static colPropAIDisabled(col, columns) { static colPropAIDisabled(col, columns) {
// console.log(col); // console.log(col);
if (col.dt === 'NUMBER') { if (['INTEGER', 'SHORTINTEGER', 'LONGINTEGER'].includes(col.dt)) {
for (let i = 0; i < columns.length; ++i) { for (let i = 0; i < columns.length; ++i) {
if (columns[i].cn !== col.cn && columns[i].ai) { if (columns[i].cn !== col.cn && columns[i].ai) {
return true; return true;
@ -169,13 +188,19 @@ export class OracleUi {
static onCheckboxChangeAI(col) { static onCheckboxChangeAI(col) {
console.log(col); console.log(col);
if (col.dt === 'NUMBER') { if (['INTEGER', 'SHORTINTEGER', 'LONGINTEGER'].includes(col.dt)) {
col.altered = col.altered || 2; col.altered = col.altered || 2;
} }
} }
static showScale(_columnObj) { static showScale(columnObj) {
return false; return (
columnObj.dt === 'DECIMAL' ||
columnObj.dt === 'NUMBER' ||
columnObj.dt === 'BINARY_FLOAT' ||
columnObj.dt === 'BINARY_DOUBLE' ||
columnObj.dt === 'SHORTDECIMAL'
);
} }
static removeUnsigned(columns) { static removeUnsigned(columns) {
@ -463,8 +488,6 @@ export class OracleUi {
return 'datetime'; return 'datetime';
case 'BLOB': case 'BLOB':
case 'CLOB':
case 'NCLOB':
case 'BFILE': case 'BFILE':
return 'blob'; return 'blob';
@ -634,7 +657,7 @@ export class OracleUi {
colProp.dt = 'NUMBER'; colProp.dt = 'NUMBER';
break; break;
case 'Barcode': case 'Barcode':
colProp.dt = 'varchar'; colProp.dt = 'VARCHAR2';
break; break;
case 'Button': case 'Button':
colProp.dt = 'VARCHAR2'; colProp.dt = 'VARCHAR2';
@ -652,7 +675,7 @@ export class OracleUi {
if (idType === 'AG') { if (idType === 'AG') {
return ['VARCHAR2', 'VARCHAR', 'NCHAR', 'NVARCHAR2']; return ['VARCHAR2', 'VARCHAR', 'NCHAR', 'NVARCHAR2'];
} else if (idType === 'AI') { } else if (idType === 'AI') {
return ['NUMBER']; return ['NUMBER', 'INTEGER', 'SHORTINTEGER', 'LONGINTEGER'];
} else { } else {
return dbTypes; return dbTypes;
} }
@ -692,7 +715,7 @@ export class OracleUi {
'NCLOB', 'NCLOB',
]; ];
case 'Checkbox': case 'Checkbox':
return ['NUMBER']; return ['NUMBER', 'INTEGER', 'SHORTINTEGER', 'LONGINTEGER'];
case 'MultiSelect': case 'MultiSelect':
case 'SingleSelect': case 'SingleSelect':
@ -728,7 +751,14 @@ export class OracleUi {
]; ];
case 'Number': case 'Number':
return ['INTEGER', 'SHORTINTEGER', 'LONGINTEGER', 'NUMBER']; return [
'INTEGER',
'SHORTINTEGER',
'LONGINTEGER',
'NUMBER',
'BINARY_FLOAT',
'BINARY_DOUBLE',
];
case 'Decimal': case 'Decimal':
return ['DECIMAL', 'SHORTDECIMAL', 'NUMBER']; return ['DECIMAL', 'SHORTDECIMAL', 'NUMBER'];
@ -742,7 +772,7 @@ export class OracleUi {
return ['NUMBER']; return ['NUMBER'];
case 'Rating': case 'Rating':
return ['NUMBER']; return ['NUMBER', 'SHORTINTEGER', 'LONGINTEGER', 'NUMBER'];
case 'Count': case 'Count':
return ['NUMBER']; return ['NUMBER'];

7
packages/nocodb/src/lib/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts

@ -280,7 +280,14 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
case 'NUMBER': case 'NUMBER':
case 'BINARY_FLOAT': case 'BINARY_FLOAT':
case 'BINARY_DOUBLE': case 'BINARY_DOUBLE':
case 'DECIMAL':
case 'SHORTDECIMAL':
return 'float'; return 'float';
case 'INTEGER':
case 'SHORTINTEGER':
case 'LONGINTEGER':
return 'integer';
case 'CLOB': case 'CLOB':
case 'NCLOB': case 'NCLOB':
return 'text'; return 'text';

Loading…
Cancel
Save