feat(transform): name rebinding in SchemaRouter (repoint references at a different object) - #322
Merged
Merged
Conversation
…t a different object)
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
SchemaRouterobject routes can now rebind — repoint a reference at a different object, not just a different schema. Routing preserves identity (same function, new address); rebinding is the substitution primitive: satisfy a reference's contract with another implementation.An object route target is now
string | ObjectRoute, where the shorthand string keeps today's meaning exactly:resolveObject(schema, name, ns): ObjectRoute | undefinedis the full-fidelity resolver;resolve()now delegates to it and keeps its exact schema-only semantics (anull/name-only target reads as "unchanged" there), so every existing caller behaves identically.schemainherits the route's schema-level default;schema: nullde-qualifies, matching theExtensionRouterto: nullconvention.transformNameList/transformRelationapply{ schema, name }targets, covering call sites in expressions, defaults, policies, FK target tables (RangeVar), DROP/COMMENT object lists, and references insideLANGUAGE sqland PL/pgSQL bodies (via the existing AST body walk).hasNameRebinds()(rebinds are inexpressible by the string-level passes, so callers must take the AST path) andnameRebinds()for reporting/verification by consumers.Tests: 9 new cases (unit resolution + call-site/FK/policy/sql-body/de-qualify/sibling-isolation through
transformSqlStatement); full@pgsql/transformsuite green (8 suites / 228 tests).Link to Devin session: https://app.devin.ai/sessions/025fb88043964fdbb335ac5e39df2478
Requested by: @pyramation