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.

loadData fails to insert data when usePreparedStatements=true

See original GitHub issue

Environment

Liquibase Version: 4.2.0 (also reproducible in 4.1.1)

Liquibase Integration & Version: spring boot, but is reproducible by cli (see below)

Liquibase Extension(s) & Version:

Database Vendor & Version: postgres:10.7

Operating System Type & Version:

Description

loadData change type fails to insert data when usePreparedStatements=true. The update operation completes without any error.

Steps To Reproduce

I have tried to simplify the steps to reproduce using cli instead of spring boot integration.

  • Database Setup (if not already available) Execute the following to run a temporary postgres docker:
docker run -it -e POSTGRES_PASSWORD=password postgres:10.7-alpine
  • A csv file to load data from: app_user.csv with the following content:
"id","name"
"1","John"
"2","Doe"
  • A changelog.xml with the following changesets:
    <changeSet id="1-createTable" author="neupsh">
      <createTable tableName="app_user">
          <column name="id" type="int"/>
          <column name="name" type="varchar(255)"/>
      </createTable>
    </changeSet>

    <changeSet id="2-loadData" author="neupsh">

        <loadData commentLineStartsWith="#" encoding="UTF-8" file="app_user.csv" quotchar="&quot;" relativeToChangelogFile="true" separator="," tableName="app_user" usePreparedStatements="true">
            <column header="id" name="id" type="NUMERIC"/>
            <column header="name" name="name" type="STRING"/>
        </loadData>
    </changeSet>
  • correct liquibase.properties pointing to the postgres db listed above
  • run liquibase update

Actual Behavior

  • Liquibase update is successful
  • app_user table is created
  • app_user table is empty
  • databasechangelog table has both changesets executed

Expected/Desired Behavior

  • Liquibase update is successful
  • app_user table is created
  • app_user table is populated with the contents from csv file
  • databasechangelog table has both changesets executed

If I change the usePreparedStatements="true" to usePreparedStatements="false" in the loadData changesets, the data is populated correctly. I have attached the sample project to reproduce. Please modify the drivers location to execute it. postgres.zip

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

1reaction
vmarcinkocommented, Jan 30, 2022

We also experienced the same with Liquibase 4.7.1 and MySQL and mysql-connector-java JDBC driver 8.0.25. Everything works well when usePreparedStatements=“false”

0reactions
FBurguercommented, Oct 7, 2022

Look like it got fixed for liquibase 4.16.1. Im closing this issue, but if the issue continues to happen to you, please reopen the issue and let us know. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Load data local infile not inserting into database
Login to your SSH prompt. Then type # mysql -u admin -p`cat /etc/psa/.psa.shadow`; mysql>LOAD DATA LOCAL INFILE 'File.csv' INTO TABLE table FIELDS ...
Read more >
loadData | Liquibase Docs
Loads data from a CSV file into an existing table when you add it to your changelog. Uses. A value of NULL in...
Read more >
LOAD DATA INFILE vs. INSERT in MySQL: Why, How, When?
This article will demonstrate the differences between LOAD DATA INFILE and INSERT and explain when you should use both for data entry in...
Read more >
MySQL 8.0 Reference Manual :: 13.2.9 LOAD DATA Statement
LOAD DATA supports explicit partition selection using the PARTITION clause with a list of one or more comma-separated names of partitions, subpartitions, or ......
Read more >
SaveData, LoadData, and ClearData functions in Power Apps
Caching data in the App.OnStart formula on a first run. Reloading the local cache on next runs. You can also use these functions...
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