-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: laravel-4.1.0
-
Component/s: Laravel
-
None
nicohell has created Issue #2720: Transaction already in progress in laravel-mongodb
Issue Text:
- Laravel-mongodb Version: 4.1
- PHP Version: 8.2.15
- Database Driver & Version: db version v6.0.13
- PHP MongoDB extension version {}1.17.2{}
Description:
Using firstOrCreate() in a transaction returns an error
Steps to reproduce
$mongodb = DB::connection('app'); $mongodb->beginTransaction(); // user does not exist and will be created \App\Models\User::firstOrCreate(['username' => 'johncarpenter', 'name' => 'carpenter', 'email' => 'john@example.com']); $mongodb->rollBack();
Expected behaviour
Manage transaction and commit or rollBack
Actual behaviour
retuns error : local.ERROR: MongoDB\Driver\Exception\RuntimeException: Transaction already in progress in vendor/mongodb/mongodb/src/Operation/WithTransaction.php:60
Notes
create() works fine
firstOrCreate() and updateOrCreate() do work for updates but do not work for creation as they start a transaction in vendor/mongodb/mongodb/src/Operation/WithTransaction.php
Hack
We went through adding a test in vendor/mongodb/mongodb/src/Operation/WithTransaction.php
if (!$session->isInTransaction()) { $session->startTransaction($this->transactionOptions); }
- causes
-
PHPORM-171 createOrFirst does not set timestamp fields
- Closed