Wisser / Jailer

Database Subsetting and Relational Data Browsing Tool.

Home Page:https://wisser.github.io/Jailer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

liquibase.exception.MigrationFailedException when importing generated XML files with dates

JoshBargar opened this issue · comments

Description of the Issue

I am using the API to generate a liquibase XML file, but when I execute mvn liquibase:update, the following error is logged:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.16.1:update (default-cli) on project test-liquibase: 
[ERROR] Error setting up or running Liquibase:
[ERROR] liquibase.exception.MigrationFailedException: Migration failed for changeset sql/1.0/00017-changes.xml::JailerExport::testuser:
[ERROR]      Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.11, 2019-04-26-15.47.11, 0, 2019-01-01-00.00.00, 0.24)' at line 1 [Failed SQL: (1064) INSERT INTO testdb.rates (id, created, modified, version, effective_date, rate) VALUES ('2', 2019-04-26-15.47.11, 2019-04-26-15.47.11, 0, 2019-01-01-00.00.00, 0.24)]

XML file generated via API:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="JailerExport" author="testuser">
<insert tableName="rates">
<column name="id" value="1"/>
<column name="created" valueDate="2019-04-26-15.47.11"/>
<column name="modified" valueDate="2019-04-26-15.47.11"/>
<column name="version" valueNumeric="0"/>
<column name="effective_date" valueDate="2019-01-01-00.00.00"/>
<column name="rate" valueNumeric="0.24"/>
</insert>
</changeSet>
</databaseChangeLog>

Expected Behavior

The insert will work if the "value" attribute is used instead of "valueDate": <column name="created" value="2019-04-26-15.47.11"/>

commented

Thanks for the issue report.

According to the documentation page:
https://docs.liquibase.com/change-types/nested-tags/column.html
Liquibase expects something like 'YYYY-MM-DDThh:mm:ss' as the value of a "valueDate" attribute.

This is not quite what Jailer generates. Could you please check if the following can be imported?

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="JailerExport" author="testuser">
<insert tableName="rates">
<column name="id" value="1"/>
<column name="created" valueDate="2019-04-26T15.47.11"/>
<column name="modified" valueDate="2019-04-26T15.47.11"/>
<column name="version" valueNumeric="0"/>
<column name="effective_date" valueDate="2019-01-01T00.00.00"/>
<column name="rate" valueNumeric="0.24"/>
</insert>
</changeSet>
</databaseChangeLog>

Thanks in advance,
Ralf

The following error is logged:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.16.1:update (default-cli) on project test-liquibase: 
[ERROR] Error setting up or running Liquibase:
[ERROR] liquibase.exception.MigrationFailedException: Migration failed for changeset sql/1.0/00017-changes.xml::JailerExport::testuser:
[ERROR]      Reason: liquibase.exception.DatabaseException: Unknown column '26T15.47.11' in 'field list' [Failed SQL: (1054) INSERT INTO testdb.rates (id, created, modified, version, effective_date, rate) VALUES ('1', 2019-04-26T15.47.11, 2019-04-26T15.47.11, 0, 2019-01-01T00.00.00, 0.24)]

This changeset is successful, though:

<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="JailerExport" author="testuser">
<insert tableName="rates">
<column name="id" value="1"/>
<column name="created" valueDate="2019-04-26T15:47:11"/>
<column name="modified" valueDate="2019-04-26T15:47:11"/>
<column name="version" valueNumeric="0"/>
<column name="effective_date" valueDate="2019-01-01T00:00:00"/>
<column name="rate" valueNumeric="0.24"/>
</insert>
</changeSet>
</databaseChangeLog>
commented

Where is the difference between the changeSet I asked you to test and this one?

The valueDate pattern you provided separates the time by . whereas the one that passed uses :.

commented

OMG, now I see that too. Please excuse my temporary blindness.

It's good that there is no need to fall back to "value" attribute. That would probably cause problems with other DBMS. Liquibase can obviously handle a date in the format it expects correctly.

I will correct this ASAP. I plan to release a new version at the end of the week. This issue will be fixed in the new version too.

commented

Fixed in Release 14.2