-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
viaTable relation does not unlink same records which it selects #4932
Comments
Sorry for duplicates |
I write a test to verify this issue. but there seems to be no problem. The issue should close. |
// ActiveRecordTest.php
public function testUnlinkAllOnConditionViaTable()
{
/** @var Order $orderClass */
$orderClass = $this->getOrderClass();
/** @var Item $itemClass */
$itemClass = $this->getItemClass();
// Ensure there are three items with category_id = 2 in the Items table
$itemsCount = $itemClass::find()->where(['category_id' => 2])->count();
$this->assertEquals(3, $itemsCount);
$orderQuery = $orderClass::find()->with('limitedItems')->where(['id' => 2]);
// Ensure that limitedItems relation returns only one item
// (category_id = 2 and id in (4, 5))
$category = $orderQuery->one();
$this->assertCount(2, $category->limitedItems);
// Unlink all items in the limitedItems relation
$category->unlinkAll('limitedItems', true);
// Call $orderQuery again to ensure that links are removed
$this->assertCount(0, $orderQuery->one()->limitedItems);
// Make sure that only links were removed, the items were not removed
$this->assertEquals(3, $itemClass::find()->where(['category_id' => 2])->count());
} |
The test code has covered this issue. |
samdark
added
type:test
and removed
severity:normal
status:to be verified
Needs to be reproduced and validated.
type:bug
Bug
labels
Jun 10, 2020
Interesting. Thanks for doing that.
|
Seems it was fixed by #12213. Thanks, @undefinedor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi guys, I have relation 1:n via pivot table declared as
The select query which it makes is OK
But the delete query, produced when I am executing
is not OK
It does not contain the additional where clause, which is present in the SELECT query.
The text was updated successfully, but these errors were encountered: