Skip to content

Commit

Permalink
Correctly reflect timestamp columns in postgres.
Browse files Browse the repository at this point in the history
While both datetime and timestamp turn into `TIMESTAMP` in postgres, the
reflection back from timestamp should be 'timestamp'. This makes fixture
files using the timestamp type more accurate.

Refs #3133
  • Loading branch information
markstory committed Apr 2, 2014
1 parent 211371d commit f006af5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Database/Schema/PostgresSchema.php
Expand Up @@ -81,7 +81,7 @@ protected function _convertColumn($column) {
return ['type' => $col, 'length' => null];
}
if (strpos($col, 'timestamp') !== false) {
return ['type' => 'datetime', 'length' => null];
return ['type' => 'timestamp', 'length' => null];
}
if ($col === 'serial' || $col === 'integer') {
return ['type' => 'integer', 'length' => 10];
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -33,7 +33,7 @@ class PostgresSchemaTest extends TestCase {
*/
protected function _needsConnection() {
$config = ConnectionManager::config('test');
$this->skipIf(strpos($config['className'], 'Postgres') === false, 'Not using Postgres for test config');
$this->skipIf(strpos($config['driver'], 'Postgres') === false, 'Not using Postgres for test config');
}

/**
Expand Down Expand Up @@ -87,11 +87,11 @@ public static function convertColumnProvider() {
// Timestamp
[
'TIMESTAMP',
['type' => 'datetime', 'length' => null]
['type' => 'timestamp', 'length' => null]
],
[
'TIMESTAMP WITHOUT TIME ZONE',
['type' => 'datetime', 'length' => null]
['type' => 'timestamp', 'length' => null]
],
// Date & time
[
Expand Down Expand Up @@ -307,7 +307,7 @@ public function testDescribeTable() {
'autoIncrement' => null,
],
'created' => [
'type' => 'datetime',
'type' => 'timestamp',
'null' => true,
'default' => null,
'length' => null,
Expand Down

0 comments on commit f006af5

Please sign in to comment.