Use global sql type map, update base integration type defs
This commit is contained in:
parent
85ef7838af
commit
2edb24fa86
|
@ -1,6 +1,6 @@
|
||||||
export interface IntegrationBase {
|
export interface IntegrationBase {
|
||||||
create?(query: any): Promise<[any]>
|
create?(query: any): Promise<any[]>
|
||||||
read?(query: any): Promise<[any]>
|
read?(query: any): Promise<any[]>
|
||||||
update?(query: any): Promise<[any]>
|
update?(query: any): Promise<any[]>
|
||||||
delete?(query: any): Promise<[any]>
|
delete?(query: any): Promise<any[]>
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
finaliseExternalTables,
|
finaliseExternalTables,
|
||||||
getSqlQuery,
|
getSqlQuery,
|
||||||
buildExternalTableId,
|
buildExternalTableId,
|
||||||
convertType,
|
convertSqlType,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import oracledb, {
|
import oracledb, {
|
||||||
ExecuteOptions,
|
ExecuteOptions,
|
||||||
|
@ -82,15 +82,6 @@ module OracleModule {
|
||||||
|
|
||||||
const UNSUPPORTED_TYPES = ["BLOB", "CLOB", "NCLOB"]
|
const UNSUPPORTED_TYPES = ["BLOB", "CLOB", "NCLOB"]
|
||||||
|
|
||||||
const TYPE_MAP = {
|
|
||||||
long: FieldTypes.LONGFORM,
|
|
||||||
number: FieldTypes.NUMBER,
|
|
||||||
binary_float: FieldTypes.NUMBER,
|
|
||||||
binary_double: FieldTypes.NUMBER,
|
|
||||||
timestamp: FieldTypes.DATETIME,
|
|
||||||
date: FieldTypes.DATETIME,
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Raw query response
|
* Raw query response
|
||||||
*/
|
*/
|
||||||
|
@ -292,7 +283,7 @@ module OracleModule {
|
||||||
return FieldTypes.BOOLEAN
|
return FieldTypes.BOOLEAN
|
||||||
}
|
}
|
||||||
|
|
||||||
return convertType(column.type, TYPE_MAP)
|
return convertSqlType(column.type)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -393,26 +384,26 @@ module OracleModule {
|
||||||
return oracledb.getConnection(attributes)
|
return oracledb.getConnection(attributes)
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(query: SqlQuery | string) {
|
async create(query: SqlQuery | string): Promise<any[]> {
|
||||||
const response = await this.internalQuery(getSqlQuery(query))
|
const response = await this.internalQuery<any>(getSqlQuery(query))
|
||||||
return response.rows && response.rows.length
|
return response.rows && response.rows.length
|
||||||
? response.rows
|
? response.rows
|
||||||
: [{ created: true }]
|
: [{ created: true }]
|
||||||
}
|
}
|
||||||
|
|
||||||
async read(query: SqlQuery | string) {
|
async read(query: SqlQuery | string): Promise<any[]> {
|
||||||
const response = await this.internalQuery(getSqlQuery(query))
|
const response = await this.internalQuery<any>(getSqlQuery(query))
|
||||||
return response.rows
|
return response.rows ? response.rows : []
|
||||||
}
|
}
|
||||||
|
|
||||||
async update(query: SqlQuery | string) {
|
async update(query: SqlQuery | string): Promise<any[]> {
|
||||||
const response = await this.internalQuery(getSqlQuery(query))
|
const response = await this.internalQuery(getSqlQuery(query))
|
||||||
return response.rows && response.rows.length
|
return response.rows && response.rows.length
|
||||||
? response.rows
|
? response.rows
|
||||||
: [{ updated: true }]
|
: [{ updated: true }]
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(query: SqlQuery | string) {
|
async delete(query: SqlQuery | string): Promise<any[]> {
|
||||||
const response = await this.internalQuery(getSqlQuery(query))
|
const response = await this.internalQuery(getSqlQuery(query))
|
||||||
return response.rows && response.rows.length
|
return response.rows && response.rows.length
|
||||||
? response.rows
|
? response.rows
|
||||||
|
|
|
@ -32,6 +32,10 @@ const SQL_TYPE_MAP = {
|
||||||
fixed: FieldTypes.NUMBER,
|
fixed: FieldTypes.NUMBER,
|
||||||
datetime: FieldTypes.DATETIME,
|
datetime: FieldTypes.DATETIME,
|
||||||
tinyint: FieldTypes.BOOLEAN,
|
tinyint: FieldTypes.BOOLEAN,
|
||||||
|
long: FieldTypes.LONGFORM,
|
||||||
|
number: FieldTypes.NUMBER,
|
||||||
|
binary_float: FieldTypes.NUMBER,
|
||||||
|
binary_double: FieldTypes.NUMBER,
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum SqlClients {
|
export enum SqlClients {
|
||||||
|
|
Loading…
Reference in New Issue