This commit is contained in:
Martin McKeaveney 2024-07-22 21:23:27 +01:00
parent 165d5b7325
commit 537c92b371
5 changed files with 23 additions and 24 deletions

View File

@ -436,10 +436,9 @@ class InternalBuilder {
[value]
)
} else if (SqlClient.ORACLE) {
query = query[fnc](
`${quotedIdentifier(this.client, key)} = ?`,
[value]
)
query = query[fnc](`${quotedIdentifier(this.client, key)} = ?`, [
value,
])
} else {
query = query[fnc](
`COALESCE(${quotedIdentifier(this.client, key)} = ?, FALSE)`,

View File

@ -153,9 +153,9 @@ export function isValidTime(value: string) {
}
export function sqlLog(client: string, query: string, values?: any[]) {
// if (!environment.SQL_LOGGING_ENABLE) {
// return
// }
if (!environment.SQL_LOGGING_ENABLE) {
return
}
let string = `[SQL] [${client.toUpperCase()}] query="${query}"`
if (values) {
string += ` values="${values.join(", ")}"`

View File

@ -16,4 +16,4 @@ services:
- oracle_data:/opt/oracle/oradata
volumes:
oracle_data:
oracle_data:

View File

@ -24,7 +24,7 @@ import {
getSqlQuery,
HOST_ADDRESS,
} from "./utils"
import {
import oracledb, {
BindParameters,
Connection,
ConnectionAttributes,
@ -33,13 +33,11 @@ import {
} from "oracledb"
import { OracleTable, OracleColumn, OracleColumnsResponse } from "./base/types"
import { sql } from "@budibase/backend-core"
import oracledb from "oracledb"
const Sql = sql.Sql
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT
interface OracleConfig {
host: string
port: number

View File

@ -34,13 +34,13 @@ function endpoint(table: any, operation: any) {
}
function generateReadJson({
table,
fields,
filters,
sort,
paginate,
}: any = {}): QueryJson {
const tableObj = {...TABLE}
table,
fields,
filters,
sort,
paginate,
}: any = {}): QueryJson {
const tableObj = { ...TABLE }
if (table) {
tableObj.name = table
}
@ -85,7 +85,7 @@ function generateRelationshipJson(config: { schema?: string } = {}): QueryJson {
column: "products",
},
],
extra: {idFilter: {}},
extra: { idFilter: {} },
meta: {
table: TABLE,
},
@ -122,7 +122,7 @@ function generateManyRelationshipJson(config: { schema?: string } = {}) {
toPrimary: "product_id",
},
],
extra: {idFilter: {}},
extra: { idFilter: {} },
meta: {
table: TABLE,
},
@ -139,7 +139,7 @@ describe("SQL query builder", () => {
})
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({
bindings: [500, 5000],
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", () => {
const query = sql._query(
generateManyRelationshipJson({schema: "production"})
generateManyRelationshipJson({ schema: "production" })
)
expect(query).toEqual({
bindings: [500, 5000],
@ -260,7 +260,8 @@ describe("SQL query builder", () => {
name: "John",
},
},
}))
})
)
expect(query).not.toEqual({
bindings: ["John", limit, 5000],
@ -276,7 +277,8 @@ describe("SQL query builder", () => {
name: "John",
},
},
}))
})
)
expect(query).toEqual({
bindings: ["John", limit, 5000],