porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.04k stars 257 forks source link

Unexpected token JSON #800

Open molotow11 opened 5 months ago

molotow11 commented 5 months ago

Hi, Guys!

I have an issue with query like this:

        SELECT i.*, 
          array_agg(m.name) as motifs,
          array_agg(m.global_art_style) as global_art_style,
          array_agg(m.styles) as styles 
        FROM public."Location" as i
          LEFT JOIN public."Motif" AS m ON m.location = i.id
          WHERE 1=1
        GROUP BY i.id
        ORDER BY id ASC

Inside array_agg fields I have text with possible NULL values, it is fine in PgAdmin and I see just NULL values, but with your library the query is failed with error: Unexpected token N in JSON at position 0

intelocate-admin commented 4 months ago

Same issue when array_agg is used on JSON column with null value.

intelocate-admin commented 4 months ago

Another probably not related issue, bool[] paramaters do not work.

await sqlSELECT ${[true, false]}::bool[];

PostgresError: cannot cast type boolean to boolean[]