Add an option to "flag" queries
It would be nice if it would be possible to mark SQL queries in some way to find them in the Panel if there are many of them. Maybe one could abuse applyOptions for this:
$query->applyOptions(['debug.mark' => true]);
Maybe queries could be even automatically tagged based on their origin (primary/secondary).
I tried a quick attempt to hack in this myself, but this seemed not that easy, unfortunately.
I like this idea
I just looked around a bit to see how this could be implement, but I haven't found a nice way yet. The LoggedQuery the panel has access to does not contain the original query Object, but only a query string. So I currently don't see a way to pass information from the app to debugkit without changing LoggingStatement in the core.
👍 @lorenzo Any ideas here?
I think this is a great idea, and was going to open a new ticket for something like this. Except my idea was to "tag" queries so that we could filter them in the SQL log.
There would be the default view of the SQL log in chronological order, but across the top would be checkboxes for each group. Unchecking a group would hide those queries from the log. It would just be a visual hiding of matching DOM elements.
I would also prefer to update the Query object interface to allow a more verbose way of tagging. It just makes it easier to work with.
$query->tag('documents');
$query->tag(['documents','reports']);
A query can be tagged with multiple tags.
I would also add tags for internal queries like the "SHOW INDEXES" and "SHOW COLUMNS" that are frequently done by the core. Maybe just tag them with "cake" or something like that.
Also (another idea) the models could auto tag the model name when the query object is created. I think this could be a very useful feature.
Tagging queries is an interesting idea. Should the tags be an map instead of a list? That would allow us to record metadata about the queries more effectively.
I'm not sure that I understand, but keep in mind two tags could share same query object.
Something like $query->tags(['type' => 'schema', 'flagged' => true]) this would allow us and userland code to tag/label queries with richer information.
The new CakePHP 5.x tracing query execution feature could be of help to some degree.
Is there someone who wants to provide a PR here?