You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After investigation, null is a valid value for MongoDB _id. That's why the Model::updateOrCreate(['_id' => null], $data) creates or updates a new document with _id: null.
This is inconsistent with how SQL works because SQL databases will generate a value with a request like this: INSERT INTO table (id, name) VALUES (null, 'foo').
Description:
Steps to reproduce
Model::updateOrCreate(['_id' => $id], $data);
Expected behaviour
A new record should be created with the given data and a generated _id.
Actual behaviour
It queries the first record from the collection and updates it.
This works fine when using the package 4.0 because the createOrFirst is not overriden there in the Mongo Builder class
The text was updated successfully, but these errors were encountered: