-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
- Laravel-mongodb Version: 3.6
- PHP Version: N/A
- Database Driver & Version: N/A
Description:
Native Illuminate\Database\Events\QueryExecuted
event only gets fired when query logging is enabled DB::connection('mongodb')->enableQueryLog();
which is not the same behaviour as the native Laravel connection.
Steps to reproduce
N/A
Expected behaviour
The default Laravel database connection will fire the QueryExecuted
event on every query regardless of the query logging config. The enableQueryLog()
functionality is used to keep an in-memory log of executed queries.
The QueryExecuted
event is listened to by a fair few packages for handy debugging (Telescope, Sentry, Laravel debug bar, Laravel AWS Xray).
Currently, query logging needs to be enabled on this connection in order to fire the QueryExecuted
which will also add queries to the in-memory query log.
See https://github.com/illuminate/database/blob/master/Connection.php#L687, which is called from https://github.com/illuminate/database/blob/master/Connection.php#L621
Can we remove the logging condition here https://github.com/jenssegers/laravel-mongodb/blob/master/src/Jenssegers/Mongodb/Collection.php#L44 and always fire the QueryExecuted
and fall back on the parent logQuery()
functionality to determine whether to add Mongo queries to the in-memory log?
Happy to raise a PR
Actual behaviour
N/A