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

[6.x] Change DatabaseNotification keyType to match uuid #30823

Merged
merged 1 commit into from
Dec 12, 2019
Merged

[6.x] Change DatabaseNotification keyType to match uuid #30823

merged 1 commit into from
Dec 12, 2019

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