diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index 327f7955cb..aacfe7f02a 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -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)`, diff --git a/packages/backend-core/src/sql/utils.ts b/packages/backend-core/src/sql/utils.ts index 71959b5661..67b5d2081b 100644 --- a/packages/backend-core/src/sql/utils.ts +++ b/packages/backend-core/src/sql/utils.ts @@ -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(", ")}"` diff --git a/packages/server/scripts/integrations/oracle/docker-compose.yml b/packages/server/scripts/integrations/oracle/docker-compose.yml index 2fe6c2f574..586f0b683d 100644 --- a/packages/server/scripts/integrations/oracle/docker-compose.yml +++ b/packages/server/scripts/integrations/oracle/docker-compose.yml @@ -16,4 +16,4 @@ services: - oracle_data:/opt/oracle/oradata volumes: - oracle_data: \ No newline at end of file + oracle_data: \ No newline at end of file diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index 9d0d1ea204..9f40372546 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -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 diff --git a/packages/server/src/integrations/tests/sql.spec.ts b/packages/server/src/integrations/tests/sql.spec.ts index a408836da0..19177fb041 100644 --- a/packages/server/src/integrations/tests/sql.spec.ts +++ b/packages/server/src/integrations/tests/sql.spec.ts @@ -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],