Skip to content

Conversation

@tianzhou
Copy link
Contributor

@tianzhou tianzhou commented Oct 22, 2025

Fix #101

Copilot AI review requested due to automatic review settings October 22, 2025 05:38
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 fixes the handling of PostgreSQL table functions that use the newer RETURN clause syntax (introduced in PostgreSQL 14) instead of the traditional AS $$ ... $$ block syntax. The fix addresses issue #103 by updating SQL queries to use pg_get_function_sqlbody() and modifying code generation logic to detect and properly format functions with RETURN clauses.

  • Updates SQL queries to use pg_get_function_sqlbody() with fallback to prosrc for extracting function definitions
  • Adds logic to detect and handle RETURN clause syntax in function/procedure SQL generation
  • Includes test case for table function using RETURN clause with SETOF timestamptz

Reviewed Changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ir/queries/queries.sql Added COALESCE with pg_get_function_sqlbody() to properly extract function bodies that use RETURN clause syntax
ir/queries/queries.sql.go Generated code reflecting SQL query changes for function/procedure retrieval
internal/diff/function.go Added conditional logic to detect RETURN clause syntax and format it without dollar quoting
internal/diff/procedure.go Added same RETURN clause detection logic for procedures
testdata/diff/create_function/add_function/. Test data files demonstrating the fix with a new table function using RETURN clause

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@tianzhou tianzhou merged commit e2cebab into main Oct 22, 2025
2 checks passed
@tianzhou tianzhou deleted the table_function branch October 23, 2025 06:33
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.

Table functions are not dumped

1 participant