You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to create a VIEW whose definition depends on one or more dynamic JavaScript values. To avoid potential SQL injection problems, I would like these dynamic values to be interpolated into the query as parameters (using ?) rather than escaping the SQL manually.
I therefore tried the following query (using the DuckDBClient wrapper of the DuckDB-Wasm library):
CREATE OR REPLACEVIEWtop_daysASSELECT*FROM aapl
ORDER BY Volume DESCLIMIT ${limit}
However this fails with the following error:
Binder Error: Unexpected prepared parameter. This type of statement can't be prepared!
If a CREATE VIEW statement cannot be prepared, and the normal connection.query method (for non-prepared statements) does not support parameters, is there any way to pass query parameters safely? It seems that I am required to escape manually.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I want to create a VIEW whose definition depends on one or more dynamic JavaScript values. To avoid potential SQL injection problems, I would like these dynamic values to be interpolated into the query as parameters (using
?
) rather than escaping the SQL manually.I therefore tried the following query (using the
DuckDBClient
wrapper of the DuckDB-Wasm library):However this fails with the following error:
If a
CREATE VIEW
statement cannot be prepared, and the normal connection.query method (for non-prepared statements) does not support parameters, is there any way to pass query parameters safely? It seems that I am required to escape manually.Beta Was this translation helpful? Give feedback.
All reactions