expand mysql2 querying section with parameterized queries#3127
Open
lunadogbot wants to merge 2 commits into
Open
expand mysql2 querying section with parameterized queries#3127lunadogbot wants to merge 2 commits into
lunadogbot wants to merge 2 commits into
Conversation
Contributor
Author
|
@bartlomieju ready for review when you have a moment. |
fibibot
approved these changes
May 14, 2026
Contributor
fibibot
left a comment
There was a problem hiding this comment.
mysql2/promise's .query() resolves to [rows, fields], so the old single-binding version was printing the tuple and the output's closing ] got eaten — [rows] destructure fixes it. .execute() with ? placeholders is the right swap; mysql2 does send these as real COM_STMT_PREPARE/COM_STMT_EXECUTE and caches the prepare on repeats, so the prose is accurate.
last_modified is bumped; the new "Abels lizard" output matches the INSERT two sections up (no apostrophe in the row, no stray " like the old output had).
Contributor
|
@bartlomieju this is ready to merge |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Restructures the "Querying MySQL" section of
examples/tutorials/mysql2.md. Theold section had two problems: the first SELECT did not destructure the
[rows, fields]tuple, so the printed output started with an outer[thatwrapped both rows and fields and was then truncated mid-array; and the
single-row example used
WHERE \name` = 'Deno'` — a string-interpolationpattern that teaches readers exactly the antipattern that ships SQL injection
bugs.
The new section keeps the same flow but uses
[rows]destructuring in thefirst example (with a closed, accurate output block) and replaces the
single-row example with a
connection.execute()call that uses a?placeholder, plus a short prose note explaining why parameterized queries are
mandatory for any user-supplied value. The "Common pitfalls" / "what about
INSERT/UPDATE/DELETE" angle is covered in one paragraph rather than a wall of
prose.
Verified end-to-end against a MySQL 8 container using the same version pin the
page imports (
npm:mysql2@^2.3.3/promise) underdenoland/deno:latest(2.7.14). Both code blocks were run as written and the output blocks reflect
what the driver actually returns.
Closes bartlomieju/orchid-inbox#46