Skip to content

Conversation

@schliepa
Copy link
Contributor

Slight edit to the example shown for the database.createTagStore API. Showing the get query with a string instead of a number to demonstrate correct usage of the template literals in combination with string expressions.

Reason for this change:

Because strings in SQL queries are usually enclosed in quotation marks:

"SELECT * FROM users WHERE name = 'Alice'"

Users may be tempted to enclose them in quotation marks in the template literals used for the SQLTagStore API:

const user = sql.get`SELECT * FROM users WHERE name = '${name}'`;

This would lead to a incorrect SQL query (which might actually fail quietly). The correct form is to leave the quotation marks out:

const user = sql.get`SELECT * FROM users WHERE name = ${name}`;

If a users attempts to escape strings with quotes in SQLTagStore
template strings (`'${expression}'`), as is usually required for 
SQL query strings, the queries would fail. This change shows an 
example on the correct use (`${expression}`).
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/sqlite

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. sqlite Issues and PRs related to the SQLite subsystem. labels Nov 27, 2025
Copy link
Member

@Renegade334 Renegade334 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDSWN.

@aduh95 aduh95 added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Nov 30, 2025
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 30, 2025
@nodejs-github-bot nodejs-github-bot merged commit d0c1024 into nodejs:main Nov 30, 2025
32 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in d0c1024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no pending requests for changes, and a CI started. doc Issues and PRs related to the documentations. sqlite Issues and PRs related to the SQLite subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants