Skip to content

Commit 6c440af

Browse files
schliepaaduh95
authored andcommitted
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é <contact.9a5d6388@renegade334.me.uk> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 280d567 commit 6c440af

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
@@ -540,8 +540,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`;
540540
sql.run`INSERT INTO users VALUES (2, 'Bob')`;
541541

542542
// Using the 'get' method to retrieve a single row.
543-
const id = 1;
544-
const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
543+
const name = 'Alice';
544+
const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
545545
console.log(user); // { id: 1, name: 'Alice' }
546546

547547
// Using the 'all' method to retrieve all rows.
@@ -567,8 +567,8 @@ sql.run`INSERT INTO users VALUES (1, 'Alice')`;
567567
sql.run`INSERT INTO users VALUES (2, 'Bob')`;
568568

569569
// Using the 'get' method to retrieve a single row.
570-
const id = 1;
571-
const user = sql.get`SELECT * FROM users WHERE id = ${id}`;
570+
const name = 'Alice';
571+
const user = sql.get`SELECT * FROM users WHERE name = ${name}`;
572572
console.log(user); // { id: 1, name: 'Alice' }
573573

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

0 commit comments

Comments
 (0)