mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-17 20:50:44 +00:00
CE-1955 Make sure to skip blank rows (e.g., no columns had a value)
This commit is contained in:
@ -62,12 +62,22 @@ public class FlatRowsToRecord implements RowsToRecordInterface
|
||||
QRecord record = new QRecord();
|
||||
BulkLoadRecordUtils.addBackendDetailsAboutFileRows(record, row);
|
||||
|
||||
boolean anyValuesFromFileUsed = false;
|
||||
for(QFieldMetaData field : table.getFields().values())
|
||||
{
|
||||
setValueOrDefault(record, field, null, mapping, row, fieldIndexes.get(field.getName()));
|
||||
if(setValueOrDefault(record, field, null, mapping, row, fieldIndexes.get(field.getName())))
|
||||
{
|
||||
anyValuesFromFileUsed = true;
|
||||
}
|
||||
}
|
||||
|
||||
rs.add(record);
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// avoid building empty records (e.g., "past the end" of an Excel file) //
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
if(anyValuesFromFileUsed)
|
||||
{
|
||||
rs.add(record);
|
||||
}
|
||||
}
|
||||
|
||||
BulkLoadValueMapper.valueMapping(rs, mapping, table);
|
||||
|
@ -56,7 +56,8 @@ class FlatRowsToRecordTest extends BaseTest
|
||||
new Serializable[] { 1, "Homer", "Simpson", true, "three fifty" },
|
||||
new Serializable[] { 2, "Marge", "Simpson", false, "" },
|
||||
new Serializable[] { 3, "Bart", "Simpson", "A", "99.95" },
|
||||
new Serializable[] { 4, "Ned", "Flanders", 3.1, "one$" }
|
||||
new Serializable[] { 4, "Ned", "Flanders", 3.1, "one$" },
|
||||
new Serializable[] { "", "", "", "", "" } // all blank row (we can get these at the bottoms of files) - make sure it doesn't become a record.
|
||||
));
|
||||
|
||||
BulkLoadFileRow header = fileToRows.next();
|
||||
|
Reference in New Issue
Block a user