From 562a48769c6625703de64872733aac6b10d43635 Mon Sep 17 00:00:00 2001 From: "Jonathan.Wage" Date: Tue, 27 Nov 2007 03:36:40 +0000 Subject: [PATCH] fixes #568 --- lib/Doctrine/Import/Pgsql.php | 12 +++++++++++- lib/Doctrine/Import/Schema.php | 1 + lib/Doctrine/Record.php | 6 +++++- lib/Doctrine/Record/Abstract.php | 4 ++-- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/Doctrine/Import/Pgsql.php b/lib/Doctrine/Import/Pgsql.php index ef25b1e38..10474cf9c 100644 --- a/lib/Doctrine/Import/Pgsql.php +++ b/lib/Doctrine/Import/Pgsql.php @@ -175,12 +175,22 @@ class Doctrine_Import_Pgsql extends Doctrine_Import 'length' => $decl['length'], 'fixed' => $decl['fixed'], 'unsigned' => $decl['unsigned'], - 'notnull' => ($val['isnotnull'] == ''), + 'notnull' => ($val['isnotnull'] == true), 'default' => $val['default'], 'primary' => ($val['pri'] == 't'), ); + + $matches = array(); + + if (preg_match("/^nextval\('(.*)'(::.*)?\)$/", $description['default'], $matches)) { + + $description['sequence'] = $this->conn->formatter->fixSequenceName($matches[1]); + $description['default'] = null; + } + $columns[$val['field']] = $description; } + return $columns; } diff --git a/lib/Doctrine/Import/Schema.php b/lib/Doctrine/Import/Schema.php index 98a810b5d..a621b27df 100644 --- a/lib/Doctrine/Import/Schema.php +++ b/lib/Doctrine/Import/Schema.php @@ -332,6 +332,7 @@ class Doctrine_Import_Schema $colDesc['default'] = isset($field['default']) ? $field['default']:null; $colDesc['autoincrement'] = isset($field['autoincrement']) ? (bool) (isset($field['autoincrement']) && $field['autoincrement']):null; $colDesc['autoincrement'] = isset($field['autoinc']) ? (bool) (isset($field['autoinc']) && $field['autoinc']):$colDesc['autoincrement']; + $colDesc['sequence'] = isset($field['sequence']) ? (string) $field['sequence']:null; $colDesc['values'] = isset($field['values']) ? (array) $field['values']:null; $validators = Doctrine::getValidators(); diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 25efd86a4..2ed076bed 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1294,8 +1294,12 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count * * @return Doctrine_Record */ - public function copy() + public function copy($deep = false) { + if ($deep) { + return $this->copyDeep(); + } + $data = $this->_data; if ($this->_table->getIdentifierType() === Doctrine::IDENTIFIER_AUTOINC) { diff --git a/lib/Doctrine/Record/Abstract.php b/lib/Doctrine/Record/Abstract.php index 737e69b23..0e799d7a0 100644 --- a/lib/Doctrine/Record/Abstract.php +++ b/lib/Doctrine/Record/Abstract.php @@ -293,7 +293,6 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access */ public function actAs($tpl, array $options = array()) { - if ( ! is_object($tpl)) { if (class_exists($tpl, true)) { $tpl = new $tpl($options); @@ -312,8 +311,9 @@ abstract class Doctrine_Record_Abstract extends Doctrine_Access if ( ! ($tpl instanceof Doctrine_Template)) { throw new Doctrine_Record_Exception('Loaded plugin class is not an istance of Doctrine_Template.'); } + $className = get_class($tpl); - + $this->_table->addTemplate($className, $tpl); $tpl->setTable($this->_table);