Whole file
kayak/pypika
The author described this change as “Fix empty Postgres array syntax (#539)”. It counts as a record because the check below fails on the code as it stood at d94277496 and passes on aadc9f375, with nothing else changed between the two runs.
Projectkayak/pypika
Fix saved2021-01-11
Sharing licenceApache-2.0 · LICENSE.txt
Change size+5 −1
What the code was meant to do, written into the code itself as a save note
Fix empty Postgres array syntax (#539)
The change
| 611 | 611 | def get_sql(self, **kwargs: Any) -> str: | |
| 612 | 612 | dialect = kwargs.get("dialect", None) | |
| 613 | 613 | values = ",".join(term.get_sql(**kwargs) for term in self.values) | |
| 614 | - | sql = ("ARRAY[{}]" if dialect in (Dialects.POSTGRESQL, Dialects.REDSHIFT) else "[{}]").format(values) | |
| 614 | + | ||
| 615 | + | sql = "[{}]".format(values) | |
| 616 | + | if dialect in (Dialects.POSTGRESQL, Dialects.REDSHIFT): | |
| 617 | + | sql = "ARRAY[{}]".format(values) if len(values) > 0 else "'{}'" | |
| 618 | + | ||
| 615 | 619 | return format_alias_sql(sql, self.alias, **kwargs) | |
| 616 | 620 | ||
| 617 | 621 |
The check that tells the two apart
fail→pass·pypika/tests/test_tuples.py::ArrayTests::test_empty_psql_array
Check file pypika/tests/test_tuples.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 itd94277496e2a51b272ae21e9a8b7792bfc355290
Broken version dated2021-01-07
Modulepypika.terms
Units changedArray
Fingerprint78032ad74fcd9823
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-04Fix PostgreSQLQueryBuilder returning clause code causing Py3.9 test failures
- 2020-12-09Fix groupby_alias specified multiple times in kwargs when subqueries are used