From 88289f071e5f3d4faaca2b7568884a776f5f1ae0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Thu, 21 Oct 2010 00:21:10 -0430 Subject: [PATCH] Restarting sequences by default qhen calling DboSource::truncate(), removing option to drop the sequence as it does not match behavior from other dbos --- cake/libs/model/datasources/dbo/dbo_postgres.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index 8a01a4d30..157f1d02e 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -308,20 +308,16 @@ class DboPostgres extends DboSource { * Deletes all the records in a table and drops all associated auto-increment sequences * * @param mixed $table A string or model class representing the table to be truncated - * @param integer $reset If -1, sequences are dropped, if 0 (default), sequences are reset, + * @param boolean $reset true for resseting the sequence, false to leave it as is. * and if 1, sequences are not modified * @return boolean SQL TRUNCATE TABLE statement, false if not applicable. */ - public function truncate($table, $reset = 0) { + public function truncate($table, $reset = true) { if (parent::truncate($table)) { $table = $this->fullTableName($table, false); - if (isset($this->_sequenceMap[$table]) && $reset !== 1) { + if (isset($this->_sequenceMap[$table]) && $reset) { foreach ($this->_sequenceMap[$table] as $field => $sequence) { - if ($reset === 0) { - $this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); - } elseif ($reset === -1) { - $this->_execute("DROP SEQUENCE IF EXISTS \"{$sequence}\""); - } + $this->_execute("ALTER SEQUENCE \"{$sequence}\" RESTART WITH 1"); } } return true;