Skip to content
Permalink
Browse files

Alias fields when finding dependent records to delete.

Prevent ambiguous column issues by aliasing fields used in conditions.

Refs #11170
  • Loading branch information...
markstory committed Sep 14, 2017
1 parent 8262b4d commit 0c7856b43779ab99c8410eee22247e15022b82d0
Showing with 2 additions and 2 deletions.
  1. +1 −1 src/ORM/Association/DependentDeleteHelper.php
  2. +1 −1 tests/TestCase/ORM/Association/HasManyTest.php
@@ -41,7 +41,7 @@ public function cascadeDelete(Association $association, EntityInterface $entity,
return true;
}
$table = $association->getTarget();
$foreignKey = (array)$association->getForeignKey();
$foreignKey = array_map([$association, 'aliasField'], (array)$association->getForeignKey());
$bindingKey = (array)$association->getBindingKey();
$conditions = array_combine($foreignKey, $entity->extract($bindingKey));
@@ -461,7 +461,7 @@ public function testCascadeDelete()
->method('deleteAll')
->with([
'Articles.is_active' => true,
'author_id' => 1
'Articles.author_id' => 1
]);
$entity = new Entity(['id' => 1, 'name' => 'PHP']);

0 comments on commit 0c7856b

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