fix: strip quotes from type names in view dependency detection#337
Merged
tianzhou merged 2 commits intopgplex:mainfrom Mar 13, 2026
Merged
fix: strip quotes from type names in view dependency detection#337tianzhou merged 2 commits intopgplex:mainfrom
tianzhou merged 2 commits intopgplex:mainfrom
Conversation
When a function returns a quoted type like SETOF public."ViewName", the extractBaseTypeName function was not stripping the double quotes. This caused the lookup in functionReferencesNewView to fail because the view lookup map stores unquoted names (e.g., public.viewname). As a result, functions with quoted return types were not detected as having view dependencies, causing them to be created before the views they depend on, leading to "type does not exist" errors. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Greptile SummaryThis PR fixes a bug in Key changes:
Notes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Diff as diff.go (orderDDLStatements)
participant FRV as functionReferencesNewView
participant EBT as extractBaseTypeName
participant TML as typeMatchesLookup
participant VL as newViewLookup (map)
Diff->>FRV: fn, newViewLookup
FRV->>EBT: fn.ReturnType (e.g. SETOF public."ViewName")
EBT-->>EBT: strip SETOF → public."ViewName"
EBT-->>EBT: strip [] → public."ViewName"
EBT-->>EBT: strip quotes → public.ViewName [NEW]
EBT-->>FRV: "public.ViewName"
FRV->>TML: typeName="public.ViewName", schema, newViewLookup
TML-->>TML: ToLower → "public.viewname"
TML->>VL: lookup["public.viewname"]
VL-->>TML: found ✓
TML-->>FRV: true
FRV-->>Diff: true → function depends on view, order accordingly
Last reviewed commit: b1f3b10 |
tianzhou
requested changes
Mar 4, 2026
Contributor
tianzhou
left a comment
There was a problem hiding this comment.
Thanks for the contribution. please add an unit test
Contributor
Author
|
I'll take a look at adding the tests |
Add tests for the extractBaseTypeName function to verify correct handling of quoted identifiers in type expressions. Tests cover: - Simple types - SETOF prefix with schema-qualified types - Quoted type names (e.g., SETOF public."ViewName") - Quoted schema and type names - Array notation - Combined cases (SETOF + quoted + array) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Contributor
Author
Tests added |
tianzhou
approved these changes
Mar 13, 2026
Contributor
tianzhou
left a comment
There was a problem hiding this comment.
LGTM. Thanks for the contribution.
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.
When a function returns a quoted type like SETOF public."ViewName", the extractBaseTypeName function was not stripping the double quotes. This caused the lookup in functionReferencesNewView to fail because the view lookup map stores unquoted names (e.g., public.viewname).
As a result, functions with quoted return types were not detected as having view dependencies, causing them to be created before the views they depend on, leading to "type does not exist" errors.