From 941a2e576161b7c591ed855ec92fc480f1ff0013 Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 18 Jul 2007 19:31:43 +0000 Subject: [PATCH] --- lib/Doctrine/AuditLog.php | 7 ++++--- lib/Doctrine/Record.php | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Doctrine/AuditLog.php b/lib/Doctrine/AuditLog.php index 5044327a9..fbac82365 100644 --- a/lib/Doctrine/AuditLog.php +++ b/lib/Doctrine/AuditLog.php @@ -129,7 +129,7 @@ class Doctrine_AuditLog return $q->execute($values, Doctrine_HYDRATE::HYDRATE_ARRAY); } public function buildDefinition(Doctrine_Table $table) - { + { $this->_options['className'] = str_replace('%CLASS%', $this->_options['table']->getComponentName(), $this->_options['className']); @@ -143,6 +143,9 @@ class Doctrine_AuditLog } $columns = $table->getColumns(); + + // the version column should be part of the primary key definition + $columns[$this->_options['versionColumn']]['primary'] = true; $id = $table->getIdentifier(); @@ -150,8 +153,6 @@ class Doctrine_AuditLog $builder = new Doctrine_Import_Builder(); - $options['primary'][] = $this->_options['versionColumn']; - $def = $builder->buildDefinition($options, $columns); if ( ! $this->_options['generateFiles']) { diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 8b5a7e6df..cc2817827 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -1375,6 +1375,10 @@ abstract class Doctrine_Record extends Doctrine_Record_Abstract implements Count ->getAuditLog() ->getVersion($this, $version); + if ( ! isset($data[0])) { + throw new Doctrine_Record_Exception('Version ' . $version . ' does not exist!'); + } + $this->_data = $data[0]; } /**