brianc / node-sql

SQL generation for node.js
MIT License
1.05k stars 191 forks source link

Conditional INSERT with parameterization #390

Open marshallford opened 6 years ago

marshallford commented 6 years ago

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)