porsager / postgres

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

Dynamic updates with table aliases #974

Open willruggiano opened 3 weeks ago

willruggiano commented 3 weeks ago
await sql`
  UPDATE foo AS f
  SET ${sql({ bar: sql`now()` }, ["bar"])}
`;

expected;

update foo as f
set bar = now()

actual:

update foo as f
set now() as "bar"

Removing the alias does the trick.