Uploaded image for project: 'PHP ORMs'
  1. PHP ORMs
  2. PHPORM-183

laravel-mongodb - Issue #2945: updateOrCreate -> createOrFirst doesn't work as expected

    • Not Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Boevsson has created Issue #2945: updateOrCreate -> createOrFirst doesn't work as expected in laravel-mongodb. This Jira ticket was filed by GromNaN

      Issue Text:

      • Laravel-mongodb Version: 4.2
      • PHP Version: 8.3.4
      • Database Driver & Version: mongod 5.0 / 7.0

      Description:

      Steps to reproduce

      1. $id = $request->get('id') ?? null; // in the case id is null
      2. Do `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

            Assignee:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Reporter:
            dbeng-pm-bot PM Bot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: