Permalink
Browse files

Changing Postgresql to use DELETE FROM instead of TRUNCATE.

This should improve compatibilty with databases using constraints.
Fixes #1838
  • Loading branch information...
1 parent ecccfe9 commit e1960d1d35c9de0d85a03fcbf8f9b15c9c658bad @markstory markstory committed Jul 29, 2011
Showing with 1 addition and 1 deletion.
  1. +1 −1 cake/libs/model/datasources/dbo/dbo_postgres.php
View
2 cake/libs/model/datasources/dbo/dbo_postgres.php
@@ -403,7 +403,7 @@ function getSequence($table, $field = 'id') {
* @access public
*/
function truncate($table, $reset = 0) {
- if (parent::truncate($table)) {
+ if ($this->execute('DELETE FROM ' . $this->fullTableName($table))) {
$table = $this->fullTableName($table, false);
if (isset($this->_sequenceMap[$table]) && $reset !== 1) {
foreach ($this->_sequenceMap[$table] as $field => $sequence) {

2 comments on commit e1960d1

@lorenzo
CakePHP member

Well, there is a reason for using truncate and it's that it will also reset the associated sequences. I wonder if this broke some tests internally in the core

@markstory
CakePHP member

Interesting, the ticket was complaining that using truncate wasn't working with constraints. http://cakephp.lighthouseapp.com/projects/42648/tickets/1838 I didn't see any new failing tests related to sequences though.

Please sign in to comment.