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 running the MergeColumns change type, the end result differs depending on the DBMS in use, sometimes resulting in data loss when one of the columns to be merged contains NULL.
The documentation doesn't mention any warning around this, and the example SQL shown uses the CONCAT_WS function. However on SQL Server, the concatenation statement generated by Liquibase uses the + operator, where the output is NULL when one of the input columns is NULL.
Comparing to MySQL, H2, where the CONCAT function is used and NULL in one of the columns does not result in NULL in the end result
The MergeColumns change type treats null values consistently across DBMS vendors (i.e. always uses a CONCAT style function to treat NULL as an empty string)
OR
The documentation is updated to reflect that this behaviour differs per DBMS
Liquibase Version
4.27.0
Database Vendor & Version
Microsoft Azure SQL Edge Developer (RTM) - 15.0.2000.1574 (ARM64)
Liquibase Integration
Docker
Liquibase Extensions
No response
OS and/or Infrastructure Type/Provider
No response
Additional Context
I'm happy to submit a PR either way or any other suggestions?
Are you willing to submit a PR?
I'm willing to submit a PR (Thank you!)
The text was updated successfully, but these errors were encountered:
Hi @goughy000, thank you for reporting this issue. I agree that the behaviour should be consistent, and I believe this is more a program bug than a documentation error.
Here is the generated SQL script for a few different databases:
DB
Statement
H2
UPDATE PUBLIC.names SET fullname = CONCAT(firstname, CONCAT(' ', lastname));
UPDATE lbcat.names SET fullname = CONCAT_WS(' ', firstname, lastname);
PostgreSQL
UPDATE public.names SET fullname = firstname
Out of these, only MSSQL isn't using string concatenation, so that is where the code should be modified.
I see that you're willing to submit a PR - our development team is available to provide guidance if needed, so feel free to create the PR and ask any questions you may have.
Search first
Description
When running the MergeColumns change type, the end result differs depending on the DBMS in use, sometimes resulting in data loss when one of the columns to be merged contains NULL.
The documentation doesn't mention any warning around this, and the example SQL shown uses the
CONCAT_WS
function. However on SQL Server, the concatenation statement generated by Liquibase uses the+
operator, where the output is NULL when one of the input columns is NULL.Comparing to MySQL, H2, where the CONCAT function is used and NULL in one of the columns does not result in NULL in the end result
Steps To Reproduce
Changelog used:
SQL Generated and ran by Liquibase:
MySQL:
SQL Server:
Which results in the following final data in the table:
MySQL:
SQL Server:
Expected/Desired Behavior
Expected behaviour is either
OR
Liquibase Version
4.27.0
Database Vendor & Version
Microsoft Azure SQL Edge Developer (RTM) - 15.0.2000.1574 (ARM64)
Liquibase Integration
Docker
Liquibase Extensions
No response
OS and/or Infrastructure Type/Provider
No response
Additional Context
I'm happy to submit a PR either way or any other suggestions?
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: