Skip to content

Commit

Permalink
Fix SQL normalization (#8021)
Browse files Browse the repository at this point in the history
Extracted constants are not always reported in order of parameters,
so sort them explicitly.
  • Loading branch information
elprans authored Nov 22, 2024
1 parent 0867249 commit ff9d074
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 3 additions & 1 deletion edb/pgsql/parser/parser.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,9 @@ cdef class NormalizedSource(Source):
serialized: Optional[bytes] = None,
) -> None:
super().__init__(text=normalized.text, serialized=serialized)
self._extracted_constants = normalized.extracted_constants
self._extracted_constants = list(
sorted(normalized.extracted_constants, key=lambda i: i[0]),
)
self._highest_extern_param_id = normalized.highest_extern_param_id
self._orig_text = orig_text

Expand Down
2 changes: 0 additions & 2 deletions tests/test_sql_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -2337,7 +2337,6 @@ async def test_native_sql_query_09(self):
[{'a': 1, 'x_a': 2}],
)

@test.xfail('bug: probably something with constant extraction')
async def test_native_sql_query_10(self):
await self.assert_sql_query_result(
'''
Expand All @@ -2348,7 +2347,6 @@ async def test_native_sql_query_10(self):
[{'a': 1, 'b': 2, 'c': 3}], # values are swapped around
)

@test.xerror('bug: probably something with constant extraction')
async def test_native_sql_query_11(self):
# JOIN ... ON TRUE fails, saying it expects bool, but it got an int
await self.assert_sql_query_result(
Expand Down

0 comments on commit ff9d074

Please sign in to comment.