Fixes count not working for LIMIT queries

This commit is contained in:
Vitor Pamplona
2026-01-02 17:22:18 -05:00
parent 51f9fdd58c
commit 7a34b8480e
@@ -265,7 +265,7 @@ class QueryBuilder(
until = newFilter.until, until = newFilter.until,
limit = newFilter.limit, limit = newFilter.limit,
) )
return db.runCount(sql.sql, sql.args) return db.countIn(sql.sql, sql.args)
} }
val rowIdSubQuery = prepareRowIDSubQueries(filter, hasher(db)) val rowIdSubQuery = prepareRowIDSubQueries(filter, hasher(db))
@@ -646,7 +646,7 @@ class QueryBuilder(
if (project) { if (project) {
append("SELECT id, pubkey, created_at, kind, tags, content, sig FROM event_headers") append("SELECT id, pubkey, created_at, kind, tags, content, sig FROM event_headers")
} else { } else {
append("SELECT count(*) FROM event_headers") append("SELECT row_id FROM event_headers")
} }
if (clause.conditions.isNotEmpty()) { if (clause.conditions.isNotEmpty()) {
append("\nWHERE ") append("\nWHERE ")