Skip to content

Commit 675b494

Browse files
authored
Merge pull request #805 from cakephp/fix-804
Add missing array cast in SqliteAdapter
2 parents 9cf0a3c + cf82111 commit 675b494

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/Db/Adapter/SqliteAdapter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@ public function createTable(Table $table, array $columns = [], array $indexes =
376376

377377
$sql = 'CREATE TABLE ';
378378
$sql .= $this->quoteTableName($table->getName()) . ' (';
379+
if (isset($options['primary_key'])) {
380+
$options['primary_key'] = (array)$options['primary_key'];
381+
}
382+
379383
foreach ($columns as $column) {
380384
$sql .= $this->quoteColumnName((string)$column->getName()) . ' ' . $this->getColumnSqlDefinition($column) . ', ';
381385

tests/TestCase/Db/Adapter/SqliteAdapterTest.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -360,17 +360,14 @@ public function testCreateTableWithoutAutoIncrementingPrimaryKeyAndWithForeignKe
360360

361361
public function testAddPrimaryKey()
362362
{
363-
$table = new Table('table1', ['id' => false], $this->adapter);
363+
$table = new Table('table1', [], $this->adapter);
364364
$table
365365
->addColumn('column1', 'integer')
366366
->addColumn('column2', 'integer')
367+
->addPrimaryKey('id')
367368
->save();
368369

369-
$table
370-
->changePrimaryKey('column1')
371-
->save();
372-
373-
$this->assertTrue($this->adapter->hasPrimaryKey('table1', ['column1']));
370+
$this->assertTrue($this->adapter->hasPrimaryKey('table1', ['id']));
374371
}
375372

376373
public function testChangePrimaryKey()

0 commit comments

Comments
 (0)