Skip to content

Add support for introspecting domain types #380

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

Merged
merged 8 commits into from
Mar 25, 2024
Merged

Add support for introspecting domain types #380

merged 8 commits into from
Mar 25, 2024

Conversation

plcplc
Copy link
Contributor

@plcplc plcplc commented Mar 22, 2024

What

This PR adds support for introspecting domain types.

How

Prior to this PR domain types were already recognised as scalar types. However, the ability to view a domain type transparently as its base type was not, so you couldn't do anything with values of domain type.

This PR adds cases to the set of implicit casts for domain types in the introspection query, which enables support for comparison operators.

@plcplc plcplc force-pushed the plc/issues/PG-61 branch from 56df009 to 631d96d Compare March 22, 2024 20:47
@@ -745,7 +745,41 @@
}
}
},
"Native_query_sql": {
"NativeQuerySql": {
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels like it's related to @soupi 's recent .sql files change for native queries rather than domain types?

Copy link
Contributor

@danieljharvey danieljharvey left a comment

Choose a reason for hiding this comment

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

Lovely that all we have to really do is say "X is actually Y" and then everything else falls into place.

@plcplc plcplc enabled auto-merge March 25, 2024 10:07
@plcplc plcplc added this pull request to the merge queue Mar 25, 2024
Merged via the queue into main with commit 6b60788 Mar 25, 2024
35 checks passed
@plcplc plcplc deleted the plc/issues/PG-61 branch March 25, 2024 10:20
Copy link
Contributor

@SamirTalwar SamirTalwar left a comment

Choose a reason for hiding this comment

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

Late review, but I just wanted to say, thank you for teaching me something. 😊

'c', --for composite type
-- 'd' for domain (a predicate-restricted version of a type)
'c', -- for composite type
-- 'd', for domain (a predicate-restricted version of a type)
Copy link
Contributor

Choose a reason for hiding this comment

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

Weird comma.

@@ -0,0 +1,5 @@
-- This file is used to test the support of domain types

CREATE DOMAIN even_number int4 CHECK (VALUE % 2 = 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

I did not know you could do this in SQL and now I do.

I'm not sure if this is a blessing or a curse.

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.

3 participants