From b1f3b1075b07c72fcfa6dce9a4b25fe4ba785ab7 Mon Sep 17 00:00:00 2001 From: Justin McIntyre Date: Wed, 4 Mar 2026 10:49:04 -0400 Subject: [PATCH] fix: strip quotes from type names in view dependency detection 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 --- internal/diff/diff.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/diff/diff.go b/internal/diff/diff.go index 48f8b5e9..5ae3a1f6 100644 --- a/internal/diff/diff.go +++ b/internal/diff/diff.go @@ -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, "\"", "") return t }