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.

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

611611 def get_sql(self, **kwargs: Any) -> str:
612612 dialect = kwargs.get("dialect", None)
613613 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+
615619 return format_alias_sql(sql, self.alias, **kwargs)
616620
617621

The check that tells the two apart

failpass·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