sqb-connect-oracledb
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "sqb-connect-oracledb", | ||
"description": "SQB Connection plugin for Oracle database using 'oracledb' library", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"author": "Panates Ltd.", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -14,3 +14,3 @@ /* SQB-connect-oracledb | ||
/* External module dependencies. */ | ||
const {Connection} = require('sqb'); | ||
const {Connection, TableMetaData} = require('sqb'); | ||
const assert = require('assert'); | ||
@@ -116,16 +116,17 @@ //noinspection SpellCheckingInspection,NpmUsedModulesInstalled | ||
if (response.metaData) { | ||
metaData = {}; | ||
response.metaData.forEach((item, idx) => { | ||
const o = metaData[item.name] = {index: idx}; | ||
metaData = new TableMetaData(); | ||
response.metaData.forEach((v, idx) => { | ||
const o = {name: v.name}; | ||
// fetchType | ||
let a = fetchTypeMap[item.fetchType]; | ||
let a = fetchTypeMap[v.fetchType]; | ||
if (a) o.jsType = a; | ||
a = dbTypeMap[item.dbType]; | ||
a = dbTypeMap[v.dbType]; | ||
// dbType | ||
if (a) o.dbType = a; | ||
if (item.byteSize) o.byteSize = item.byteSize; | ||
if (!item.nullable) o.required = true; | ||
if (item.precision) o.precision = item.precision; | ||
if (item.precision > 0) o.precision = item.precision; | ||
else item.dbType = 'FLOAT'; | ||
if (v.byteSize) o.size = v.byteSize; | ||
if (v.nullable) o.nullable = v.nullable; | ||
if (v.precision) o.precision = v.precision; | ||
if (v.precision > 0) o.precision = v.precision; | ||
else v.dbType = 'FLOAT'; | ||
metaData.add(o); | ||
}); | ||
@@ -132,0 +133,0 @@ } |
@@ -95,7 +95,6 @@ /* SQB | ||
.orderBy('owner', 'table_name', 'column_id') | ||
.onFetchRow((row, idx) => { | ||
.onFetchRow((row, idx, meta) => { | ||
let dataType = meta.getValue('data_type', row); | ||
/* Map oracle data types to generic data types */ | ||
let dataType = row.DATA_TYPE; | ||
if (dataType) { | ||
row.ORG_DATA_TYPE = dataType; | ||
switch (dataType) { | ||
@@ -131,7 +130,6 @@ case 'NCHAR': | ||
} | ||
row.DATA_TYPE = dataType; | ||
meta.setValue('data_type', dataType, row); | ||
} | ||
if (row.NULLABLE !== null) { | ||
row.NULLABLE = row.NULLABLE === 'Y'; | ||
} | ||
if (row.NULLABLE !== null) | ||
meta.setValue('nullable', (row.NULLABLE === 'Y'), row); | ||
}); | ||
@@ -149,3 +147,3 @@ } | ||
'ac.constraint_name', 'ac.status', | ||
sqb.raw('to_char(listagg(acc.column_name) within group (order by null)) columns')) | ||
sqb.raw('to_char(listagg(acc.column_name, \',\') within group (order by null)) columns')) | ||
.from('all_constraints ac') | ||
@@ -172,6 +170,6 @@ .join( | ||
'ac.constraint_name', 'ac.status', | ||
sqb.raw('to_char(listagg(acc.column_name) within group (order by null)) column_name'), | ||
sqb.raw('to_char(listagg(ac.r_owner) within group (order by null)) r_schema'), | ||
sqb.raw('to_char(listagg(acr.table_name) within group (order by null)) r_table_name'), | ||
sqb.raw('to_char(listagg(acr.column_name) within group (order by null)) r_columns') | ||
sqb.raw('to_char(listagg(acc.column_name, \',\') within group (order by null)) column_name'), | ||
sqb.raw('to_char(listagg(ac.r_owner, \',\') within group (order by null)) r_schema'), | ||
sqb.raw('to_char(listagg(acr.table_name, \',\') within group (order by null)) r_table_name'), | ||
sqb.raw('to_char(listagg(acr.column_name, \',\') within group (order by null)) r_columns') | ||
) | ||
@@ -178,0 +176,0 @@ .from('all_constraints ac') |
19278
538