Skip to content

Commit 12cd559

Browse files
committed
Fix up SqlServer
1 parent 35eb3e0 commit 12cd559

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/Db/Adapter/PostgresAdapter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
namespace Migrations\Db\Adapter;
1010

1111
use Cake\Database\Connection;
12+
use Cake\I18n\Date;
13+
use Cake\I18n\DateTime;
1214
use InvalidArgumentException;
1315
use Migrations\Db\AlterInstructions;
1416
use Migrations\Db\Literal;
@@ -1526,7 +1528,11 @@ public function bulkinsert(Table $table, array $rows): void
15261528
}
15271529
$values[] = $placeholder;
15281530
if ($placeholder == '?') {
1529-
if (is_bool($v)) {
1531+
if ($v instanceof DateTime) {
1532+
$vals[] = $v->toDateTimeString();
1533+
} elseif ($v instanceof Date) {
1534+
$vals[] = $v->toDateString();
1535+
} elseif (is_bool($v)) {
15301536
$vals[] = $this->castToBool($v);
15311537
} else {
15321538
$vals[] = $v;

src/Db/Adapter/SqlserverAdapter.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
namespace Migrations\Db\Adapter;
1010

1111
use BadMethodCallException;
12+
use Cake\I18n\Date;
13+
use Cake\I18n\DateTime;
1214
use InvalidArgumentException;
1315
use Migrations\Db\AlterInstructions;
1416
use Migrations\Db\Literal;
@@ -1361,7 +1363,11 @@ public function bulkinsert(TableMetadata $table, array $rows): void
13611363
$placeholder = (string)$v;
13621364
}
13631365
if ($placeholder == '?') {
1364-
if (is_bool($v)) {
1366+
if ($v instanceof DateTime) {
1367+
$vals[] = $v->toDateTimeString();
1368+
} elseif ($v instanceof Date) {
1369+
$vals[] = $v->toDateString();
1370+
} elseif (is_bool($v)) {
13651371
$vals[] = $this->castToBool($v);
13661372
} else {
13671373
$vals[] = $v;

0 commit comments

Comments
 (0)