-
Notifications
You must be signed in to change notification settings - Fork 32
fix: strip quotes from type names in view dependency detection #337
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1929,7 +1929,7 @@ func functionReferencesNewView(fn *ir.Function, newViews map[string]struct{}) bo | |
| } | ||
|
|
||
| // extractBaseTypeName extracts the base type name from a type expression, | ||
| // stripping SETOF prefix and array notation. | ||
| // stripping SETOF prefix, array notation, and double quotes from identifiers. | ||
| func extractBaseTypeName(typeExpr string) string { | ||
| t := strings.TrimSpace(typeExpr) | ||
| // Strip SETOF prefix (case-insensitive) | ||
|
|
@@ -1940,6 +1940,8 @@ func extractBaseTypeName(typeExpr string) string { | |
| for len(t) > 2 && t[len(t)-2:] == "[]" { | ||
| t = t[:len(t)-2] | ||
| } | ||
| // Strip double quotes from identifiers (e.g., public."ViewName" -> public.ViewName) | ||
| t = strings.ReplaceAll(t, "\"", "") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Quote-stripping happens before case-folding, but after array stripping — works correctly, but edge case with dot-containing quoted schema names The approach of In practice, schema names with dots are extremely uncommon and This is a very low-probability edge case, but it's worth being aware of. The simpler alternative — stripping only quotes that wrap a single token (e.g., via a small regex like No code change required unless dot-containing schema names are a supported use case. |
||
| return t | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No tests added for the new quoted-identifier behavior
The fix is correct, but there are no unit tests in the diff covering the new quoted-identifier stripping logic. Without tests, future refactors could silently regress this case. Consider adding a test for
extractBaseTypeName(or an integration-style test forfunctionReferencesNewView) that covers at minimum:SETOF public."ViewName"→public.ViewName"Schema"."View"→Schema.View"MyType"[]→MyTypepublic.unquoted→public.unquoted(no-op, regression guard)Example: