-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
SoftDelete::runSoftDelete does not take into account overridden Model::setKeysForSaveQuery #28022
Comments
Why would |
@driesvints it was mistype. Corrected. |
Heh, I'm not sure that |
Yes you can overwrite Please see below
|
The question is if this has side effects. @staudenmeir do you maybe see any from the changes above? |
I agree that this should be changed. We should also use An example where the current behavior is incorrect: $user = User::find(1);
$user->id = 2;
$user->delete(); This works without |
So should I create new pull request ? And update both SoftDeletes::performDeleteOnModel() and SoftDelete::runSoftDelete ? |
Yes, please create a PR. |
@staudenmeir thanks for verifying! :) |
PR was merged. |
Description:
SoftDelete::runSoftDelete does not take into account overridden Model::setKeysForSaveQuery method.
I use this for multi-tenancy purposes. Or for use composite primary keys.
Model:
When running below code:
Expected query:
UPDATE shop SET deleted_at = ?, Shop.updated_at = ? WHERE shop_id = ? AND user_id = ?
Actual query:
UPDATE shop SET deleted_at = ?, SHOP.updated_at = ? WHERE shop_id = ?
Solution is to replace below line
To
$query = $this->setKeysForSaveQuery($this->newModelQuery());
The text was updated successfully, but these errors were encountered: