Skip to content

Commit

Permalink
fix(13909): fixed update_at column is ambiguous-column by qualifying …
Browse files Browse the repository at this point in the history
…column name (#26022)
  • Loading branch information
nickshatilo authored and taylorotwell committed Oct 9, 2018
1 parent 60721fc commit 1b0c52c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Illuminate/Database/Eloquent/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,10 +822,15 @@ protected function addUpdatedAtColumn(array $values)
return $values;
}

return Arr::add(
$values, $this->model->getUpdatedAtColumn(),
$this->model->freshTimestampString()
);
if (! empty($this->getQuery()->joins)) {
$column = $this->model->getQualifiedUpdatedAtColumn();
} else {
$column = $this->model->getUpdatedAtColumn();
}

return array_merge($values, [
$column => $this->model->freshTimestampString(),
]);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/Illuminate/Database/Eloquent/Concerns/HasTimestamps.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,14 @@ public function getUpdatedAtColumn()
{
return static::UPDATED_AT;
}

/**
* Get the fully qualified "updated at" column.
*
* @return string
*/
public function getQualifiedUpdatedAtColumn()
{
return $this->getTable().'.'.$this->getUpdatedAtColumn();
}
}

0 comments on commit 1b0c52c

Please sign in to comment.