leafo/pgmoon

Empty db.array will not error, but generate invalid SQL

turbo opened this issue · 2 comments

turbo commented

For postgres, an empty table passed to db.array will generate syntactically invalid SQL:

(shortened)

model\create tags: DB.array data.topics or {}

yields

INSERT INTO "projects" (<...>, "tags", <...>) VALUES (<...>, ], <...>) RETURNING "id"

This fails because it is rejected by PG.

leafo commented

there's a separate ticket about this. essentially it's broken because there's no good solution I'm aware of: #37

There's no syntax to make an empty array that works for any type.

I suppose it's time to make it throw an error instead?

turbo commented

FWIW, I'd prefer for it to throw an error.