-
Notifications
You must be signed in to change notification settings - Fork 11.7k
Capture PDO read / write type for query events #58156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 12.x
Are you sure you want to change the base?
Conversation
|
Thanks for submitting a PR! Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface. Pull requests that are abandoned in draft may be closed due to inactivity. |
| public function __construct($sql, $bindings, $time, $connection) | ||
| public function __construct($sql, $bindings, $time, $connection, $readWriteType = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constructor remains backwards compatible.
|
cc @avosalmon 👀 |
d3e3cda to
ce55981
Compare
This PR exposes the read / write type to the query executed event and query exceptions for better debugging and logging.
I've found there isn't a bulletproof way to determine this with what Laravel already exposes. You can get it right in 95% of cases, but there are certain scenarios where it is impossible to know for sure if a query was against the read or write connection.
This method of tracking the last resolved PDO, although feeling a little weird, is the best way I can see of making this correct in all cases.