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

constraintViolation does not work with check constraints on domains #87

Open
photz opened this issue Apr 18, 2022 · 1 comment
Open

Comments

@photz
Copy link

photz commented Apr 18, 2022

Currently, constraintViolation does not correcty parse the error message generated by Postgres when a check constraint on a domain is violated.
So, for instance, if I define a domain like this:

create domain foo as int check (value <> 42);

and then do something to violate the constraint, like so

select 42::foo;

then the error message generated by Postgres is: value for domain foo violates check constraint "foo_check"
constraintViolation in that case returns Nothing because it expected the domain name to be surrounded by quotation marks.

@photz
Copy link
Author

photz commented Apr 18, 2022

Actually, the domain name is conditionally wrapped in quotation marks:
https://github.com/postgres/postgres/blob/27b77ecf9f4d5be211900eda54d8155ada50d696/src/backend/utils/adt/domains.c#L184
format_type_be() quotes it, if there's whitespace, for example.

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

No branches or pull requests

1 participant