Test fix.

This commit is contained in:
mike12345567 2024-09-11 14:26:01 +01:00
parent db074c0d22
commit fc3a865cfb
1 changed files with 17 additions and 16 deletions

View File

@ -60,7 +60,7 @@ describe("Captures of real examples", () => {
queryJson queryJson
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [relationshipLimit, relationshipLimit, primaryLimit], bindings: [primaryLimit, relationshipLimit, relationshipLimit],
sql: expect.stringContaining( sql: expect.stringContaining(
multiline( multiline(
`select json_agg(json_build_object('executorid',"b"."executorid",'taskname',"b"."taskname",'taskid',"b"."taskid",'completed',"b"."completed",'qaid',"b"."qaid",'executorid',"b"."executorid",'taskname',"b"."taskname",'taskid',"b"."taskid",'completed',"b"."completed",'qaid',"b"."qaid")` `select json_agg(json_build_object('executorid',"b"."executorid",'taskname',"b"."taskname",'taskid',"b"."taskid",'completed',"b"."completed",'qaid',"b"."qaid",'executorid',"b"."executorid",'taskname',"b"."taskname",'taskid',"b"."taskid",'completed',"b"."completed",'qaid',"b"."qaid")`
@ -75,11 +75,11 @@ describe("Captures of real examples", () => {
queryJson queryJson
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [relationshipLimit, "assembling", primaryLimit], bindings: ["assembling", primaryLimit, relationshipLimit],
sql: expect.stringContaining( sql: expect.stringContaining(
multiline( multiline(
`where exists (select 1 from "tasks" as "b" inner join "products_tasks" as "c" on "b"."taskid" = "c"."taskid" `where exists (select 1 from "tasks" as "b" inner join "products_tasks" as "c" on "b"."taskid" = "c"."taskid" where "c"."productid" = "a"."productid"
where "c"."productid" = "a"."productid" and COALESCE("b"."taskname" = $2, FALSE)` and COALESCE("b"."taskname" = $1, FALSE)`
) )
), ),
}) })
@ -91,12 +91,13 @@ describe("Captures of real examples", () => {
queryJson queryJson
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [relationshipLimit, primaryLimit], bindings: [primaryLimit, relationshipLimit],
sql: expect.stringContaining( sql: expect.stringContaining(
multiline( multiline(
`select json_agg(json_build_object('executorid',"b"."executorid",'taskname',"b"."taskname",'taskid',"b"."taskid",'completed',"b"."completed",'qaid',"b"."qaid")) `with "paginated" as (select "a".* from "products" as "a" order by "a"."productname" asc nulls first, "a"."productid" asc limit $1)
from (select "b".* from "tasks" as "b" inner join "products_tasks" as "c" on "b"."taskid" = "c"."taskid" select "a".*, (select json_agg(json_build_object('executorid',"b"."executorid",'taskname',"b"."taskname",'taskid',"b"."taskid",'completed',"b"."completed",'qaid',"b"."qaid"))
where "c"."productid" = "a"."productid" order by "b"."taskid" asc limit $1` from (select "b".* from "tasks" as "b" inner join "products_tasks" as "c" on "b"."taskid" = "c"."taskid" where "c"."productid" = "a"."productid" order by "b"."taskid" asc limit $2) as "b") as "tasks"
from "paginated" as "a" order by "a"."productname" asc nulls first, "a"."productid" asc`
) )
), ),
}) })
@ -109,12 +110,12 @@ describe("Captures of real examples", () => {
queryJson queryJson
) )
expect(query).toEqual({ expect(query).toEqual({
bindings: [relationshipLimit, ...filters, relationshipLimit], bindings: [...filters, relationshipLimit, relationshipLimit],
sql: multiline( sql: multiline(
`select "a".*, (select json_agg(json_build_object('productname',"b"."productname",'productid',"b"."productid")) `with "paginated" as (select "a".* from "tasks" as "a" where "a"."taskid" in ($1, $2) order by "a"."taskid" asc limit $3)
select "a".*, (select json_agg(json_build_object('productname',"b"."productname",'productid',"b"."productid"))
from (select "b".* from "products" as "b" inner join "products_tasks" as "c" on "b"."productid" = "c"."productid" from (select "b".* from "products" as "b" inner join "products_tasks" as "c" on "b"."productid" = "c"."productid"
where "c"."taskid" = "a"."taskid" order by "b"."productid" asc limit $1) as "b") as "products" where "c"."taskid" = "a"."taskid" order by "b"."productid" asc limit $4) as "b") as "products" from "paginated" as "a" order by "a"."taskid" asc`
from "tasks" as "a" where "a"."taskid" in ($2, $3) order by "a"."taskid" asc limit $4`
), ),
}) })
}) })
@ -132,18 +133,18 @@ describe("Captures of real examples", () => {
expect(query).toEqual({ expect(query).toEqual({
bindings: [ bindings: [
relationshipLimit,
relationshipLimit,
relationshipLimit,
rangeValue.low, rangeValue.low,
rangeValue.high, rangeValue.high,
equalValue, equalValue,
notEqualsValue, notEqualsValue,
primaryLimit, primaryLimit,
relationshipLimit,
relationshipLimit,
relationshipLimit,
], ],
sql: expect.stringContaining( sql: expect.stringContaining(
multiline( multiline(
`where exists (select 1 from "persons" as "c" where "c"."personid" = "a"."executorid" and "c"."year" between $4 and $5)` `where exists (select 1 from "persons" as "c" where "c"."personid" = "a"."executorid" and "c"."year" between $1 and $2)`
) )
), ),
}) })