[9.x] Improve UUID and ULID support for Eloquent - #44146
Conversation
| if ($this->getKeyType() === 'string') { | ||
| return false; | ||
| } | ||
|
|
There was a problem hiding this comment.
This might need to be rethought. In my mind a string key type column can never be incrementing but I might be wrong.
| $query->shouldReceive('insertGetId')->once()->with([], 'id')->andReturn('string id'); | ||
| $query->shouldReceive('insert')->once()->with(['id' => 'string id']); | ||
| $query->shouldReceive('getConnection')->once(); | ||
| $model->expects($this->once())->method('newModelQuery')->willReturn($query); |
There was a problem hiding this comment.
I had to rewrite the test here because of the change I did in the getIncrementing method. I think the current test wasn't realistic as I can't see how you can increment with string-based keys. With string-based keys you always need to set them beforehand afaik (like I adjusted the test to).
|
@driesvints why was the change to |
|
@taylorotwell whoops, you're right. Pushed. I first was thinking of doing it through a property but when you apply a trait with a property directly on a model you cannot overwrite it. The current solution is way better and more frictionless :) |
|
Good job! 👍 |
|
Maybe it's nice to add support for a binary column type for UUID? 😏 |
|
Hi @driesvints . This update break jenssegers/laravel-mongodb public function getIncrementing()
{
if ($this->getKeyType() === 'string') {
return false;
}
return $this->incrementing;
} |
|
@The-Hasanov I replied on the related PR fix: mongodb/laravel-mongodb#2452 |
Improves upon #44074 by:
incrementingto false when astringtype primary key is usedI was doubting on checking to see if I could add support to use both traits at the same time (so you could both fill in UUID and ULID columns) but I guess that scenario isn't so common.