Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

closes #5968, refs #5798, reverts [7893], when dependent is true, con…

…ditions are not respected on HABTM associations when deleting parent record. [7893] would result in orphaned records. If more fine grained control is needed, create a model for the join table and handle it on an application/applicaiton basis.

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7988 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information...
commit c53c28760f08731fc1bb7aa667accd2810322357 1 parent 7c87d36
gwoo authored
2  cake/libs/model/model.php
View
@@ -1759,7 +1759,7 @@ function _deleteLinks($id) {
foreach ($this->hasAndBelongsToMany as $assoc => $data) {
$records = $this->{$data['with']}->find('all', array(
- 'conditions' => array_merge(array($data['foreignKey'] => $id), (array) $data['conditions']),
+ 'conditions' => array_merge(array($this->{$data['with']}->escapeField($data['foreignKey']) => $id)),
'fields' => $this->{$data['with']}->primaryKey,
'recursive' => -1
));
9 cake/tests/cases/libs/model/model.test.php
View
@@ -3768,7 +3768,7 @@ function testCounterCacheIncrease() {
$result = $user[$User->alias]['post_count'];
$expected = 3;
$this->assertEqual($result, $expected);
-
+
}
/**
* Tests that counter caches are updated when records are deleted
@@ -6056,7 +6056,7 @@ function testGroupBy() {
if ($this->skipif($isStrictGroupBy, 'Postgresql and Oracle have strict GROUP BY and are incompatible with this test.')) {
return;
}
-
+
$this->loadFixtures('Project', 'Product', 'Thread', 'Message', 'Bid');
$Thread =& new Thread();
$Product =& new Product();
@@ -6370,10 +6370,7 @@ function testDeleteHabtmReferenceWithConditions() {
$this->assertFalse($result);
$result = $Portfolio->ItemsPortfolio->find('all', array('conditions' => array('ItemsPortfolio.portfolio_id' => 1)));
- $expected = array(
- array('ItemsPortfolio' => array('id' => 1, 'item_id' => 1, 'portfolio_id' => 1))
- );
- $this->assertEqual($result, $expected);
+ $this->assertFalse($result);
}
function testDeleteArticleBLinks() {
Please sign in to comment.
Something went wrong with that request. Please try again.