New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
loadData inserts NULL when CSV contains function #1672
Comments
Hi @kdebski85 Thanks for the excellent writeup of this issue. We will add it to the list of issues to process. Along with #1091 which may help in conjunction with this one. |
It's still happening on 4.4.3. |
Hello all, I ended up with the same problem when I upgraded liquibase from 2.0.5 to 4.7.0. A workaround is to use usePreparedStatements="false" since #1091 has been fixed, but it's only a workaround. Is there any plan to fix this issue in the near future? |
Hi @LaurianeDPX Thanks for the update. I believe the current short term plan is to use usePreparedStatements=false as this is not a simple fix to move is back to how it worked in version v2. We can take another look to see what it would take to fix and keep existing functionality too. You can submit a PR as well. |
Hi, thanks for your answer. I continued my tests this morning and the weirdest thing happened (weirdest = I don't have an explanation for this, but maybe you do). I just changed the xsd of the databaseChangeLog XML tags from dbchangelog-2.0.xsd to dbchangelog-4.4.xsd, and it worked. The workaround with usePreparedStatements=false is not needed anymore. If you have an explanation for that behavior, I'd be happy to hear it. But as for this issue, it does not impact me anymore. |
We seem to be now attempting to load in the value you specified in the CSV file. In this case, it's not a valid datetime value. If you want to allow functions, you can use type="COMPUTED" and we'll pass it as a function, but then all values need to be a valid function or else a database-valid date string that is quoted in the csv file |
Environment
Liquibase Version: 4.2.1
Liquibase Integration & Version: SpringLiquibase 4.2.1
Liquibase Extension(s) & Version:
Database Vendor & Version: H2 1.4.200
Operating System Type & Version: Windows 10
Description
When CSV file used for loadData contains a function (for example "CURRENT_TIMESTAMP"), Liquibase tries to insert NULL for that column instead of using that function.
Steps To Reproduce
FOO table:
loadData changeset (failing):
foo.csv content:
Actual Behavior
Liquibase tries to insert NULL to "CHANGE_DATETIME" column which fails due to not-null constraint.
Expected/Desired Behavior
Liquibase should use "CURRENT_TIMESTAMP" in insert and the current timestamp should be inserted.
Additional Context
It worked fine in the old Liquibase version that I used (3.4.2).
As a workaround, a custom load data change can be used that disables prepared statements:
and then
META-INF/services/liquibase.change.Change
file must contain the qualified class name of CustomLoadDataChange.Please also note that disabling of prepared statements for given change with usePreparedStatements=false currently does not work due to #1091
Some issues that might be related:
https://liquibase.jira.com/browse/CORE-3208
https://liquibase.jira.com/browse/CORE-2976
Using different types in loadData instead of type="TIMESTAMP" does not help.
For type="STRING" the error is:
Cannot parse "TIMESTAMP" constant "CURRENT_TIMESTAMP"
For type="COMPUTED" the error is the same as for type="TIMESTAMP".
For details for CURRENT_TIMESTAMP function in H2 please see:
http://www.h2database.com/html/functions.html#current_timestamp
The text was updated successfully, but these errors were encountered: