You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You receive an error that the updated_at field is ambiguous while running a delete() function on a hasManyThrough relationship having softDelete.
Steps To Reproduce:
Create a hasManyThrough relationship on a model. For eg.
Make a function in the model User.php
public function commuteDistances() {
return $this->hasManyThrough('App\Models\CommuteDistance','App\UserPropertyListing','user_id','user_property_listing_id','id');
}
Try running
$user->commuteDistances()->delete();
The query generated is
update commute_distances inner join user_property_listings on user_property_listings.id = commute_distances.user_property_listing_id set commute_distances.deleted_at = 2016-10-07 15:33:41, updated_at = 2016-10-07 15:33:41 where commute_distances.deleted_at is null and user_property_listings.deleted_at is null and user_property_listings.user_id = 3
Error
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'updated_at' in field list is ambiguous
The text was updated successfully, but these errors were encountered:
Mysql
Description:
You receive an error that the updated_at field is ambiguous while running a delete() function on a hasManyThrough relationship having softDelete.
Steps To Reproduce:
Create a hasManyThrough relationship on a model. For eg.
Make a function in the model User.php
public function commuteDistances() {
return $this->hasManyThrough('App\Models\CommuteDistance','App\UserPropertyListing','user_id','user_property_listing_id','id');
}
Try running
$user->commuteDistances()->delete();
The query generated is
update
commute_distances
inner joinuser_property_listings
onuser_property_listings
.id
=commute_distances
.user_property_listing_id
setcommute_distances
.deleted_at
= 2016-10-07 15:33:41,updated_at
= 2016-10-07 15:33:41 wherecommute_distances
.deleted_at
is null anduser_property_listings
.deleted_at
is null anduser_property_listings
.user_id
= 3Error
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'updated_at' in field list is ambiguous
The text was updated successfully, but these errors were encountered: