Repository navigation
Query: substitute bound values in a single pass - #10
Merged
Merged
Conversation
Values were substituted one after another over the whole query, through fixed marker strings. Text inside one value could therefore be taken for the marker of another. All markers are now swapped for their values in one strtr() pass that never rescans substituted text, and markers carry a random part per query. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DqZUi2UiBJP6rZoCSRcdpE
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.
What changes
Query::getParsedQuery()put a fixed marker where each value goes and then substituted the values one after another over the whole query. A value is data and must never be read as part of the query's own structure, but text inside one value could be taken for the marker of another.Now all markers are swapped for their values in one
strtr()pass, which never rescans text it has already substituted, and the markers carry a random part per query.No change for callers: the same queries come out for the same input.
Tests
new Query(...)with bound values and theselectbuilder, for positional and named placeholders; a later value appears exactly once in the result.phpunit --exclude-group=database(the CI selection), run locally on PHP 8.5: 203 tests, 3 errors. The 3 errors are theMySQLErrorTestcases, which need themysqliextension my local PHP lacks; they error the same way onmaster.Release
Intended for 3.3.1, together with #9.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DqZUi2UiBJP6rZoCSRcdpE