Repository navigation
fix(pg-meta): return complete check expressions for NOT VALID and NO INHERIT constraints - #517
Merged
barryroodt merged 1 commit intoNov 5, 2026
Conversation
…INHERIT constraints list_tables cut the check expression out of pg_get_constraintdef by character count, so the NOT VALID or NO INHERIT suffix shifted the cut and returned text such as "a > 0) NOT VALI". Read the expression with pg_get_expr instead. Fixes supabase#516
barryroodt
approved these changes
Nov 5, 2026
barryroodt
left a comment
Contributor
There was a problem hiding this comment.
Thanks @irisfield, nice catch, and the write-up made this easy to review!
On your first question: yes, pg_get_expr is what we want. I compared old vs new output on PGlite (Postgres 17.5) for a handful of shapes (regex, IN list, BETWEEN with AND, date + jsonb casts, OR IS NULL) and they match. Only the NOT VALID / NO INHERIT cases change.
On the second one, flagging NOT VALID in the output is fine to leave out of this PR.
Merged
barryroodt
pushed a commit
that referenced
this pull request
Nov 5, 2026
🤖 I have created a release *beep* *boop* --- <details><summary>mcp-server-supabase: 0.16.0</summary> ## [0.16.0](mcp-server-supabase-v0.15.0...mcp-server-supabase-v0.16.0) (2026-11-05) ### Features * bound run_notebook cost ([#511](#511)) ([e90d110](e90d110)) * **mcp-server-supabase:** run selected notebook cells ([#514](#514)) ([8d04248](8d04248)) * **notebooks:** add delete_notebook tool with elicitation confirmation ([#510](#510)) ([f36f74a](f36f74a)) * **notebooks:** enable create_notebook and run_notebook tools ([#509](#509)) ([addc4e5](addc4e5)) ### Bug Fixes * **feedback:** accept null project_id and surface the feedback length limit ([#521](#521)) ([994f56c](994f56c)) * hint agents to re-copy malformed project refs ([#522](#522)) ([0c650bf](0c650bf)) * **notebooks:** return caller errors for client-caused notebook refusals ([#512](#512)) ([5f0d393](5f0d393)) * **pg-meta:** report partition FKs once and add partition_of to list_tables ([#508](#508)) ([2c7fa82](2c7fa82)) * **pg-meta:** return complete check expressions for NOT VALID and NO INHERIT constraints ([#517](#517)) ([c54bb40](c54bb40)) * **sql:** skip destructive confirmation for planner-only EXPLAIN ([#519](#519)) ([95745e5](95745e5)) * tolerate non-URL edge function paths in api platform ([#438](#438)) ([00d07a4](00d07a4)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: supabase-releaser[bot] <223506987+supabase-releaser[bot]@users.noreply.github.com>
Contributor
Author
|
Thanks for the review and for running the extra comparisons! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
Bug fix
What is the current behavior?
Fixes #516
list_tables(verbose) builds each column'scheckby removingCHECK (and the last character frompg_get_constraintdefby character count. When the constraint has aNOT VALIDorNO INHERITsuffix, the cut lands inside the suffix.What is the new behavior?
The
check_constraintssubquery incolumns.sqlreads the expression withpg_get_expr(conbin, conrelid, true), which returns the expression without any constraint options. Checks without a suffix return the same text as before.check (a > 0) not valida > 0) NOT VALIa > 0check (b > 0) no inheritb > 0) NO INHERIb > 0check (c > 0)c > 0c > 0No change to tool names, descriptions, or input and output schemas.
How to Review
Check expression
packages/mcp-server-supabase/src/pg-meta/columns.sqlcheck_constraintssubquery now selectspg_get_expr(...)in place of thesubstring(pg_get_constraintdef(...)).Tests
packages/mcp-server-supabase/src/server.database.test.tslist tables returns the check expression for NOT VALID and NO INHERIT constraintschecks thecheckreturned bylist_tablesfor aNOT VALID, aNO INHERITand a plain constraint.Review questions
pg_get_expr(conbin, conrelid, true)the output you want forcheck? It matches the previous text for constraints without options.list_tablessay when a check isNOT VALID(not yet validated against existing rows)? This PR returns the expression only and does not add a field.numericandIN (...)shapes?checkvaluelist_tablesreturns, rather than the SQL that builds it?Verification
mainwitha > 0) NOT VALIandb > 0) NO INHERI, and passes with the fix.pnpm --filter @supabase/mcp-server-supabase test:unit --run: 771 passed.pnpm format:check: clean.mainreturnsa > 0) NOT VALIandb > 0) NO INHERI; this branch returnsa > 0,b > 0andc > 0.