Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the PostgreSQL domain #532

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Leo-XM-Zeng
Copy link
Contributor

@Leo-XM-Zeng Leo-XM-Zeng commented Jan 14, 2025

If the domain refers to a base type, we only need to obtain the corresponding base type.
If domain refers to an array type, we need to obtain the corresponding array type and array dimension information.
If the type currently used is an array type, and the member type of the array type is domain, we need to get the most basic type and then construct the corresponding array type.
#514

Comment on lines 1 to 4
create domain domainvarchar varchar(5);
create domain domainnumeric numeric(8,2);
create domain domainint4 int4;
create domain domaintext text;
Copy link
Collaborator

@JelteF JelteF Jan 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Domains are often use to encode check constraints:

> CREATE DOMAIN positiveint int CHECK(VALUE > 0);
CREATE DOMAIN
> select 5::positiveint;
 positiveint
─────────────
           5
> select (-5)::positiveint;
ERROR:  23514: value for domain positiveint violates check constraint "positiveint_check"
SCHEMA NAME:  public
DATATYPE NAME:  positiveint
CONSTRAINT NAME:  positiveint_check

In the tests for this PR you don't use that feature. I'm also not sure if/how we can implement those checks. How about for this first version we error of the domain has a constraint? (and show that we do that with a test).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants