Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for $0 over SQL adapter #8388

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion edb/pgsql/resolver/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,9 @@ def resolve_ParamRef(
# external params map one-to-one to internal params
if expr.number < 1:
raise errors.QueryError(
f'there is no parameter ${expr.number}',
f'param out of bounds: ${expr.number}',
pgext_code=pgerror.ERROR_UNDEFINED_PARAMETER,
hint='query parameters start with 1',
)

param = ctx.query_params[expr.number - 1]
Expand Down
3 changes: 2 additions & 1 deletion tests/test_sql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ async def test_sql_query_53(self):

async def test_sql_query_54(self):
with self.assertRaisesRegex(
asyncpg.UndefinedParameterError, 'there is no parameter \\$0'
asyncpg.UndefinedParameterError, 'param out of bounds: \\$0',
hint='query parameters start with 1'
):
await self.scon.fetch(
'''
Expand Down