We're updating the issue view to help you get more done. 

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)

1 2 3 4 5 6 7 8 9 <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:

1 2 3 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.

1 2 3 4 5 6 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

Status

Assignee

Unassigned

Reporter

Bringer OfDawn

Labels

None

Affects versions

3.6.0
3.6.2
3.6.3
3.6.1

Priority

Major