From 9dbeae0fa3ad66720a73dbf783bbdb0415de92ac Mon Sep 17 00:00:00 2001 From: mark_story Date: Thu, 6 Jun 2013 08:03:49 -0400 Subject: [PATCH] Code review comments. --- lib/Cake/Database/Schema/Collection.php | 3 +-- lib/Cake/Database/Schema/SqliteSchema.php | 4 +--- lib/Cake/Database/Schema/Table.php | 4 ++-- .../TestCase/Database/Schema/SqliteSchemaTest.php | 14 ++++++++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/lib/Cake/Database/Schema/Collection.php b/lib/Cake/Database/Schema/Collection.php index c8e4ada255f..fbe21a59660 100644 --- a/lib/Cake/Database/Schema/Collection.php +++ b/lib/Cake/Database/Schema/Collection.php @@ -119,8 +119,7 @@ public function describe($name) { */ protected function _executeSql($sql, $params) { try { - $statement = $this->_connection->execute($sql, $params); - return $statement; + return $this->_connection->execute($sql, $params); } catch (\PDOException $e) { throw new Exception($e->getMessage(), 500, $e); } diff --git a/lib/Cake/Database/Schema/SqliteSchema.php b/lib/Cake/Database/Schema/SqliteSchema.php index 7dd78ad7f6a..1c49a33c30f 100644 --- a/lib/Cake/Database/Schema/SqliteSchema.php +++ b/lib/Cake/Database/Schema/SqliteSchema.php @@ -231,9 +231,7 @@ protected function _convertOnClause($clause) { if ($clause === 'NO ACTION') { return 'none'; } - if ($clause === 'SET NULL') { - return null; - } + return null; } /** diff --git a/lib/Cake/Database/Schema/Table.php b/lib/Cake/Database/Schema/Table.php index 1f2cd1028fe..d350c848eef 100644 --- a/lib/Cake/Database/Schema/Table.php +++ b/lib/Cake/Database/Schema/Table.php @@ -93,8 +93,8 @@ class Table { 'columns' => [], 'length' => [], 'references' => [], - 'update' => 'cascade', - 'delete' => 'cascade', + 'update' => 'restrict', + 'delete' => 'restrict', ]; /** diff --git a/lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php b/lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php index e98f9e18e2d..8fd040a9b27 100644 --- a/lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php +++ b/lib/Cake/Test/TestCase/Database/Schema/SqliteSchemaTest.php @@ -477,25 +477,31 @@ public static function constraintSqlProvider() { 'author_id_idx', ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id']], 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' . - 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE CASCADE' + 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT' + ], + [ + 'author_id_idx', + ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'cascade'], + 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' . + 'REFERENCES "authors" ("id") ON UPDATE CASCADE ON DELETE RESTRICT' ], [ 'author_id_idx', ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'restrict'], 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' . - 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE CASCADE' + 'REFERENCES "authors" ("id") ON UPDATE RESTRICT ON DELETE RESTRICT' ], [ 'author_id_idx', ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => null], 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' . - 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE CASCADE' + 'REFERENCES "authors" ("id") ON UPDATE SET NULL ON DELETE RESTRICT' ], [ 'author_id_idx', ['type' => 'foreign', 'columns' => ['author_id'], 'references' => ['authors', 'id'], 'update' => 'none'], 'CONSTRAINT "author_id_idx" FOREIGN KEY ("author_id") ' . - 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE CASCADE' + 'REFERENCES "authors" ("id") ON UPDATE NO ACTION ON DELETE RESTRICT' ], ]; }