Issues

Select view

Select search mode

 
50 of 68

CSV Load Data inferes wrong column types when specify a single column mapping

Description

Hi,

We have some loadData calls using some CSV's. In version 3.4.2 everything works fine, but since version 3.6.X, generateStatements method in class LoadDataChange works slightly different.

If we have a database table with the following columns ID, NAME, CREATION_DATE and we have the following line (this is just an example)

<loadData encoding="UTF-8" file="classpath:config/liquibase/data/v4.0.0/initial_data_my_table.csv" separator="," tableName="MY_TABLE"> <column name="CREATION_DATE" type="timestamp"/> </loadData>

Code reaches the following line:

if (columns.isEmpty()) { columns.addAll(getColumnsFromHeaders(headers)); }

In this example, columns is not empty, neither complete. So the only mapping is CREATION_DATE, trying to insert the ID field (number), as a string, and failing during the migration process

One solution could be completing mapping using default database mappings and giving a higher priority to the mappings defined in the file.

if (columns.isEmpty()) { columns.addAll(getColumnsFromHeaders(headers)); }else { completeColumnsEspecificationWithCsvDefinition(headers); }

Due to this issue, we cannot upgrade liquibase dependencies to latest versions

Thanks a lot fot your help!

Environment

liquibase 3.4.2
csv loaddata

Details

Reporter

Affects versions

Priority

Created August 6, 2019 at 8:50 AM
Updated November 30, 2020 at 3:52 PM

Activity

Show:

Gyula Bibernáth November 30, 2020 at 3:52 PM
Edited

I've run into the same problem and come to the same conclusion. Also implemented the fix for it, but the PR has not been merged yet

Bringer OfDawn August 3, 2020 at 8:48 AM

Hi again! any news about this?

Bringer OfDawn October 9, 2019 at 9:39 AM

Hi! Do you have any information regarding this issue?

 

Thanks a lot in advance