Skip to content

Commit d0c1024

Browse files
authored
doc: show the use of string expressions in the SQLTagStore example
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}`). PR-URL: #60873 Reviewed-By: René <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 6274eb7 commit d0c1024

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/api/sqlite.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`;
550550
sql.run`INSERT INTO users VALUES (2, 'Bob')`;
551551

552552
// Using the 'get' method to retrieve a single row.
553-
const id = 1;
554-
const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
553+
const name = 'Alice';
554+
const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
555555
console.log(user); // { id: 1, name: 'Alice' }
556556

557557
// Using the 'all' method to retrieve all rows.
@@ -577,8 +577,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`;
577577
sql.run`INSERT INTO users VALUES (2, 'Bob')`;
578578

579579
// Using the 'get' method to retrieve a single row.
580-
const id = 1;
581-
const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
580+
const name = 'Alice';
581+
const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
582582
console.log(user); // { id: 1, name: 'Alice' }
583583

584584
// Using the 'all' method to retrieve all rows.

0 commit comments

Comments
 (0)