Skip to content
This repository was archived by the owner on Mar 12, 2020. It is now read-only.

Commit 4b90f7a

Browse files
author
Eric Meyer
committed
Fixes Data Tool Outputs Empty Strings: If a column returns an empty string, the data tool still outputs the column value. Empty strings should not be output. This bloats the XML.
http://transparensee.jira.com/browse/DATATOOL-32
1 parent 59fe535 commit 4b90f7a

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

src/main/java/com/t11e/discovery/datatool/CreateActionRowCallbackHandler.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ else if (StringUtils.isBlank(subquery.getProperty()))
184184
{
185185
final String propertyPrefix = StringUtils.isNotBlank(subquery.getPropertyPrefix()) ? subquery.getPropertyPrefix() : "";
186186
if (values.size() == 1)
187-
188187
{
189188
final Map<String, Object> row = values.get(0);
190189
for (final Entry<String, Object> entry : row.entrySet())
@@ -380,7 +379,11 @@ private SubqueryRowCallbackHandler(final List<Map<String, Object>> values, final
380379
public void processRow(final ResultSet rs)
381380
throws SQLException
382381
{
383-
values.add(convertor.getRowAsMap(rs));
382+
final Map<String, Object> row = convertor.getRowAsMap(rs);
383+
if (!row.isEmpty())
384+
{
385+
values.add(row);
386+
}
384387
}
385388
}
386389
}

src/main/java/com/t11e/discovery/datatool/column/StringColumnProcessor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import java.sql.ResultSet;
44
import java.sql.SQLException;
55

6+
import org.apache.commons.lang.StringUtils;
7+
68
public class StringColumnProcessor
79
implements IColumnProcessor
810
{
@@ -20,7 +22,7 @@ public String processColumn(final ResultSet rs, final int column)
2022
}
2123
else
2224
{
23-
value = value.trim();
25+
value = StringUtils.trimToNull(value);
2426
}
2527
return value;
2628
}

src/test/java/com/t11e/discovery/datatool/SqlChangesetExtractorTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ public void testStringColumns()
107107
CollectionsFactory.<String, String> makeMap());
108108
oneOf(writer).setItem(
109109
"2",
110-
CollectionsFactory.<String, String> makeMap(
111-
"col_fixed", "",
112-
"col_string", "",
113-
"col_clob", ""));
110+
CollectionsFactory.<String, String> makeMap());
114111
oneOf(writer).setItem(
115112
"3",
116113
CollectionsFactory.<String, String> makeMap(

src/test/java/com/t11e/discovery/datatool/SubqueryTestCreate.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ create table SubqueryColors (
2626

2727
insert into SubqueryColors (parent_id, name, asnumber, asdate) values
2828
(1, 'red', 10, '2011-01-01-00.00.00.000000'),
29+
(1, '', null, null),
30+
(1, null, null, null),
2931
(2, 'orange', 20, '2011-01-02-00.00.00.000000'),
3032
(2, 'yellow', 30, '2011-01-03-00.00.00.000000');
3133

src/test/java/com/t11e/discovery/datatool/VerticalTableTestCreate.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ create table vertical_data (
2323

2424
insert into vertical_data (id, name, value) values
2525
(1, 'color', 'red'),
26+
(1, 'color', ''),
27+
(1, 'color', null),
2628
(1, 'provider', 'p1'),
2729
(1, 'kind', 'k1'),
2830
(2, 'color', 'orange'),

0 commit comments

Comments
 (0)