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

Correctly parse complex check constraint expressions for PostgreSQL #43963

Merged

Conversation

fatkodima
Copy link
Member

Postgres "arbitrarily" adds additional parentheses to check constraint definitions when retrieving from pg_constraint system table. It can be surrounded by 2 pairs of them, or by 1.
But pg_get_constraintdef supports additional parameter (for pretty printing) which removes them when not needed and the check constraint definiton is always looks like CHECK (<actual definition>).

Closes #43823

@fatkodima fatkodima force-pushed the fix-postgres-check-constraint-expression branch 2 times, most recently from 9f89b48 to 5c9a541 Compare December 22, 2021 01:49
@fatkodima fatkodima force-pushed the fix-postgres-check-constraint-expression branch from 5c9a541 to 9f0f286 Compare December 22, 2021 02:09
@kamipo kamipo merged commit a8d088f into rails:main Dec 22, 2021
kamipo added a commit that referenced this pull request Dec 22, 2021
…t-expression

Correctly parse complex check constraint expressions for PostgreSQL
@joeljunstrom
Copy link

Nice fix, just noticed this bug and was perplexed for a while. Would it make sense to backport this to 6-1-stable?

CGA1123 pushed a commit to CGA1123/rails that referenced this pull request Jul 31, 2023
…traint-expression

Correctly parse complex check constraint expressions for PostgreSQL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check constraint with psql CASE statement is nil in schema.
3 participants