Browse Source

Merge pull request #7378 from cakephp/issue-7363

Handle postgres time without timezone correctly.
Mark Story 10 years ago
parent
commit
a2a381c6a7

+ 3 - 0
src/Database/Schema/PostgresSchema.php

@@ -85,6 +85,9 @@ class PostgresSchema extends BaseSchema
         if (strpos($col, 'timestamp') !== false) {
             return ['type' => 'timestamp', 'length' => null];
         }
+        if (strpos($col, 'time') !== false) {
+            return ['type' => 'time', 'length' => null];
+        }
         if ($col === 'serial' || $col === 'integer') {
             return ['type' => 'integer', 'length' => 10];
         }

+ 13 - 0
tests/TestCase/Database/Schema/PostgresSchemaTest.php

@@ -72,6 +72,7 @@ body TEXT,
 author_id INTEGER NOT NULL,
 published BOOLEAN DEFAULT false,
 views SMALLINT DEFAULT 0,
+readingtime TIME,
 created TIMESTAMP,
 CONSTRAINT "content_idx" UNIQUE ("title", "body"),
 CONSTRAINT "author_idx" FOREIGN KEY ("author_id") REFERENCES "schema_authors" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
@@ -108,6 +109,10 @@ SQL;
                 'TIME',
                 ['type' => 'time', 'length' => null]
             ],
+            [
+                'TIME WITHOUT TIME ZONE',
+                ['type' => 'time', 'length' => null]
+            ],
             // Integer
             [
                 'SMALLINT',
@@ -330,6 +335,14 @@ SQL;
                 'comment' => null,
                 'autoIncrement' => null,
             ],
+            'readingtime' => [
+                'type' => 'time',
+                'null' => true,
+                'default' => null,
+                'length' => null,
+                'precision' => null,
+                'comment' => null,
+            ],
             'created' => [
                 'type' => 'timestamp',
                 'null' => true,