Whole file

kayak/pypika

The author described this change as Fix groupby_alias specified multiple times in kwargs when subqueries are used. It counts as a record because the check below fails on the code as it stood at a3f1d0258 and passes on 8d6f7b857, with nothing else changed between the two runs.

Fix saved2020-12-09
Sharing licenceApache-2.0 · LICENSE.txt
Change size+8 2

What the code was meant to do, written into the code itself as a save note

Fix groupby_alias specified multiple times in kwargs when subqueries are used

The change

276276 super().__init__(dialect=Dialects.ORACLE, **kwargs)
277277
278278 def get_sql(self, *args: Any, **kwargs: Any) -> str:
279- return super().get_sql(*args, groupby_alias=False, **kwargs)
279+ # Oracle does not support group by a field alias
280+ # Note: set directly in kwargs as they are re-used down the tree in the case of subqueries!
281+ kwargs['groupby_alias'] = False
282+ return super().get_sql(*args, **kwargs)
280283
281284
282285 class OracleQuery(Query):
577580 return querystring
578581
579582 def get_sql(self, *args: Any, **kwargs: Any) -> str:
580- return super().get_sql(*args, groupby_alias=False, **kwargs)
583+ # MSSQL does not support group by a field alias.
584+ # Note: set directly in kwargs as they are re-used down the tree in the case of subqueries!
585+ kwargs['groupby_alias'] = False
586+ return super().get_sql(*args, **kwargs)
581587
582588 def _top_sql(self) -> str:
583589 if self._top:

The check that tells the two apart

failpass·pypika/tests/dialects/test_mssql.py::SelectTests::test_groupby_alias_False_does_not_group_by_alias_when_subqueries_are_present

Check file pypika/tests/dialects/test_mssql.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before ita3f1d025822ed34408ad93c8e8d9f3f794378f27
Broken version dated2020-12-04
Modulepypika.dialects
Units changedMSSQLQueryBuilder, OracleQueryBuilder
Fingerprinta97923fd9646f22b
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in kayak/pypika