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 {
|
||||
create?(query: any): Promise<[any]>
|
||||
read?(query: any): Promise<[any]>
|
||||
update?(query: any): Promise<[any]>
|
||||
delete?(query: any): Promise<[any]>
|
||||
create?(query: any): Promise<any[]>
|
||||
read?(query: any): Promise<any[]>
|
||||
update?(query: any): Promise<any[]>
|
||||
delete?(query: any): Promise<any[]>
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import {
|
|||
finaliseExternalTables,
|
||||
getSqlQuery,
|
||||
buildExternalTableId,
|
||||
convertType,
|
||||
convertSqlType,
|
||||
} from "./utils"
|
||||
import oracledb, {
|
||||
ExecuteOptions,
|
||||
|
@ -82,15 +82,6 @@ module OracleModule {
|
|||
|
||||
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
|
||||
*/
|
||||
|
@ -292,7 +283,7 @@ module OracleModule {
|
|||
return FieldTypes.BOOLEAN
|
||||
}
|
||||
|
||||
return convertType(column.type, TYPE_MAP)
|
||||
return convertSqlType(column.type)
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,26 +384,26 @@ module OracleModule {
|
|||
return oracledb.getConnection(attributes)
|
||||
}
|
||||
|
||||
async create(query: SqlQuery | string) {
|
||||
const response = await this.internalQuery(getSqlQuery(query))
|
||||
async create(query: SqlQuery | string): Promise<any[]> {
|
||||
const response = await this.internalQuery<any>(getSqlQuery(query))
|
||||
return response.rows && response.rows.length
|
||||
? response.rows
|
||||
: [{ created: true }]
|
||||
}
|
||||
|
||||
async read(query: SqlQuery | string) {
|
||||
const response = await this.internalQuery(getSqlQuery(query))
|
||||
return response.rows
|
||||
async read(query: SqlQuery | string): Promise<any[]> {
|
||||
const response = await this.internalQuery<any>(getSqlQuery(query))
|
||||
return response.rows ? response.rows : []
|
||||
}
|
||||
|
||||
async update(query: SqlQuery | string) {
|
||||
async update(query: SqlQuery | string): Promise<any[]> {
|
||||
const response = await this.internalQuery(getSqlQuery(query))
|
||||
return response.rows && response.rows.length
|
||||
? response.rows
|
||||
: [{ updated: true }]
|
||||
}
|
||||
|
||||
async delete(query: SqlQuery | string) {
|
||||
async delete(query: SqlQuery | string): Promise<any[]> {
|
||||
const response = await this.internalQuery(getSqlQuery(query))
|
||||
return response.rows && response.rows.length
|
||||
? response.rows
|
||||
|
|
|
@ -32,6 +32,10 @@ const SQL_TYPE_MAP = {
|
|||
fixed: FieldTypes.NUMBER,
|
||||
datetime: FieldTypes.DATETIME,
|
||||
tinyint: FieldTypes.BOOLEAN,
|
||||
long: FieldTypes.LONGFORM,
|
||||
number: FieldTypes.NUMBER,
|
||||
binary_float: FieldTypes.NUMBER,
|
||||
binary_double: FieldTypes.NUMBER,
|
||||
}
|
||||
|
||||
export enum SqlClients {
|
||||
|
|
Loading…
Reference in New Issue