Closed gyhyfj closed 6 months ago
@gyhyfj please use staticParameters while using template literals in sql queries.
TLDR; fix like this:
const tableName = 'bilibili_like'
const { rows } = await db.sql`SELECT * FROM {${tableName}}`
Explanation: when you use template literals, db0 automatically converts them to prepared statements and tableNames are not allowed to be part of prepared statements.
Detailed Discussion: #77
This issue can be closed now. Documentation initiative is being tracked in #77
Environment
node 20.12.1 nitropack 2.9.6 better-sqlite3 9.6.0
Reproduction
The following code works well without template string:
The following code throws error without template string:
Error:
Describe the bug
sql
method throw error with template stringAdditional context
No response
Logs
No response