debug_kit icon indicating copy to clipboard operation
debug_kit copied to clipboard

Read connections in SQL Log panel?

Open ryanolton opened this issue 1 year ago • 3 comments

I recently stumbled across this great feature that allows read-only connections, but I do not see any queries using the "read" connection in the SQL Log panel within DebugKit.

Does DebugKit support these "read" connections? Perhaps I'm missing some configuration setting?

The panel code seems to look for unique connections, in this cause it finds "default", but the "read" and "write" config keys specified seem to both be a part of "default", so they're not seen as two different connections. The end result is that the SQL Log panel only shows "write" connections, no "read" connections are visible.

'default' => [
	'className' => Connection::class,
	'driver' => Postgres::class,
	'encoding' => 'utf8',
	'host' => 'localhost',
	'username' => 'test',
	'password' => 'test',
	'database' => 'test_db',
	'read' => [
		'database' => 'read_test_db',
	],
	'write' => [
		'database' => 'test_db',
	],
	'log' => false,
],

Here is the original PR for this feature: https://github.com/cakephp/cakephp/pull/16785

ryanolton avatar May 15 '24 16:05 ryanolton

DebugKit doesn't know about connection roles yet, we'd need to improve how debugkit collects queries to make that possible.

markstory avatar May 15 '24 17:05 markstory

@LordSimal closing this issue may have been a bit hasty. While I indeed see the Role column, I only see write queries within the DebugKit SQL panel. As I convert queries to use the read role, they disappear from the panel altogether.

I suspect that was at least part of what @markstory meant in his comment above; the DebugKit SQL panel doesn't appear to be aware of read queries as far as I can tell.

ryanolton avatar Dec 31 '24 21:12 ryanolton

Thats because https://github.com/cakephp/debug_kit/blob/5.x/src/Panel/SqlLogPanel.php#L57 only fetches the write role, not the read role.

Will have to tackle this later.

LordSimal avatar Jan 01 '25 10:01 LordSimal