liquibase loadData does not properly load numeric field in boolean always as false
Description
Environment
Linux (Mint, CentOS), Windows
Jdk 1.7 & Jdk 1.8
Target db : postgres (and all others)
Attachments
- 02 Jul 2014, 04:13 AM
Activity
Adrien SALES October 23, 2014 at 9:11 PM
Great news ! Thanks.
Nathan Voxland October 23, 2014 at 9:00 PM
Included in pull request https://github.com/liquibase/liquibase/pull/282
Adrien SALES July 3, 2014 at 6:35 AM
Commit (0817aa919fa76268b38a853e9f63c25a49cfa3b5) made on github, see
https://github.com/adriens/liquibase/commit/0817aa919fa76268b38a853e9f63c25a49cfa3b5
It propely solves this issue.
Adrien SALES July 3, 2014 at 4:57 AM
Provding test case (successfully run on patch on liquibase-3.2.1-SNAPSHOT and on liquibase-3.3.0-SNAPSHOT).
I'll make the pull request on liquibase-3.3.0-SNAPSHOT, maybe will Nathan want to merge it on 3.2.1-SNAPSHOT.
I. Resources
I.1 db.changelog.xml :
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<!-- Ensure test is run on postgresql -->
<preConditions>
<dbms type="postgresql" />
</preConditions>
<changeSet author="asales" id="test">
<createTable
remarks="test table"
tableName="test_boolean">
<column name="id" type="integer"/>
<column name="input" type="varchar(20)"/>
<column name="parsed" type="boolean"/>
<column name="expected" type="boolean"/>
</createTable>
</changeSet>
<changeSet id="load-boolean" author="asales">
<loadData tableName="test_boolean"
file="import.csv"
separator="," >
<column name="id" type="NUMERIC" />
<column name="input" type="STRING" />
<column name="parsed" type="BOOLEAN"/>
<column name="expected" type="BOOLEAN"/>
</loadData>
</changeSet>
</databaseChangeLog>
I.2 import.csv :
"id","input","parsed","expected"
"1","-1","-1","false"
"2"," 1"," -1","false"
"3","-1 ","-1 ","false"
"4","0","0","false"
"5"," 0"," 0","false"
"6","0 ","0 ","false"
"7","1","1","true"
"8"," 1"," 1","true"
"9","1 ","1 ","true"
"10","2","2","true"
"11","true","true","true"
"12"," true"," true","true"
"13","true ","true ","true"
"14","True","True","true"
"15"," True"," True","true"
"16","True ","True ","true"
"17","TRUE","TRUE","true"
"18"," TRUE"," TRUE","true"
"19","TRUE ","TRUE ","true"
"20","t","t","true"
"21"," t"," t","true"
"22","t ","t ","true"
"23","y","y","true"
"24"," y"," y","true"
"25","y ","y ","true"
"26","Y","Y","true"
"27"," Y"," Y","true"
"28","Y ","Y ","true"
"29","yes","yes","true"
"30"," yes"," yes","true"
"31","yes ","yes ","true"
"32","Yes","Yes","true"
"33"," Yes"," Yes","true"
"34","Yes ","Yes ","true"
"35","YES","YES","true"
"36"," YES "," YES","true"
"37","YES ","YES ","true"
"38","false","false","false"
"39"," false"," false","false"
"40","false ","false ","false"
"41","False","False","false"
"42"," False"," False","false"
"43","False ","False ","false"
"44","FALSE","FALSE","false"
"45"," FALSE"," FALSE","false"
"46","FALSE ","FALSE ","false"
"47","f","f","false"
"48"," f"," f","false"
"49","f ","f ","false"
"50","F","F","false"
"51"," F"," F","false"
"52","F ","F ","false"
"53","n","n","false"
"54"," n"," n","false"
"55","n ","n ","false"
"56","N","N","false"
"57"," N"," N","false"
"58","N ","N ","false"
"59","no","no","false"
"60"," no"," no","false"
"61","no ","no ","false"
"62","No","No","false"
"63"," No"," No","false"
"64","No ","No ","false"
"65","NO","NO","false"
"66"," NO"," NO","false"
"67","NO ","NO ","false"
"68"," any dummy text!"," any dummy text!","false"
II. Test
liquibase update
Then :
select * from test_boolean where parsed <> expected
returns :
id | input | parsed | expected
-------------------+----------
(0 rows)
and to get more details :
select * from test_boolean
returns :
id | input | parsed | expected
-----------------------------+----------
1 | -1 | f | f
2 | -1 | f | f
3 | -1 | f | f
4 | 0 | f | f
5 | 0 | f | f
6 | 0 | f | f
7 | 1 | t | t
8 | 1 | t | t
9 | 1 | t | t
10 | 2 | t | t
11 | true | t | t
12 | true | t | t
13 | true | t | t
14 | True | t | t
15 | True | t | t
16 | True | t | t
17 | TRUE | t | t
18 | TRUE | t | t
19 | TRUE | t | t
20 | t | t | t
21 | t | t | t
22 | t | t | t
23 | y | t | t
24 | y | t | t
25 | y | t | t
26 | Y | t | t
27 | Y | t | t
28 | Y | t | t
29 | yes | t | t
30 | yes | t | t
31 | yes | t | t
32 | Yes | t | t
33 | Yes | t | t
34 | Yes | t | t
35 | YES | t | t
36 | YES | t | t
37 | YES | t | t
38 | false | f | f
39 | false | f | f
40 | false | f | f
41 | False | f | f
42 | False | f | f
43 | False | f | f
44 | FALSE | f | f
45 | FALSE | f | f
46 | FALSE | f | f
47 | f | f | f
48 | f | f | f
49 | f | f | f
50 | F | f | f
51 | F | f | f
52 | F | f | f
53 | n | f | f
54 | n | f | f
55 | n | f | f
56 | N | f | f
57 | N | f | f
58 | N | f | f
59 | no | f | f
60 | no | f | f
61 | no | f | f
62 | No | f | f
63 | No | f | f
64 | No | f | f
65 | NO | f | f
66 | NO | f | f
67 | NO | f | f
68 | any dummy text! | f | f
68 rows)
Adrien SALES July 3, 2014 at 2:02 AM
I could make a first load, and it does now work as expected. I'm finishing some more tests and will perform a pull on github.
It will also fix CORE-1738.
When loading a csv (numeric, numerci) into a table (numeric, boolean) with a boolean, the boolean column is always set as false, for every row :
0 -> f
1 -> f
2 -> f
...
n -> f
whereas we would have expected this :
0 -> f
1 -> t
2 -> t
...
n -> t