Closed
Description
Postgres supports camel cased column and table names - but only when you quote your table/column names. Same for column names which use reserved words - they also need to be quoted.
sql`SELECT * from ${sql('tableName')} where ${sql({firstName: 'John'})}`
This generates the sql query SELECT * from tableName where firstName = $1
Which will fail if you used camelCased names while creating the table
SELECT * from "tableName" where "firstName" = $1
would be the expected query.
Not that important, but also related and unexpected is that dollar quoted names become quoted
sql`SELECT * from ${sql('$$table_name$$')} where ${sql({firstName: 'John'})}`
This generates the sql query SELECT * from "$$table_name$$" where firstName = $1
Which will fail as $$
are already quotes
SELECT * from $$table_name$$ where "firstName" = $1
would be the expected query.
Metadata
Metadata
Assignees
Labels
No labels