Skip to content

Conversation

@tianzhou
Copy link
Contributor

@tianzhou tianzhou commented Nov 9, 2025

Fix issue 2 of #155

Fix developed based on #158

Copilot AI review requested due to automatic review settings November 9, 2025 13:14
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds normalization of schema-qualified type names in function and procedure parameters. When PostgreSQL returns type names with schema qualifications (e.g., public.order_status), the code now strips the schema prefix if it matches the routine's schema, while preserving cross-schema references (e.g., utils.priority_level remains qualified when the function is in public schema).

Key changes:

  • Added stripSameSchemaPrefix method to normalize type names by removing same-schema qualifications
  • Updated parseParametersFromSignature to accept a routineSchema parameter and normalize parameter types
  • Test data files updated to demonstrate the functionality with functions having parameters from both same-schema and cross-schema types

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
ir/inspector.go Added stripSameSchemaPrefix method and updated parseParametersFromSignature to normalize parameter type names by schema context
testdata/diff/create_function/alter_function_same_signature/plan.txt Updated test data with additional function parameters using custom types
testdata/diff/create_function/alter_function_same_signature/plan.sql Updated test SQL with additional function parameters using custom types
testdata/diff/create_function/alter_function_same_signature/plan.json Updated JSON plan with new pgschema version, fingerprint, and SQL containing additional parameters
testdata/diff/create_function/alter_function_same_signature/old.sql Added enum type definition and additional function parameters to old schema state
testdata/diff/create_function/alter_function_same_signature/new.sql Added enum type definition and additional function parameters with comment to new schema state
testdata/diff/create_function/alter_function_same_signature/diff.sql Updated diff output showing additional function parameters
Comments suppressed due to low confidence (1)

ir/inspector.go:1057

  • When parsing multi-word type names (e.g., character varying(255)), this code joins all parts after the parameter name with spaces. However, the stripSameSchemaPrefix function on line 1065 expects a single type identifier and won't correctly handle schema prefixes in complex types like public.character varying(255). This could cause the schema prefix to remain when it should be stripped. Consider parsing the first word of the type separately for schema stripping, then reconstructing the full type.
			param.DataType = strings.Join(remainingParts[1:], " ")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tianzhou tianzhou force-pushed the function_schema_qualifer branch from a17cbd1 to 7160ec4 Compare November 9, 2025 13:28
@tianzhou tianzhou force-pushed the function_schema_qualifer branch from 7160ec4 to 6e5676e Compare November 9, 2025 13:28
@tianzhou tianzhou merged commit add00ec into main Nov 9, 2025
2 checks passed
@tianzhou
Copy link
Contributor Author

tianzhou commented Nov 9, 2025

cc @p-c-h-b

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