Skip to content

fix: keep schema qualifier on casts to shadowed types in routine defaults (#701 follow-up) - #729

Merged
tianzhou merged 4 commits into
mainfrom
devin/1795951143-shadowed-type-defaults
Nov 29, 2026
Merged

tianzhou merged 4 commits into
mainfrom
devin/1795951143-shadowed-type-defaults

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #727 (stacked on its branch). A routine parameter default cast to a same-schema type that a pg_catalog type shadows lost its qualifier:

CREATE TYPE name AS ENUM ('main', 'other');
CREATE FUNCTION pick(p public.name DEFAULT 'main') ...
-- before: p public.name DEFAULT 'main'::name          -- rejected by PostgreSQL
-- after:  p public.name DEFAULT 'main'::public.name

The ::schema. cast stripping happened in three places; all now go through a new ir.StripCastQualifiers(value, castQualifierRe, shadowedTypes), which keeps the qualifier when the following identifier is in Metadata.ShadowedTypes:

  • normalizeDefaultValue (both the ::pgschema_tmp_*. and same-schema regexes) — now takes shadowedTypes; routine callers pass it, column defaults pass nil.
  • newSameSchemaQualifierStripper in cmd/plan (maps temp → target, then strips).
  • formatFunctionParameter via new stripDefaultSchemaPrefix.

Not covered: table column types of a shadowed type (e.g. choice public.name) are still emitted bare, because the column query strips same-schema qualifiers in SQL; that needs a queries.sql change and is out of scope here.

Tests: new create_function/issue_701_shadowed_type_default diff/plan fixture (function + procedure), TestStripCastQualifiersKeepsShadowedTypes.

Link to Devin session: https://app.devin.ai/sessions/2160d3f08fd1454bb91db03645ac0427
Open in Devin Desktop: https://app.devin.ai/desktop/session/2160d3f08fd1454bb91db03645ac0427?variant=devin
Requested by: @tianzhou


🟢 Devin Review found nothing to fix · View findings · Follow Devin's work

Devin Review

@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · This PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Preserves required schema qualifiers on casts to shadowed types in routine defaults.

  • Routine defaults keep schema names on shadowed type casts.

Acknowledged scope: devin-ai-integration[bot] explicitly deferred shadowed table column types because the column query removes their qualifiers.

Reviews (1) · Last reviewed commit: "fix: keep schema qualifier on casts to s..." · Reviewed by Greptile

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration
devin-ai-integration Bot changed the base branch from fix/issue-701-shadowed-type-qualifier to main November 29, 2026 11:54
devin-ai-integration Bot and others added 4 commits November 29, 2026 11:54
@devin-ai-integration
devin-ai-integration Bot force-pushed the devin/1795951143-shadowed-type-defaults branch from 4e67785 to f6fbcfe Compare November 29, 2026 11:54
@tianzhou
tianzhou merged commit a0d92d0 into main Nov 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant