Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 0c7856b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/ORM/Association/DependentDeleteHelper.php
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/ORM/Association/HasManyTest.php
Expand Up @@ -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']);
Expand Down

0 comments on commit 0c7856b

Please sign in to comment.