Repository navigation
feat(sql): add the postcode as a PostgreSQL domain and DuckDB macros - #75
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The postcode as a column type, in plain SQL. There is no extension to build, so both files load on managed services that accept none.
sql/postgres.sql): anng_postcodedomain that refuses anything but a compact code, anng_postcode_prefixdomain, and six immutable functions: parse a code or a prefix, format, truncate to a segment, parent, and within.sql/duckdb.sql): macros with the same names and answers. DuckDB has no domains, so the README gives the constraint to use.scripts/sql_conformance.pyturns the cases inspec/vectors.jsoninto SQL and runs them, 101 on each engine. Two steps in thepythonjob run it, so the ruleset is unchanged.translate()becauseupper()follows the database locale. I ran PostgreSQL 17 under a Turkish locale, where a naive version would mishandlei, along with PostgreSQL 14 and DuckDB 1.5.EXPLAINand the README shows the form.One thing the README warns about because I got it wrong first: a DuckDB constraint written with
=lets a malformed code through, since comparing with NULL is not false. It needsIS NOT DISTINCT FROM.The CI steps use the runner's preinstalled PostgreSQL, which I could not exercise locally. If they fail here, I will fix them on this branch.