Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Transactions passed in find() or findFirst() to query inside of started transactions #13226
this ticket exists because I was to incompetent to first create a Ticket before starting a PR. The target branch has changed and I need to rewrite the history with the correct ticket number :)
Small description of change:
Currently you only can use the internal Transaction behaviour without an option to use a specific transaction in find / findFirst. This should be changed
This change is to achieve the following:
In Unit-testing one usual procedure is to create a transaction for a TestCase and after the execution rollback this change.
Which means there is a "long transaction" going on and we want to check if the transaction actually is writing the correct values in the database. But the static context of model::find / model::findFirst does not get the transaction passed.
To achieve that passing a new index "transaction" containing an transaction in the $param array seams to be a viable solution.
Another use-case can be having multiple transactions and wanting to look inside.
Just to be precise -> ofc we could just get the connection and query manually inside of it, but I want to be as close to the framework as possible when testing certain services hence I want to use the model.
I took your reviews and advice from the last attempt and used the params to not break the interfaces / change method signatures.
the logic is implemented as follows:
if you pass in a transaction via param in the find/findFirst method. It will set the transaction to query object and this transaction will be used for all queries and executions within this query context.
This should not affect any standard behaviour but still allow me to finally achieve cleaner unittests for my usecase.