Skip to content

Fix write query failing when a named parameter is called :sql#2765

Open
viraatdas wants to merge 1 commit into
simonw:mainfrom
viraatdas:libra/issues/1-cannot-execute-a-write-query-with-a-parameter-ca
Open

Fix write query failing when a named parameter is called :sql#2765
viraatdas wants to merge 1 commit into
simonw:mainfrom
viraatdas:libra/issues/1-cannot-execute-a-write-query-with-a-parameter-ca

Conversation

@viraatdas
Copy link
Copy Markdown

Fixes #2761.

When you run a write query containing a named parameter called :sql (for example update docs set title = :sql where id = :id), the generated parameter input on the execute-write form is named sql, which collides with the form's own sql field holding the query text. The user's :sql value 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 new sql_parameter_name_prefix), so a :sql (or :id, etc.) parameter input no longer collides with the control sql field. The label still shows the bare parameter name, and the JS parameter controls track the original name via data-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 :sql parameter and asserts the affected row is updated correctly. It fails before this change.

Prepared with AI assistance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot execute a write query with a parameter called :sql

1 participant