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.
Projectkayak/pypika
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
| 276 | 276 | super().__init__(dialect=Dialects.ORACLE, **kwargs) | |
| 277 | 277 | ||
| 278 | 278 | 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) | |
| 280 | 283 | ||
| 281 | 284 | ||
| 282 | 285 | class OracleQuery(Query): | |
| ⋯ | |||
| 577 | 580 | return querystring | |
| 578 | 581 | ||
| 579 | 582 | 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) | |
| 581 | 587 | ||
| 582 | 588 | def _top_sql(self) -> str: | |
| 583 | 589 | if self._top: | |
The check that tells the two apart
fail→pass·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
- 2024-04-17fix `Field.__init__` (#742)
- 2023-09-26Fix: Allow the usage of `frozenset` in the `isin(...)` and `notin(...)` functions (#744)
- 2023-09-22fix(terms): fixed EmptyCriterion bug with ComplexCriterion (#732)
- 2021-08-26MySQLQuery
- 2021-01-11Fix empty Postgres array syntax (#539)
- 2021-01-04Fix PostgreSQLQueryBuilder returning clause code causing Py3.9 test failures