-
Notifications
You must be signed in to change notification settings - Fork 176
Closed
Labels
bugSomething isn’t workingSomething isn’t working
Description
This code ends up running SELECT DISTINCT columnName FROM my_table
(it interpolates the name of the variable into the SQL):
const columnName = 'my_column'
const rows = await sql`SELECT DISTINCT ${columnName} FROM my_table`
// runs SELECT DISTINCT columnName FROM my_table
I expected it to run SELECT DISTINCT my_column FROM table
(interpolate the value of columnName into the SQL). Variable interpolation seems to work this way in fenced sql blocks, and the following code also works:
const columnName = 'my_column'
const rows = await sql(['SELECT DISTINCT ' + columnName + ' FROM my_table'])
// runs SELECT DISTINCT my_column FROM my_table
but this, again, does not
const columnName = 'my_column'
const rows = await sql(['SELECT DISTINCT ', ' FROM my_table'], columnName)
// runs SELECT DISTINCT columnName FROM my_table
Metadata
Metadata
Assignees
Labels
bugSomething isn’t workingSomething isn’t working