Skip to content

Commit

Permalink
fix(controller): commit immediately
Browse files Browse the repository at this point in the history
Based on my understanding on the source file of
`Database\BaseConnection`, status is not reliable for nested
transactions.

However, the rollback still happens on tests.
  • Loading branch information
KennethTrecy committed Aug 27, 2023
1 parent b2f18a0 commit 1ca3401
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions app/Controllers/BaseOwnedResourceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,7 @@ function($request_data) use ($controller) {
$response_document
);

if (static::mustTransactForCreation()) {
if ($database->transStatus() === true) {
$database->transCommit();
} else {
$database->transRollback();

return $controller->makeServerError(
"There is an error on inserting to the database server."
);
}
}
if (static::mustTransactForCreation()) $database->transCommit();

return $controller->respondCreated()->setJSON($response_document);
}
Expand Down

0 comments on commit 1ca3401

Please sign in to comment.