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
When using an inverse of a nullable polymorphic (morphTo()) relationship along side with $touches on the relationship, Laravel generates incorrect query for touching the relationship.
Steps To Reproduce:
Create tags table with nullable taggable fields:
Schema::create('tags', function (Blueprint$table) {
$table->increments('id');
$table->nullableMorphs('taggable');
$table->timestamps();
});
Create Tag model with taggable() relationship and $touches property set to ['taggable']
class Tag extends Model
{
protected$touches = ['taggable'];
publicfunctiontaggable()
{
return$this->morphTo();
}
}
Now try to create a new Tag
Tag::create();
This generates the following error:
Illuminate/Database/QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tags.' in 'where clause' (SQL: update `tags` set `updated_at` = 2018-09-03 20:31:36 where `tags`.`` is null)'
Thanks for looking into this
The text was updated successfully, but these errors were encountered:
Description:
When using an inverse of a nullable polymorphic (
morphTo()
) relationship along side with$touches
on the relationship, Laravel generates incorrect query for touching the relationship.Steps To Reproduce:
Create
tags
table with nullabletaggable
fields:Create
Tag
model withtaggable()
relationship and$touches
property set to['taggable']
Now try to create a new Tag
Tag::create();
This generates the following error:
Thanks for looking into this
The text was updated successfully, but these errors were encountered: