Skip to content

Commit

Permalink
Merge pull request #414 from othercorey/4.x-primarykey
Browse files Browse the repository at this point in the history
4.x - Updated calls to TableSchema::primaryKey() to getPrimaryKey()
  • Loading branch information
othercorey authored Dec 16, 2019
2 parents b010b0d + 55f539d commit 93d080e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/View/Helper/MigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public function columns($table)
$tableSchema = $this->schema($table);
}
$columns = [];
$tablePrimaryKeys = $tableSchema->primaryKey();
$tablePrimaryKeys = $tableSchema->getPrimaryKey();
foreach ($tableSchema->columns() as $column) {
if (in_array($column, $tablePrimaryKeys)) {
continue;
Expand Down Expand Up @@ -268,7 +268,7 @@ public function primaryKeys($table)
$tableSchema = $this->schema($table);
}
$primaryKeys = [];
$tablePrimaryKeys = $tableSchema->primaryKey();
$tablePrimaryKeys = $tableSchema->getPrimaryKey();
foreach ($tableSchema->columns() as $column) {
if (in_array($column, $tablePrimaryKeys)) {
$primaryKeys[] = ['name' => $column, 'info' => $this->column($tableSchema, $column)];
Expand All @@ -292,7 +292,7 @@ public function hasUnsignedPrimaryKey($tables)
if (!($table instanceof TableSchema)) {
$tableSchema = $this->schema($table);
}
$tablePrimaryKeys = $tableSchema->primaryKey();
$tablePrimaryKeys = $tableSchema->getPrimaryKey();

foreach ($tablePrimaryKeys as $primaryKey) {
$column = $tableSchema->getColumn($primaryKey);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/MigrationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function testMigrateAndRollback()
$columns = $numbersTable->getSchema()->columns();
$expected = ['id', 'number', 'radix'];
$this->assertEquals($columns, $expected);
$primaryKey = $numbersTable->getSchema()->primaryKey();
$primaryKey = $numbersTable->getSchema()->getPrimaryKey();
$this->assertEquals($primaryKey, ['id']);

$lettersTable = TableRegistry::get('Letters', ['connection' => $this->Connection]);
Expand All @@ -174,7 +174,7 @@ public function testMigrateAndRollback()
$this->assertEquals($expected, $columns);
$idColumn = $lettersTable->getSchema()->getColumn('id');
$this->assertEquals(true, $idColumn['autoIncrement']);
$primaryKey = $lettersTable->getSchema()->primaryKey();
$primaryKey = $lettersTable->getSchema()->getPrimaryKey();
$this->assertEquals($primaryKey, ['id']);

// Rollback last
Expand Down

0 comments on commit 93d080e

Please sign in to comment.