tidy
This commit is contained in:
parent
165d5b7325
commit
537c92b371
5 changed files with 23 additions and 24 deletions
|
@ -436,10 +436,9 @@ class InternalBuilder {
|
||||||
[value]
|
[value]
|
||||||
)
|
)
|
||||||
} else if (SqlClient.ORACLE) {
|
} else if (SqlClient.ORACLE) {
|
||||||
query = query[fnc](
|
query = query[fnc](`${quotedIdentifier(this.client, key)} = ?`, [
|
||||||
`${quotedIdentifier(this.client, key)} = ?`,
|
value,
|
||||||
[value]
|
])
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
query = query[fnc](
|
query = query[fnc](
|
||||||
`COALESCE(${quotedIdentifier(this.client, key)} = ?, FALSE)`,
|
`COALESCE(${quotedIdentifier(this.client, key)} = ?, FALSE)`,
|
||||||
|
|
|
@ -153,9 +153,9 @@ export function isValidTime(value: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sqlLog(client: string, query: string, values?: any[]) {
|
export function sqlLog(client: string, query: string, values?: any[]) {
|
||||||
// if (!environment.SQL_LOGGING_ENABLE) {
|
if (!environment.SQL_LOGGING_ENABLE) {
|
||||||
// return
|
return
|
||||||
// }
|
}
|
||||||
let string = `[SQL] [${client.toUpperCase()}] query="${query}"`
|
let string = `[SQL] [${client.toUpperCase()}] query="${query}"`
|
||||||
if (values) {
|
if (values) {
|
||||||
string += ` values="${values.join(", ")}"`
|
string += ` values="${values.join(", ")}"`
|
||||||
|
|
|
@ -24,7 +24,7 @@ import {
|
||||||
getSqlQuery,
|
getSqlQuery,
|
||||||
HOST_ADDRESS,
|
HOST_ADDRESS,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
import {
|
import oracledb, {
|
||||||
BindParameters,
|
BindParameters,
|
||||||
Connection,
|
Connection,
|
||||||
ConnectionAttributes,
|
ConnectionAttributes,
|
||||||
|
@ -33,13 +33,11 @@ import {
|
||||||
} from "oracledb"
|
} from "oracledb"
|
||||||
import { OracleTable, OracleColumn, OracleColumnsResponse } from "./base/types"
|
import { OracleTable, OracleColumn, OracleColumnsResponse } from "./base/types"
|
||||||
import { sql } from "@budibase/backend-core"
|
import { sql } from "@budibase/backend-core"
|
||||||
import oracledb from "oracledb"
|
|
||||||
|
|
||||||
const Sql = sql.Sql
|
const Sql = sql.Sql
|
||||||
|
|
||||||
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
|
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
|
||||||
|
|
||||||
|
|
||||||
interface OracleConfig {
|
interface OracleConfig {
|
||||||
host: string
|
host: string
|
||||||
port: number
|
port: number
|
||||||
|
|
|
@ -39,8 +39,8 @@ function generateReadJson({
|
||||||
filters,
|
filters,
|
||||||
sort,
|
sort,
|
||||||
paginate,
|
paginate,
|
||||||
}: any = {}): QueryJson {
|
}: any = {}): QueryJson {
|
||||||
const tableObj = {...TABLE}
|
const tableObj = { ...TABLE }
|
||||||
if (table) {
|
if (table) {
|
||||||
tableObj.name = table
|
tableObj.name = table
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ function generateRelationshipJson(config: { schema?: string } = {}): QueryJson {
|
||||||
column: "products",
|
column: "products",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
extra: {idFilter: {}},
|
extra: { idFilter: {} },
|
||||||
meta: {
|
meta: {
|
||||||
table: TABLE,
|
table: TABLE,
|
||||||
},
|
},
|
||||||
|
@ -122,7 +122,7 @@ function generateManyRelationshipJson(config: { schema?: string } = {}) {
|
||||||
toPrimary: "product_id",
|
toPrimary: "product_id",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
extra: {idFilter: {}},
|
extra: { idFilter: {} },
|
||||||
meta: {
|
meta: {
|
||||||
table: TABLE,
|
table: TABLE,
|
||||||
},
|
},
|
||||||
|
@ -139,7 +139,7 @@ describe("SQL query builder", () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should add the schema to the LEFT JOIN", () => {
|
it("should add the schema to the LEFT JOIN", () => {
|
||||||
const query = sql._query(generateRelationshipJson({schema: "production"}))
|
const query = sql._query(generateRelationshipJson({ schema: "production" }))
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: [500, 5000],
|
bindings: [500, 5000],
|
||||||
sql: `select "brands"."brand_id" as "brands.brand_id",
|
sql: `select "brands"."brand_id" as "brands.brand_id",
|
||||||
|
@ -170,7 +170,7 @@ describe("SQL query builder", () => {
|
||||||
|
|
||||||
it("should add the schema to both the toTable and throughTable in many-to-many join", () => {
|
it("should add the schema to both the toTable and throughTable in many-to-many join", () => {
|
||||||
const query = sql._query(
|
const query = sql._query(
|
||||||
generateManyRelationshipJson({schema: "production"})
|
generateManyRelationshipJson({ schema: "production" })
|
||||||
)
|
)
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: [500, 5000],
|
bindings: [500, 5000],
|
||||||
|
@ -260,7 +260,8 @@ describe("SQL query builder", () => {
|
||||||
name: "John",
|
name: "John",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
|
|
||||||
expect(query).not.toEqual({
|
expect(query).not.toEqual({
|
||||||
bindings: ["John", limit, 5000],
|
bindings: ["John", limit, 5000],
|
||||||
|
@ -276,7 +277,8 @@ describe("SQL query builder", () => {
|
||||||
name: "John",
|
name: "John",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}))
|
})
|
||||||
|
)
|
||||||
|
|
||||||
expect(query).toEqual({
|
expect(query).toEqual({
|
||||||
bindings: ["John", limit, 5000],
|
bindings: ["John", limit, 5000],
|
||||||
|
|
Loading…
Reference in a new issue