[5.8] fix MorphTo Relation ignores parent $timestamp when touching #28670
[5.8] fix MorphTo Relation ignores parent $timestamp when touching #28670taylorotwell merged 5 commits intolaravel:5.8from
Conversation
|
@driesvints reopened #28658 |
|
We also have to cover cases where timestamps are enabled, but framework/src/Illuminate/Database/Eloquent/Builder.php Lines 861 to 864 in 0ef0134 |
| { | ||
| $class = $class ?: static::class; | ||
|
|
||
| if (! get_class_vars($class)['timestamps']) { |
There was a problem hiding this comment.
I would prefer (new $class)->usesTimestamps() to be consistent with existing code.
There was a problem hiding this comment.
We also have to cover cases where timestamps are enabled, but UPDATED_AT is null:
just added test
There was a problem hiding this comment.
@staudenmeir in some cases we're getting abstract classes here for ex.
There was a problem hiding this comment.
Yes, but only in the tests. You can't get an abstract class in a real application. Please adjust the test accordingly.
There was a problem hiding this comment.
Yes, but only in the tests. You can't get an abstract class in a real application.
OK, but If I use (new $class)->usesTimestamps() 6 more test are failing (not including mine) - what to do with that?
For example this one:
There was a problem hiding this comment.
I think we should move the new code to Relation::touch(). Model::isIgnoringTouch() is only about $ignoreOnTouch, not about timestamps.
|
|
||
| public function testTouchingModelWithUpdatedAtNull() | ||
| { | ||
| $this->assertFalse( |
There was a problem hiding this comment.
This case has to return true. You need to cover it by adjusting isIgnoringTouch().
Signed-off-by: Max Kovalenko <mxss1998@yandex.ru>
Fixed bug with touching model which has $timestamps set to false resulting in Illuminate\Database\QueryException: SQLSTATE[HY000]: General error: 1 no such column: updated_at
for source issue and more details see #28638