Fix write query failing when a named parameter is called :sql#2765
Open
viraatdas wants to merge 1 commit into
Open
Fix write query failing when a named parameter is called :sql#2765viraatdas wants to merge 1 commit into
viraatdas wants to merge 1 commit into
Conversation
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.
Fixes #2761.
When you run a write query containing a named parameter called
:sql(for exampleupdate docs set title = :sql where id = :id), the generated parameter input on the execute-write form is namedsql, which collides with the form's ownsqlfield holding the query text. The user's:sqlvalue then overrides the query for the rest of the form, so the write does not work.This namespaces the generated parameter form inputs with a
_sql_param_prefix (via a newsql_parameter_name_prefix), so a:sql(or:id, etc.) parameter input no longer collides with the controlsqlfield. The label still shows the bare parameter name, and the JS parameter controls track the original name viadata-parameter-name; the execute-write view reads the prefixed fields.Added an end-to-end regression test (
test_execute_write_form_parameter_called_sql) that runs a write query with a:sqlparameter and asserts the affected row is updated correctly. It fails before this change.Prepared with AI assistance.