Skip to content

Conversation

@kendugu
Copy link

@kendugu kendugu commented Dec 12, 2019

The default primary key for database notifications is a UUID, but the default keyType (from the base model) is an int. This causes ids with string UUIDs to be force cast as integers in MorphTo and other relationships.

/**
* Get the name of the "where in" method for eager loading.
*
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $key
* @return string
*/
protected function whereInMethod(Model $model, $key)
{
return $model->getKeyName() === last(explode('.', $key))
&& in_array($model->getKeyType(), ['int', 'integer'])
? 'whereIntegerInRaw'
: 'whereIn';
}

The default primary key for database notifications is a UUID, but the default `keyType` (from the base model) is an `int`. This causes ids with string UUIDs to be force cast as integers in MorphTo and other relationships.

https://github.com/laravel/framework/blob/f5c3c60d52eccd77274e586fc4c775374e826b0f/src/Illuminate/Database/Eloquent/Relations/Relation.php#L310-L323
@driesvints driesvints changed the title Change DatabaseNotification keyType to match uuid [6.x] Change DatabaseNotification keyType to match uuid Dec 12, 2019
@taylorotwell taylorotwell merged commit e3b4f7f into laravel:6.x Dec 12, 2019
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

Successfully merging this pull request may close these issues.

2 participants