From c2c17f9b906b6553b75b45b7138dc6e48d7a1f93 Mon Sep 17 00:00:00 2001 From: nate Date: Wed, 21 Mar 2007 05:00:54 +0000 Subject: [PATCH] Fixing MySQL schema generation for null columns git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4637 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/model/datasources/dbo/dbo_mysql.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_mysql.php b/cake/libs/model/datasources/dbo/dbo_mysql.php index 1938bf9f3..494440bd7 100644 --- a/cake/libs/model/datasources/dbo/dbo_mysql.php +++ b/cake/libs/model/datasources/dbo/dbo_mysql.php @@ -527,9 +527,11 @@ class DboMysql extends DboSource { $real = $this->columns[$type]; $out = $this->name($name) . ' ' . $real['name']; - if (isset($real['limit']) || isset($real['length'])) { - if (isset($col['length'])) { - $length = $col['length']; + if (isset($real['limit']) || isset($real['length']) || isset($column['limit']) || isset($column['length'])) { + if (isset($column['length'])) { + $length = $column['length']; + } elseif (isset($column['limit'])) { + $length = $column['limit']; } elseif (isset($real['length'])) { $length = $real['length']; } else { @@ -546,6 +548,8 @@ class DboMysql extends DboSource { $out .= ' DEFAULT NULL'; } elseif (isset($column['default']) && isset($column['null']) && $column['null'] == false) { $out .= ' DEFAULT ' . $this->value($column['default'], $type) . ' NOT NULL'; + } elseif (isset($column['null']) && $column['null'] == false) { + $out .= ' NOT NULL'; } return $out; }