Skip to content

postgresl array queries can error on ^3.3.0 #651

@sanny-io

Description

@sanny-io

The test suite for ZenStack LIVE compares its results by running an actual query against a database and seeing if it matches the expected result. I've upgraded to ^3.3.0 and some tests now fail that previously passed.

All of the errors look like they're related to arrays, and they appear similar to this:

Failed to execute query: error: operator does not exist: real[] @> double precision[]

Here's a sample query

client.user.exists({
    where: {
        floatArray: {
            equals: [1.1, 2.2, 3.3],
        },
    },
})

Here's the generated SQL

select exists (select 1 as "$t" from "User" where "User"."floatArray" = cast(ARRAY[$1,$2,$3] as double precision[])) as "exists"

Here's a reproduction (run the Vitest suite)

https://github.com/visualbravo/zenstack-live/tree/incorrect-sql

Here's where the tests were passing before updating to ^3.3.0

https://github.com/visualbravo/zenstack-live/actions/runs/21591495912/job/62212519618

I placed a try/catch in the discriminator test suite on line 75 to aid in debugging.

https://github.com/visualbravo/zenstack-live/blob/incorrect-sql/packages/live/tests/discriminator.test.ts#L75

It looks like there's some sort of casting issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions