Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down