Closed
Description
The following breaks because order
is a reserved POSTGRES keyword.
const some_table_data = [
{ order: 1, transition: 'up' },
{ order: 2, transition: 'down' }
]
const results = sql`INSERT INTO some_table ${sql(some_table_data, 'order', 'transition')}`
This problem is similar to #21 in that the column order
needs quotes to work.
Writing this SQL raw, should look something like this:
INSERT INTO some_table ("order",transition) values ($1,$2),($3,$4);
(Notice the quotes around "order"
.
Instead, this library generates the following:
INSERT INTO some_table (order,transition) values ($1,$2),($3,$4);
Which throws a SQL syntax error.
I can't figure out a workaround other than to use sql.unsafe
, which I'm forced to use to move forward, but I don't want that permanently. Any ideas?
Metadata
Metadata
Assignees
Labels
No labels