Skip to content

Commit c0aabf3

Browse files
committed
Fix test issues
1 parent 25bb9a8 commit c0aabf3

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

src/DMLQueryBuilder.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,12 @@ public function batchInsert(string $table, array $columns, iterable $rows, array
5050
$columns,
5151
);
5252

53-
$tableAndColumns .= ' (' . implode(', ', $quotedColumnNames) . ') VALUES ';
53+
$tableAndColumns .= ' (' . implode(', ', $quotedColumnNames) . ')';
5454
}
5555

56-
return 'INSERT ALL ' . $tableAndColumns . implode($tableAndColumns, $values) . ' SELECT 1 FROM SYS.DUAL';
56+
$tableAndColumns .= ' VALUES ';
57+
58+
return 'INSERT ALL' . $tableAndColumns . implode($tableAndColumns, $values) . ' SELECT 1 FROM SYS.DUAL';
5759
}
5860

5961
/**

tests/Provider/CommandProvider.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function batchInsert(): array
2525
$batchInsert = parent::batchInsert();
2626

2727
$batchInsert['multirow']['expected'] = <<<SQL
28-
INSERT ALL INTO "type" ("int_col", "float_col", "char_col", "bool_col") VALUES (:qp0, :qp1, :qp2, :qp3) INTO "type" ("int_col", "float_col", "char_col", "bool_col") VALUES (:qp4, :qp5, :qp6, :qp7) SELECT 1 FROM SYS.DUAL
28+
INSERT ALL INTO "type" ("int_col", "float_col", "char_col", "bool_col") VALUES (:qp0, :qp1, :qp2, :qp3) INTO "type" ("int_col", "float_col", "char_col", "bool_col") VALUES (:qp4, :qp5, :qp6, :qp7) SELECT 1 FROM SYS.DUAL
2929
SQL;
3030
$batchInsert['multirow']['expectedParams'][':qp3'] = '1';
3131
$batchInsert['multirow']['expectedParams'][':qp7'] = '0';
@@ -55,6 +55,18 @@ public static function batchInsert(): array
5555
'with shuffled indexes of values' => [
5656
':qp0' => '1',
5757
],
58+
'empty columns and associative values' => [
59+
':qp3' => '1',
60+
],
61+
'empty columns and objects' => [
62+
':qp3' => '1',
63+
],
64+
'empty columns and Traversable' => [
65+
':qp3' => '1',
66+
],
67+
'empty columns and indexed values' => [
68+
':qp3' => '1',
69+
],
5870
];
5971

6072
foreach ($replaceParams as $key => $expectedParams) {

tests/Provider/QueryBuilderProvider.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ public static function batchInsert(): array
5151
DbHelper::changeSqlForOracleBatchInsert($batchInsert['bool-false, bool2-null']['expected']);
5252

5353
$batchInsert['wrong']['expected'] = <<<SQL
54-
INSERT ALL INTO {{%type}} ("float_col", "time") VALUES (:qp0, now()) INTO {{%type}} ("float_col", "time") VALUES (:qp1, now()) SELECT 1 FROM SYS.DUAL
54+
INSERT ALL INTO {{%type}} ("float_col", "time") VALUES (:qp0, now()) INTO {{%type}} ("float_col", "time") VALUES (:qp1, now()) SELECT 1 FROM SYS.DUAL
5555
SQL;
5656

5757
DbHelper::changeSqlForOracleBatchInsert($batchInsert['bool-false, time-now()']['expected']);
5858
DbHelper::changeSqlForOracleBatchInsert($batchInsert['column table names are not checked']['expected']);
59+
DbHelper::changeSqlForOracleBatchInsert($batchInsert['empty columns and non-exists table']['expected']);
5960

6061
$batchInsert['bool-false, bool2-null']['expectedParams'][':qp0'] = '0';
6162
$batchInsert['bool-false, time-now()']['expectedParams'][':qp0'] = '0';

tests/Support/Fixture/oci.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,19 @@ CREATE TABLE "type" (
165165
"int_col" integer NOT NULL,
166166
"float_col" double precision NOT NULL,
167167
"char_col" char(100) NOT NULL,
168-
"blob_col" blob DEFAULT NULL,
168+
"bool_col" char NOT NULL check ("bool_col" in (0,1)),
169169
"int_col2" integer DEFAULT 1,
170170
"tinyint_col" number(3) DEFAULT 1,
171171
"smallint_col" smallint DEFAULT 1,
172172
"char_col2" varchar2(100) DEFAULT 'some''thing',
173173
"char_col3" varchar2(4000),
174174
"nvarchar_col" nvarchar2(100) DEFAULT '',
175175
"float_col2" double precision DEFAULT 1.23,
176+
"blob_col" blob DEFAULT NULL,
176177
"numeric_col" decimal(5,2) DEFAULT 33.22,
177178
"timestamp_col" timestamp DEFAULT to_timestamp('2002-01-01 00:00:00', 'yyyy-mm-dd hh24:mi:ss') NOT NULL,
178179
"time_col" interval day (0) to second(0) DEFAULT INTERVAL '0 10:33:21' DAY(0) TO SECOND(0),
179180
"interval_day_col" interval day (1) to second(0) DEFAULT INTERVAL '2 04:56:12' DAY(1) TO SECOND(0),
180-
"bool_col" char NOT NULL check ("bool_col" in (0,1)),
181181
"bool_col2" char DEFAULT 1 check("bool_col2" in (0,1)),
182182
"ts_default" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL,
183183
"bit_col" number(3) DEFAULT 130 NOT NULL

0 commit comments

Comments
 (0)