From c6ec710abebbb71f6489e76ab48ba337cf348259 Mon Sep 17 00:00:00 2001 From: Sam Rose Date: Tue, 30 Jul 2024 16:03:03 +0100 Subject: [PATCH] Solve _some_ date problems. --- packages/backend-core/src/sql/sql.ts | 2 +- .../src/api/routes/tests/search.spec.ts | 22 +++++++++---------- packages/server/src/integrations/oracle.ts | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/backend-core/src/sql/sql.ts b/packages/backend-core/src/sql/sql.ts index df70ea6fea..a06af6e318 100644 --- a/packages/backend-core/src/sql/sql.ts +++ b/packages/backend-core/src/sql/sql.ts @@ -237,7 +237,7 @@ class InternalBuilder { return `${hours}:${minutes}:${seconds}` } if (typeof input === "string") { - return new Date(`1970-01-01 ${input}`) + return new Date(`1970-01-01T${input}Z`) } } diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 32e4735f3a..e2df279603 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -40,14 +40,14 @@ import { structures } from "@budibase/backend-core/tests" import { DEFAULT_EMPLOYEE_TABLE_SCHEMA } from "../../../db/defaultData/datasource_bb_default" describe.each([ - ["in-memory", undefined], - ["lucene", undefined], - ["sqs", undefined], - [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], - [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], - [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], - [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], - // [DatabaseName.ORACLE, getDatasource(DatabaseName.ORACLE)], + // ["in-memory", undefined], + // ["lucene", undefined], + // ["sqs", undefined], + // [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], + // [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], + // [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], + // [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], + [DatabaseName.ORACLE, getDatasource(DatabaseName.ORACLE)], ])("search (%s)", (name, dsProvider) => { const isSqs = name === "sqs" const isLucene = name === "lucene" @@ -2389,9 +2389,9 @@ describe.each([ describe.each([ { low: "2024-07-03T00:00:00.000Z", high: "9999-00-00T00:00:00.000Z" }, - // { low: "2024-07-03T00:00:00.000Z", high: "9998-00-00T00:00:00.000Z" }, - // { low: "0000-00-00T00:00:00.000Z", high: "2024-07-04T00:00:00.000Z" }, - // { low: "0001-00-00T00:00:00.000Z", high: "2024-07-04T00:00:00.000Z" }, + { low: "2024-07-03T00:00:00.000Z", high: "9998-00-00T00:00:00.000Z" }, + { low: "0000-00-00T00:00:00.000Z", high: "2024-07-04T00:00:00.000Z" }, + { low: "0001-00-00T00:00:00.000Z", high: "2024-07-04T00:00:00.000Z" }, ])("date special cases", ({ low, high }) => { const earlyDate = "2024-07-03T10:00:00.000Z", laterDate = "2024-07-03T11:00:00.000Z" diff --git a/packages/server/src/integrations/oracle.ts b/packages/server/src/integrations/oracle.ts index b8fcd63e7f..a9ce05302c 100644 --- a/packages/server/src/integrations/oracle.ts +++ b/packages/server/src/integrations/oracle.ts @@ -406,7 +406,9 @@ class OracleIntegration extends Sql implements DatasourcePlus { password: this.config.password, connectString, } - return oracledb.getConnection(attributes) + const connection = await oracledb.getConnection(attributes) + await connection.execute(`ALTER SESSION SET TIME_ZONE='UTC'`) + return connection } async create(query: SqlQuery | string): Promise {