-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] Revert from using createOrFirst
in other *OrCreate
methods
#48531
[10.x] Revert from using createOrFirst
in other *OrCreate
methods
#48531
Conversation
…rstOrCreate` behind the scenes (laravel#48213)" This reverts commit e1ae507.
createOrFirst
in other *OrCreate
methodscreateOrFirst
in other *OrCreate
methods
I went ahead to dig a bit more into what was going on over here and found a few things:
1. The
|
… methods (laravel#48531)" This reverts commit 408a3e3.
…pdateOrCreate` improvement through `createOrFirst` + additional query tests (#48637) * Revert "[10.x] Revert from using `createOrFirst` in other `*OrCreate` methods (#48531)" This reverts commit 408a3e3. * test: 💍 Add `Builder::createOrFirst()` snapshot tests * test: 💍 Add `Builder::firstOrCreate()` snapshot tests * test: 💍 Add `Builder::updateOrCreate()` snapshot tests * test: 💍 Add test stubs for `DatabaseEloquentHasManyTest` * test: 💍 Add `HasMany::createOrFirst()` snapshot tests * test: 💍 Add `HasMany::firstOrCreate()` snapshot tests * test: 💍 Add `HasMany::updateOrCreate()` snapshot tests * test: 💍 prepare HasManyThrough test * test: 💍 Add HasManyThrough::CreateOrFirst() snapshot tests * test: 💍 Add HasManyThrough::firstOrCreate() snapshot test * test: 💍 Add HasManyThrough::updateOrCreate() snapshot test * refactor: 💡 use createOrFirst in firstOrCreate * test: 💍 fix test * style: 💄 Apply StyleCI fixes * docs: ✏️ Add missing FIXME comments * refactor: 💡 Omit verbose arguments * test: 💍 Rename `DatabaseEloquentHasManyThroughTest` with fixes * test: 💍 Add `BelongsToMany::createOrFirst/firstOrCreate` tests * test: 💍 Extract `DatabaseEloquentHasManyTest` cases with fixes * test: 💍 Extract `DatabaseEloquentBuilderTest` cases with fixes * test: 💍 refactoring * test: 💍 Add `BelongsToMany::updateOrCreate` snapshot tests --------- Co-authored-by: fuwasegu <admin@fuwasegu.com>
…pdateOrCreate` improvement through `createOrFirst` + additional query tests (laravel#48637) * Revert "[10.x] Revert from using `createOrFirst` in other `*OrCreate` methods (laravel#48531)" This reverts commit 408a3e3. * test: 💍 Add `Builder::createOrFirst()` snapshot tests * test: 💍 Add `Builder::firstOrCreate()` snapshot tests * test: 💍 Add `Builder::updateOrCreate()` snapshot tests * test: 💍 Add test stubs for `DatabaseEloquentHasManyTest` * test: 💍 Add `HasMany::createOrFirst()` snapshot tests * test: 💍 Add `HasMany::firstOrCreate()` snapshot tests * test: 💍 Add `HasMany::updateOrCreate()` snapshot tests * test: 💍 prepare HasManyThrough test * test: 💍 Add HasManyThrough::CreateOrFirst() snapshot tests * test: 💍 Add HasManyThrough::firstOrCreate() snapshot test * test: 💍 Add HasManyThrough::updateOrCreate() snapshot test * refactor: 💡 use createOrFirst in firstOrCreate * test: 💍 fix test * style: 💄 Apply StyleCI fixes * docs: ✏️ Add missing FIXME comments * refactor: 💡 Omit verbose arguments * test: 💍 Rename `DatabaseEloquentHasManyThroughTest` with fixes * test: 💍 Add `BelongsToMany::createOrFirst/firstOrCreate` tests * test: 💍 Extract `DatabaseEloquentHasManyTest` cases with fixes * test: 💍 Extract `DatabaseEloquentBuilderTest` cases with fixes * test: 💍 refactoring * test: 💍 Add `BelongsToMany::updateOrCreate` snapshot tests --------- Co-authored-by: fuwasegu <admin@fuwasegu.com>
Changed
createOrFirst
, other*OrCreate
methods were updated to use it behind the scenes. It turns out this was more problematic than we initially thought. This PR reverts usingcreateOrFirst
in other methods, but we'll keep it around for the specific scenario it was designed for: using unique constraints to determine if it should create or find the record.I've tested the test case added in #48529 and it passes when we revert these changes here.
There was a comment here mentioning an issue, which might be related (it was also on
updateOrCreate
). We didn't have a way to reproduce the issue.Reverted PRs:
updateOrCreate()
to UsefirstOrCreate()
#48160firstOrCreate
methods in relations usecreateOrFirst
behind the scenes #48192createOrFirst
to thefirstOrCreate
in the builder alone: [10.x] Adds acreateOrFirst
method to Eloquent #47973