Merge #20082 - [Toon Export] Fix null separator
Pull-request: #20082 Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
commit
e76adf1911
@ -138,12 +138,7 @@ class ExportToon extends ExportPlugin
|
||||
$buffer .= str_repeat(' ', $this->indent);
|
||||
}
|
||||
|
||||
if ($col === null) {
|
||||
$buffer .= 'null';
|
||||
continue;
|
||||
}
|
||||
|
||||
$buffer .= $col;
|
||||
$buffer .= $col ?? 'null';
|
||||
|
||||
// phpcs:ignore SlevomatCodingStandard.ControlStructures.EarlyExit.EarlyExitNotUsed
|
||||
if ($index !== $columnsCnt - 1) {
|
||||
|
||||
@ -183,15 +183,19 @@ class ExportToonTest extends AbstractTestCase
|
||||
$exportToon->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
$exportToon->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
$exportToon->exportData(
|
||||
'test_db',
|
||||
'test_table_export_toon',
|
||||
'SELECT * FROM `test_db`.`test_table_export_toon`;',
|
||||
);
|
||||
$result = ob_get_clean();
|
||||
|
||||
self::assertIsString($result);
|
||||
self::assertSame(
|
||||
'test_db.test_table[3]{id,name,datetimefield}:' . "\n" .
|
||||
' 1,abcd,2011-01-20 02:00:02' . "\n" .
|
||||
' 2,foo,2010-01-20 02:00:02' . "\n" .
|
||||
' 3,Abcd,2012-01-20 02:00:02' . "\n\n",
|
||||
'test_db.test_table_export_toon[3]{id,name,datetimefield,textfield,intfield}:' . "\n" .
|
||||
' 1,abcd,2011-01-20 02:00:02,31,null' . "\n" .
|
||||
' 2,foo,2010-01-20 02:00:02,null,null' . "\n" .
|
||||
' 3,Abcd,2012-01-20 02:00:02,null,8' . "\n\n",
|
||||
$result,
|
||||
);
|
||||
}
|
||||
@ -205,15 +209,19 @@ class ExportToonTest extends AbstractTestCase
|
||||
$exportToon->setExportOptions($request, new Export());
|
||||
|
||||
ob_start();
|
||||
$exportToon->exportData('test_db', 'test_table', 'SELECT * FROM `test_db`.`test_table`;');
|
||||
$exportToon->exportData(
|
||||
'test_db',
|
||||
'test_table_export_toon',
|
||||
'SELECT * FROM `test_db`.`test_table_export_toon`;',
|
||||
);
|
||||
$result = ob_get_clean();
|
||||
|
||||
self::assertIsString($result);
|
||||
self::assertSame(
|
||||
'test_db.test_table[3|]{id|name|datetimefield}:' . "\n" .
|
||||
' 1|abcd|2011-01-20 02:00:02' . "\n" .
|
||||
' 2|foo|2010-01-20 02:00:02' . "\n" .
|
||||
' 3|Abcd|2012-01-20 02:00:02' . "\n\n",
|
||||
'test_db.test_table_export_toon[3|]{id|name|datetimefield|textfield|intfield}:' . "\n" .
|
||||
' 1|abcd|2011-01-20 02:00:02|31|null' . "\n" .
|
||||
' 2|foo|2010-01-20 02:00:02|null|null' . "\n" .
|
||||
' 3|Abcd|2012-01-20 02:00:02|null|8' . "\n\n",
|
||||
$result,
|
||||
);
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ use function trim;
|
||||
use const MYSQLI_TYPE_BLOB;
|
||||
use const MYSQLI_TYPE_DATETIME;
|
||||
use const MYSQLI_TYPE_DECIMAL;
|
||||
use const MYSQLI_TYPE_INT24;
|
||||
use const MYSQLI_TYPE_STRING;
|
||||
|
||||
// phpcs:disable Generic.Files.LineLength.TooLong
|
||||
@ -1730,6 +1731,22 @@ class DbiDummy implements DbiExtension
|
||||
['5', 'Abcd', '2012-01-20 02:00:02', '+30.2103210000'],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT * FROM `test_db`.`test_table_export_toon`;',
|
||||
'columns' => ['id', 'name', 'datetimefield', 'textfield', 'intfield'],
|
||||
'metadata' => [
|
||||
FieldHelper::fromArray(['type' => MYSQLI_TYPE_DECIMAL]),
|
||||
FieldHelper::fromArray(['type' => MYSQLI_TYPE_STRING]),
|
||||
FieldHelper::fromArray(['type' => MYSQLI_TYPE_DATETIME]),
|
||||
FieldHelper::fromArray(['type' => MYSQLI_TYPE_STRING]),
|
||||
FieldHelper::fromArray(['type' => MYSQLI_TYPE_INT24]),
|
||||
],
|
||||
'result' => [
|
||||
['1', 'abcd', '2011-01-20 02:00:02',31,null],
|
||||
['2', 'foo', '2010-01-20 02:00:02',null,null],
|
||||
['3', 'Abcd', '2012-01-20 02:00:02',null,8],
|
||||
],
|
||||
],
|
||||
[
|
||||
'query' => 'SELECT * FROM `test_db`.`test_table`;',
|
||||
'columns' => ['id', 'name', 'datetimefield'],
|
||||
|
||||
Loading…
Reference in New Issue
Block a user