Skip to content

fix: col default expression#93

Closed
tianzhou wants to merge 1 commit intomainfrom
default_expression
Closed

fix: col default expression#93
tianzhou wants to merge 1 commit intomainfrom
default_expression

Conversation

@tianzhou
Copy link
Contributor

Fix #91

Copilot AI review requested due to automatic review settings October 16, 2025 16:18
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 a bug in handling column default expressions where complex default expressions containing parentheses combined with NOT NULL constraints were being formatted incorrectly (GitHub issue #91). The specific issue was that closing parentheses were being lost before NOT NULL constraints.

Key changes:

  • Updated the normalizeDefaultValue function to use regex-based type cast removal that preserves content after the type cast
  • Added comprehensive test case for the issue including raw SQL, expected pgschema output, and pg_dump output

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ir/normalize.go Modified type cast stripping logic to use regex pattern matching instead of simple string truncation
cmd/dump/dump_integration_test.go Added integration test for the default expression bug
testdata/dump/issue_91_col_default_expr/raw.sql Test input SQL demonstrating the problematic default expression pattern
testdata/dump/issue_91_col_default_expr/pgschema.sql Expected output showing correct formatting with preserved parentheses
testdata/dump/issue_91_col_default_expr/pgdump.sql Reference pg_dump output for comparison
testdata/dump/issue_91_col_default_expr/manifest.json Test case metadata and documentation

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

@tianzhou tianzhou closed this Oct 18, 2025
@tianzhou tianzhou deleted the default_expression branch October 23, 2025 06:34
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.

column default expression sometimes generate invalid syntax

2 participants