You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When adding new fields with @defaultValue in a JHipster entity, the generated Liquibase changelog does not correctly set the default values in the database. Specifically, the changelog generates the following incorrect XML:
This issue can lead to runtime errors or misaligned database schemas, especially when default values and non-null constraints are crucial for business logic.
Proposed Solution
Update the generator to:
Ensure defaultValueNumeric is set to the numeric value provided in the @defaultValue annotation.
Automatically set nullable="false" if a @defaultValue is defined.
The text was updated successfully, but these errors were encountered:
The bug is in JDL parsing. @defaultValue(1) works as expected, @defaultValue(0) fails.
You can use @defaultValue("0") as workaround.
mshima
changed the title
Liquibase changelog generates incorrect default values for new columns in an entity
jdl: error passing 0 value in field annotations.
Dec 28, 2024
Issue Description
When adding new fields with
@defaultValue
in a JHipster entity, the generated Liquibase changelog does not correctly set the default values in the database. Specifically, the changelog generates the following incorrect XML:This leads to the following problems:
defaultValueNumeric="true"
is invalid and does not set the intended default value (e.g.,0
).NULL
values, even though the@defaultValue
annotation implies it should beNOT NULL
.Steps to Reproduce
@defaultValue
annotations:Expected Behavior
The generated changelog should correctly define default values and nullable constraints. For example:
Observed Behavior
The generated changelog incorrectly defines the columns as follows:
Environment
Additional Context
This issue can lead to runtime errors or misaligned database schemas, especially when default values and non-null constraints are crucial for business logic.
Proposed Solution
Update the generator to:
defaultValueNumeric
is set to the numeric value provided in the@defaultValue
annotation.nullable="false"
if a@defaultValue
is defined.The text was updated successfully, but these errors were encountered: