Skip to content
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

updated_at ambiguous on using delete() on hasManyThrough relation with softDeletes #15798

Closed
funyug opened this issue Oct 7, 2016 · 1 comment

Comments

@funyug
Copy link

funyug commented Oct 7, 2016

  • Laravel Version: 5.1.45
  • PHP Version: 7.0.1
  • Database Driver & Version:
    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 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

@themsaid
Copy link
Member

Duplicate of #13909

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants