Skip to content

HCK-18624: Do not generate SET DEFAULT when the default value is unchanged - #210

Open
Sylvie-P wants to merge 1 commit into
developfrom
HCK-18624
Open

Sylvie-P wants to merge 1 commit into
developfrom
HCK-18624

Conversation

@Sylvie-P

@Sylvie-P Sylvie-P commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor
Sub-bugHCK-18624 [PostgreSQL] FE generates a redundant ALTER COLUMN SET DEFAULT for a false default when the column has a comment

## Problem

In PostgreSQL forward-engineering with column default values inline, a column with a default value false and a comment gets its default twice: inline in CREATE TABLE, and again as ALTER TABLE ... ALTER COLUMN ... SET DEFAULT false;.

Column comments always go in separate statements, so the column goes through the ALTER script helpers. In defaultValueHelper.js, the filter was:

newDefault !== undefined && (!oldDefault || newDefault !== oldDefault)

!oldDefault is true for false, 0, "" and null, so an unchanged falsy default was generated again. The !== comparison already covers the case of a new default, so the extra clause only added false positives.

Change

newDefault !== undefined && newDefault !== oldDefault

Same logic as the CREATE path, which uses !_.isUndefined(columnDefinition.default).

Checked (helper called directly with node)

Old default New default Before After
false false SET DEFAULT false nothing
0 0 SET DEFAULT 0 nothing
absent false (separate option) SET DEFAULT false SET DEFAULT false
false true SET DEFAULT true SET DEFAULT true
5 5 nothing nothing
false absent DROP DEFAULT DROP DEFAULT

Regression test in Studio, same branch name HCK-18624 (script generation options, PostgreSQL model: boolean column with default false and a comment).

Note: the same filter exists in the YugabyteDB, BigQuery and Db2 plugins. Not changed here.

Related: HCK-18361 (fix of the empty SET DEFAULT ; for false).

🤖 Generated with Claude Code

…anged

The filter treated a falsy old default (false, 0, empty string) as missing,
so an unchanged default was generated again as ALTER COLUMN SET DEFAULT.
This happens in forward-engineering for any column with a comment, because
column comments go through the ALTER script path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants