Skip to content

Commit 795cd93

Browse files
author
Malte Riesch
committed
bug fix: columns with only zeros 0 did not get included in parser
1 parent beabe4b commit 795cd93

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/TestDbAcle/Psv/PsvParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ protected function psvToArray($psvContent)
145145

146146
protected function skipRow($row){
147147
$trimmedRow = ltrim($row);
148-
return !$trimmedRow || $trimmedRow[0] == static::SYMBOL_COMMENT;
148+
return $trimmedRow == '' || $trimmedRow[0] == static::SYMBOL_COMMENT;
149149
}
150150

151151
protected function splitByPipe($row){

tests/TestDbAcle/Psv/PsvParserTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,36 @@ function test_parsePsvTree() {
228228

229229
}
230230

231+
232+
function test_parsePsvTree_withOneColumnOfZeros() {
233+
$psvParser = new \TestDbAcle\Psv\PsvParser();
234+
235+
$psvToParse = "
236+
237+
[ expression2]
238+
col1
239+
0
240+
0
241+
";
242+
243+
$parsedTree = $psvParser->parsePsvTree($psvToParse);
244+
245+
246+
247+
248+
$this->assertEquals(array (
249+
'expression2' =>
250+
array (
251+
0 =>
252+
array (
253+
'col1' => '0',
254+
),
255+
1 =>
256+
array (
257+
'col1' => '0',
258+
),
259+
),
260+
), $parsedTree->toArray());
261+
262+
}
231263
}

0 commit comments

Comments
 (0)