Skip to content
Browse files

Changing Postgresql to use DELETE FROM instead of TRUNCATE.

This should improve compatibilty with databases using constraints.
Fixes #1838
  • Loading branch information...
markstory committed Jul 29, 2011
1 parent ecccfe9 commit e1960d1d35c9de0d85a03fcbf8f9b15c9c658bad
Showing with 1 addition and 1 deletion.
  1. +1 −1 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


This comment has been minimized.

Copy link

replied Jul 29, 2011

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


This comment has been minimized.

Copy link
Member Author

replied Jul 29, 2011

Interesting, the ticket was complaining that using truncate wasn't working with constraints. I didn't see any new failing tests related to sequences though.

Please sign in to comment.
You can’t perform that action at this time.