feat(Postgres): support nested domain types
This PR adds support for nested domain types. When comparing a PgType by Oid it compares the Oid of the base type when it is a domain.
Does this PR only address DOMAINs that are transitively based on a "primitive" (e.g., a DOMAIN of a DOMAIN of integer)? If not, then there should be a test added for the case where you have a composite type that has a DOMAIN field that is based on a composite type that has a "primitive" field. For example a test that fetches the row in buzz based on the below query:
BEGIN;
CREATE TYPE foo AS (x integer);
CREATE DOMAIN bar AS foo NOT NULL;
CREATE TYPE fizz AS (y bar);
CREATE TABLE buzz(z fizz NOT NULL);
INSERT INTO buzz VALUES (ROW(ROW(1)));
COMMIT;
There is a bug in how FromSql is derived in postgres_types that was not triggered until such a test was added. If this PR does not intend to support such situations, then it may make sense to rename the PR to make it clear that only transitive "primitive" DOMAIN support is being added.
Thanks for the comment, it did not support all nested domain types. I updated the PR and added the unit test from the mentioned PR.
@joeydewaal merge conflicts here.
All done!