debug_kit icon indicating copy to clipboard operation
debug_kit copied to clipboard

Add an option to "flag" queries

Open nrother opened this issue 9 years ago • 10 comments

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.

nrother avatar Jan 13 '17 15:01 nrother

I like this idea

lorenzo avatar Jan 15 '17 10:01 lorenzo

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.

nrother avatar Jan 18 '17 12:01 nrother

👍 @lorenzo Any ideas here?

dereuromark avatar Sep 29 '17 00:09 dereuromark

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.

thinkingmedia avatar Dec 21 '17 15:12 thinkingmedia

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.

markstory avatar Dec 21 '17 17:12 markstory

I'm not sure that I understand, but keep in mind two tags could share same query object.

thinkingmedia avatar Dec 21 '17 18:12 thinkingmedia

Something like $query->tags(['type' => 'schema', 'flagged' => true]) this would allow us and userland code to tag/label queries with richer information.

markstory avatar Dec 21 '17 18:12 markstory

The new CakePHP 5.x tracing query execution feature could be of help to some degree.

ravage84 avatar Sep 19 '23 18:09 ravage84

Is there someone who wants to provide a PR here?

dereuromark avatar Mar 14 '24 08:03 dereuromark