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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Unknown
    • 4.4.0
    • Affects Version/s: None
    • None
    • None
    • None
    • None
    • None
    • None

      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:
              Jérôme Tamarelle
              Reporter:
              TPM Jira Automations Bot
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: