brianc/node-sql

Conditional INSERT with parameterization

Opened this issue · 0 comments

How might I pull off something like this? I have something similar to this "working" in a hacky way but the values passed to select function are not parameterized and are not wrapped with quotes.

Input:

{
  colName: 'foo',
  colName2: 'bar'
}
INSERT INTO tableName (col_name, col_name2)
SELECT $1, $2
WHERE EXISTS (SUB_QUERY_HERE)