Skip to content

Support parameter binding in db.query() #18

@findolor

Description

@findolor
  • Add parameter binding support to db.query(sql, params) so callers can pass replacements for ?/?1 placeholders when
    executing SQL.
  • Currently only raw SQL strings are supported; developers must manually interpolate values, which is error-prone and
    insecure (risk of SQL injection, data formatting issues).
  • Accept arrays as the second argument (e.g., await db.query('INSERT ... VALUES (?1)', ['not_a_number'])) and bind them
    in order to the positional placeholders.
  • Preserve existing behavior when no params are provided; reject mismatched counts (extra placeholders or params) with
    clear errors.
  • Update documentation/examples to show the new overload; add tests covering simple insert/update queries and type
    conversion edge cases.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions