From 8fbb978cca683b18f6579ab53444960cf7f0620c Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 23 Jul 2024 11:20:14 +0100 Subject: [PATCH] fix tests --- .../server/src/integrations/tests/sql.spec.ts | 55 ++----------------- 1 file changed, 6 insertions(+), 49 deletions(-) diff --git a/packages/server/src/integrations/tests/sql.spec.ts b/packages/server/src/integrations/tests/sql.spec.ts index 278c5dd1ec..7379c25b74 100644 --- a/packages/server/src/integrations/tests/sql.spec.ts +++ b/packages/server/src/integrations/tests/sql.spec.ts @@ -142,14 +142,7 @@ describe("SQL query builder", () => { const query = sql._query(generateRelationshipJson({ schema: "production" })) expect(query).toEqual({ bindings: [500, 5000], - sql: `select "brands"."brand_id" as "brands.brand_id", - "brands"."brand_name" as "brands.brand_name", - "products"."product_id" as "products.product_id", - "products"."product_name" as "products.product_name", - "products"."brand_id" as "products.brand_id" - from (select * from "production"."brands" order by "test"."id" asc limit $1) as "brands" - left join "production"."products" as "products" on "brands"."brand_id" = "products"."brand_id" - order by "test"."id" asc limit $2`, + sql: `select "brands"."brand_id" as "brands.brand_id", "brands"."brand_name" as "brands.brand_name", "products"."product_id" as "products.product_id", "products"."product_name" as "products.product_name", "products"."brand_id" as "products.brand_id" from (select * from "production"."brands" order by "test"."id" asc limit $1) as "brands" left join "production"."products" as "products" on "brands"."brand_id" = "products"."brand_id" order by "test"."id" asc limit $2`, }) }) @@ -157,14 +150,7 @@ describe("SQL query builder", () => { const query = sql._query(generateRelationshipJson()) expect(query).toEqual({ bindings: [500, 5000], - sql: `select "brands"."brand_id" as "brands.brand_id", - "brands"."brand_name" as "brands.brand_name", - "products"."product_id" as "products.product_id", - "products"."product_name" as "products.product_name", - "products"."brand_id" as "products.brand_id" - from (select * from "brands" order by "test"."id" asc limit $1) as "brands" - left join "products" as "products" on "brands"."brand_id" = "products"."brand_id" - order by "test"."id" asc limit $2`, + sql: `select "brands"."brand_id" as "brands.brand_id", "brands"."brand_name" as "brands.brand_name", "products"."product_id" as "products.product_id", "products"."product_name" as "products.product_name", "products"."brand_id" as "products.brand_id" from (select * from "brands" order by "test"."id" asc limit $1) as "brands" left join "products" as "products" on "brands"."brand_id" = "products"."brand_id" order by "test"."id" asc limit $2`, }) }) @@ -174,14 +160,7 @@ describe("SQL query builder", () => { ) expect(query).toEqual({ bindings: [500, 5000], - sql: `select "stores"."store_id" as "stores.store_id", - "stores"."store_name" as "stores.store_name", - "products"."product_id" as "products.product_id", - "products"."product_name" as "products.product_name" - from (select * from "production"."stores" order by "test"."id" asc limit $1) as "stores" - left join "production"."stocks" as "stocks" on "stores"."store_id" = "stocks"."store_id" - left join "production"."products" as "products" on "products"."product_id" = "stocks"."product_id" - order by "test"."id" asc limit $2`, + sql: `select "stores"."store_id" as "stores.store_id", "stores"."store_name" as "stores.store_name", "products"."product_id" as "products.product_id", "products"."product_name" as "products.product_name" from (select * from "production"."stores" order by "test"."id" asc limit $1) as "stores" left join "production"."stocks" as "stocks" on "stores"."store_id" = "stocks"."store_id" left join "production"."products" as "products" on "products"."product_id" = "stocks"."product_id" order by "test"."id" asc limit $2`, }) }) @@ -197,13 +176,7 @@ describe("SQL query builder", () => { ) expect(query).toEqual({ bindings: ["john%", limit, 5000], - sql: `select * - from (select * - from (select * - from (select * from "test" where LOWER("test"."name") LIKE :1 order by "test"."id" asc) - where rownum <= :2) "test" - order by "test"."id" asc) - where rownum <= :3`, + sql: `select * from (select * from (select * from (select * from "test" where LOWER("test"."name") LIKE :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`, }) query = new Sql(SqlClient.ORACLE, limit)._query( @@ -218,17 +191,7 @@ describe("SQL query builder", () => { ) expect(query).toEqual({ bindings: ["%20%", "%25%", `%"john"%`, `%"mary"%`, limit, 5000], - sql: `select * - from (select * - from (select * - from (select * - from "test" - where (COALESCE(LOWER("test"."age"), '') LIKE :1 AND COALESCE(LOWER("test"."age"), '') LIKE :2) - and (COALESCE(LOWER("test"."name"), '') LIKE :3 AND COALESCE(LOWER("test"."name"), '') LIKE :4) - order by "test"."id" asc) - where rownum <= :5) "test" - order by "test"."id" asc) - where rownum <= :6`, + sql: `select * from (select * from (select * from (select * from "test" where (COALESCE(LOWER("test"."age"), '') LIKE :1 AND COALESCE(LOWER("test"."age"), '') LIKE :2) and (COALESCE(LOWER("test"."name"), '') LIKE :3 AND COALESCE(LOWER("test"."name"), '') LIKE :4) order by "test"."id" asc) where rownum <= :5) "test" order by "test"."id" asc) where rownum <= :6`, }) query = new Sql(SqlClient.ORACLE, limit)._query( @@ -242,13 +205,7 @@ describe("SQL query builder", () => { ) expect(query).toEqual({ bindings: [`%jo%`, limit, 5000], - sql: `select * - from (select * - from (select * - from (select * from "test" where LOWER("test"."name") LIKE :1 order by "test"."id" asc) - where rownum <= :2) "test" - order by "test"."id" asc) - where rownum <= :3`, + sql: `select * from (select * from (select * from (select * from "test" where LOWER("test"."name") LIKE :1 order by "test"."id" asc) where rownum <= :2) "test" order by "test"."id" asc) where rownum <= :3`, }) })