pg: syntax error at or near $1 for select distinct on

I have a postgres database, and I have a select distinct on query I am generating with drizzle code.

It used to work just fine, but sometime in the last couple of months it just stopped working and started throwing errors. I haven't changed my dependency versions for drizzle or related libraries.. maybe something changed underneath the drizzle-orm deps? I am stumped

await db.selectDistinctOn([DB.stopTimes.stopId, DB.routes.id, DB.trips.directionId, select3.distance]) ...


which generates the following sql sent to the pg server:
select distinct on ("stop_times"."stop_id"$1"routes"."route_id"$2"trips"."direction_id"$3"distance") ...

there are 10 total args in this query, but the first 3 are:
', ' ', ' ', ' (so, three {comma followed by a space} which i assume is to properly separate the column ids in the distinct on clause)

but it throws an error with the message: syntax error at or near $1

any ideas??
Was this page helpful?