Adds a test case to simulate reports
This commit is contained in:
+37
@@ -532,4 +532,41 @@ class QueryAssemblerTest {
|
||||
sql,
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testReportLikeFilter() {
|
||||
val sql =
|
||||
explain(
|
||||
Filter(
|
||||
kinds = listOf(ContactListEvent.KIND),
|
||||
authors = listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
tags =
|
||||
mapOf(
|
||||
"p" to listOf("460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"),
|
||||
),
|
||||
limit = 500,
|
||||
),
|
||||
)
|
||||
|
||||
println(sql)
|
||||
|
||||
TestCase.assertEquals(
|
||||
"""
|
||||
SELECT id, pubkey, created_at, kind, tags, content, sig FROM event_headers
|
||||
INNER JOIN (
|
||||
SELECT DISTINCT(event_tags.event_header_row_id) as row_id FROM event_tags INNER JOIN event_headers ON event_headers.row_id = event_tags.event_header_row_id WHERE (event_tags.tag_hash = "-4551135004136952885") AND (event_headers.kind = "3") AND (event_headers.pubkey = "460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c") ORDER BY event_tags.created_at DESC LIMIT 500
|
||||
) AS filtered
|
||||
ON event_headers.row_id = filtered.row_id
|
||||
ORDER BY created_at DESC, id
|
||||
├── CO-ROUTINE filtered
|
||||
│ ├── SEARCH event_tags USING INDEX query_by_tags_hash (tag_hash=?)
|
||||
│ ├── SEARCH event_headers USING INTEGER PRIMARY KEY (rowid=?)
|
||||
│ └── USE TEMP B-TREE FOR DISTINCT
|
||||
├── SCAN filtered
|
||||
├── SEARCH event_headers USING INTEGER PRIMARY KEY (rowid=?)
|
||||
└── USE TEMP B-TREE FOR ORDER BY
|
||||
""".trimIndent(),
|
||||
sql,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user