Skip to content

Commit

Permalink
Improve error message for $0 over SQL adapter (#8388)
Browse files Browse the repository at this point in the history
Closes #8374
  • Loading branch information
aljazerzen authored and msullivan committed Mar 1, 2025
1 parent b30975b commit b0cd0c7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion edb/pgsql/resolver/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,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

0 comments on commit b0cd0c7

Please sign in to comment.