Skip to content

Commit

Permalink
Fix issue #11916
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Vorsin committed Apr 10, 2018
1 parent ba859e2 commit ab6c4b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Database/Schema/PostgresSchema.php
Expand Up @@ -196,6 +196,10 @@ protected function _defaultValue($default)
return null;
}

if (strpos($default, 'NULL::') === 0) {
return null;
}

// Remove quotes and postgres casts
return preg_replace(
"/^'(.*)'(?:::.*)$/",
Expand Down
8 changes: 8 additions & 0 deletions tests/TestCase/Database/Schema/PostgresSchemaTest.php
Expand Up @@ -143,6 +143,10 @@ public static function convertColumnProvider()
['type' => 'NUMERIC'],
['type' => 'decimal', 'length' => null, 'precision' => null]
],
[
['type' => 'NUMERIC', 'default' => 'NULL::numeric'],
['type' => 'decimal', 'length' => null, 'precision' => null, 'default' => null]
],
[
['type' => 'DECIMAL(10,2)', 'column_precision' => 10, 'column_scale' => 2],
['type' => 'decimal', 'length' => 10, 'precision' => 2]
Expand All @@ -164,6 +168,10 @@ public static function convertColumnProvider()
['type' => 'CHARACTER VARYING(10)'],
['type' => 'string', 'length' => 10]
],
[
['type' => 'CHARACTER VARYING(255)', 'default' => 'NULL::character varying'],
['type' => 'string', 'length' => 255, 'default' => null]
],
[
['type' => 'CHAR(10)'],
['type' => 'string', 'fixed' => true, 'length' => 10]
Expand Down

0 comments on commit ab6c4b9

Please sign in to comment.