From 1ff9dedf60f6e2715faa581faf1a46657078a612 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Thu, 20 Mar 2014 13:29:36 +0400 Subject: [PATCH] Fixed getting default value from postgres schema --- framework/db/pgsql/Schema.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/framework/db/pgsql/Schema.php b/framework/db/pgsql/Schema.php index 92c1a4a..fb5322f 100644 --- a/framework/db/pgsql/Schema.php +++ b/framework/db/pgsql/Schema.php @@ -373,6 +373,12 @@ SQL; $table->sequenceName = preg_replace(['/nextval/', '/::/', '/regclass/', '/\'\)/', '/\(\'/'], '', $column->defaultValue); } } + + if ($column->defaultValue) { + if (preg_match("/^'(.*?)'::/", $column->defaultValue, $matches) || preg_match("/^(.*?)::/", $column->defaultValue, $matches)) { + $column->defaultValue = $matches[1]; + } + } } return true; @@ -398,7 +404,6 @@ SQL; $column->precision = $info['numeric_precision']; $column->scale = $info['numeric_scale']; $column->size = $info['size']; - if (isset($this->typeMap[$column->dbType])) { $column->type = $this->typeMap[$column->dbType]; } else { @@ -406,6 +411,7 @@ SQL; } $column->phpType = $this->getColumnPhpType($column); + return $column; } }