question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The **nullable** and **defaultValue** and **value** attributes do not work together as one

See original GitHub issue

Environment

Liquibase Version: 4.6.2-4.8.0 Liquibase Integration & Version: Spring Boot 2.6.4 Database Vendor & Version: MySQL 8.0.20 Operating System Type & Version: macOS 12.3

Description

After upgrading 4.6.1->4.6.2+, Using the createTable tag, The nullable and defaultValue attributes do not work.

databaseChangeLog

<changeSet author="tom" id="20220124-003">
    <createTable tableName="menu">
        <column autoIncrement="true" name="id" type="BIGINT" remarks="pk">
            <constraints nullable="false" primaryKey="true"/>
        </column>
        <column name="path" type="VARCHAR(255)" remarks="path" defaultValue="">
            <constraints nullable="false"/>
        </column>
    </createTable>
</changeSet>

Liquibase 4.6.1 creates a correct table

`path` varchar(255) NOT NULL DEFAULT '' COMMENT 'path',

Liquibase 4.6.2+ creates a incorrect table

`path` varchar(255) DEFAULT NULL COMMENT 'path',

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
erolatrestoncommented, Mar 20, 2022

Please see https://github.com/liquibase/liquibase/issues/2657. The problem exists only for adding non-nullable columns when the value is also specified. If the value is not specified, default value is correctly set.

0reactions
nvoxlandcommented, Jul 16, 2022

This is working for me as of 4.13.0. I think it was addressed by #2752

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - DefaultValue attribute is not working with my Auto Property
The DefaultValue attribute is only used to tell the Visual Studio Designers (for example when designing a form) what the default value of...
Read more >
Adding a column with a default value to a table - Ask TOM
I have done very light test adding the column with the default value and not null constraint straight, as opposing of doing it...
Read more >
Function arguments - Manual - PHP
A function may define default values for arguments using syntax similar to assigning a variable. The default is used only when the parameter...
Read more >
Model Binding in ASP.NET Core | Microsoft Learn
By default, a model state error isn't created if no value is found for a model property. The property is set to null...
Read more >
Immutable objects
Any annotation with simple name Nullable will work. Nullable attributes are not required to be set using a builder, and null values are...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found