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

Conversation

@kendugu
Copy link
Contributor

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
2 checks passed
2 checks passed
continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.