From d538a25081c4ec7d2386c2645971dac3e6c7ea11 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 18 Feb 2026 11:46:12 +0000 Subject: [PATCH] Show bound SQL queries in query list table instead of placeholders Change shortSql to use boundQuery (with interpolated params) so the query list table displays actual values like 'John' instead of ?. Also add boundQuery to the text search filter so users can search by bound parameter values. https://claude.ai/code/session_01NDmw3AG9wQx6vohhYAx9Be --- .../plugin/model/QueryEntry.kt | 2 +- .../plugin/ui/table/QueryTableModel.kt | 1 + .../plugin/model/QueryEntryTest.kt | 26 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/model/QueryEntry.kt b/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/model/QueryEntry.kt index 430801e..40aedfc 100644 --- a/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/model/QueryEntry.kt +++ b/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/model/QueryEntry.kt @@ -174,7 +174,7 @@ data class QueryEntry( val shortSql: String get() { - val oneLine = query.replace(Regex("\\s+"), " ").trim() + val oneLine = (boundQuery ?: query).replace(Regex("\\s+"), " ").trim() return if (oneLine.length > 80) oneLine.take(77) + "..." else oneLine } diff --git a/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/ui/table/QueryTableModel.kt b/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/ui/table/QueryTableModel.kt index e0811e8..94f264a 100644 --- a/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/ui/table/QueryTableModel.kt +++ b/jetbrains-plugin/src/main/kotlin/com/mariadbprofiler/plugin/ui/table/QueryTableModel.kt @@ -99,6 +99,7 @@ class QueryTableModel : AbstractTableModel() { val matchesType = typeFilter == null || entry.queryType == typeFilter val matchesText = textFilter.isEmpty() || entry.query.lowercase().contains(textFilter) || + (entry.boundQuery?.lowercase()?.contains(textFilter) == true) || entry.tags.any { it.lowercase().contains(textFilter) } || getFrameFile(entry).lowercase().contains(textFilter) || getFrameFunction(entry).lowercase().contains(textFilter) diff --git a/jetbrains-plugin/src/test/kotlin/com/mariadbprofiler/plugin/model/QueryEntryTest.kt b/jetbrains-plugin/src/test/kotlin/com/mariadbprofiler/plugin/model/QueryEntryTest.kt index ec43976..32b556c 100644 --- a/jetbrains-plugin/src/test/kotlin/com/mariadbprofiler/plugin/model/QueryEntryTest.kt +++ b/jetbrains-plugin/src/test/kotlin/com/mariadbprofiler/plugin/model/QueryEntryTest.kt @@ -70,6 +70,32 @@ class QueryEntryTest { assertEquals("SELECT * FROM users", entry.shortSql) } + @Test + fun `short SQL shows bound values instead of placeholders`() { + val entry = QueryEntry( + query = "SELECT * FROM users WHERE id = ?", + params = listOf("42") + ) + assertEquals("SELECT * FROM users WHERE id = '42'", entry.shortSql) + } + + @Test + fun `short SQL shows bound values and truncates long bound query`() { + val entry = QueryEntry( + query = "SELECT * FROM users WHERE name = ? AND email = ? AND status = ?", + params = listOf("John", "john@example.com", "active") + ) + assertTrue(entry.shortSql.length <= 80) + assertTrue(entry.shortSql.endsWith("...")) + assertTrue(entry.shortSql.contains("'John'")) + } + + @Test + fun `short SQL falls back to query when no params`() { + val entry = QueryEntry(query = "SELECT * FROM users WHERE id = ?") + assertEquals("SELECT * FROM users WHERE id = ?", entry.shortSql) + } + // ---- boundQuery tests ---- @Test