Skip to content

Substitute favorite query args $10 and above - #2449

Merged
rolandwalker merged 2 commits into
dbcli:mainfrom
zzoraemon043:favorite-two-digit-args
Nov 19, 2026
Merged

rolandwalker merged 2 commits into
dbcli:mainfrom
zzoraemon043:favorite-two-digit-args

Conversation

@zzoraemon043

Copy link
Copy Markdown
Contributor

Description

Favorite query positional parameters break once a query uses $10 or higher. prepare_favorite_query_args() replaces $1 with str.replace(), so it also rewrites the start of $10, $11, ...

\fs q select $1, $2, $3, $4, $5, $6, $7, $8, $9, $10
\f q 1 2 3 4 5 6 7 8 9 10
query does not have substitution parameter $10:
  select 1, 2, 3, 4, 5, 6, 7, 8, 9, 10

The error message is also misleading: the displayed 10 is really $1's value followed by 0. With fewer arguments the mistake is silent: select $1, $10 with one argument x runs select x, x0 instead of reporting the missing $10.

The fix only matches a parameter when it is not followed by another digit. Single-digit behaviour and the existing error messages are unchanged.

test_subst_favorite_query_args_with_two_digit_parameters fails on main and passes with this change. pytest mycli_test/pytests has the same set of failures before and after on my Windows machine (polars/llm/ssh/unix-socket tests that don't run here), plus the new test passing. ruff check, ruff format --check are clean and mypy reports no new errors.

Checklist

  • I added this contribution to the changelog.md file.
  • I added my name to the mycli/AUTHORS.txt file (or it's already there).
  • To lint and format the code, I ran
    uv run ruff check && uv run ruff format && uv run mypy --install-types .

zzoraemon043 and others added 2 commits November 19, 2026 15:38
prepare_favorite_query_args() replaced "$1" with plain str.replace(),
which also matched the start of "$10", "$11" and so on. With ten or
more arguments the query was rejected because "$10" was no longer
present, and with a single argument "select $1, $10" silently became
"select x, x0" instead of reporting the missing "$10".

Only match a parameter when it is not followed by another digit.
@rolandwalker
rolandwalker merged commit 8020e18 into dbcli:main Nov 19, 2026
@rolandwalker

Copy link
Copy Markdown
Contributor

Thank you @zzoraemon043 !

zzoraemon043 added a commit to zzoraemon043/zzoraemon043 that referenced this pull request Nov 19, 2026
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.

2 participants