mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-30 04:28:44 +00:00
Tests for the singleResult hint and fetchCount
This commit is contained in:
1 parent
65fe2bb50c
commit
21c0175a71
1 file changed
+17
@@ -340,4 +340,21 @@ class FetchRequestTests: GRDBTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testSingleResultHintIsNotUsedForDefaultFetchCount() throws {
|
||||
struct CustomRequest: FetchRequest {
|
||||
typealias RowDecoder = Void
|
||||
func prepare(_ db: Database, forSingleResult singleResult: Bool) throws -> (SelectStatement, RowAdapter?) {
|
||||
if singleResult { fatalError("not implemented") }
|
||||
return try (db.makeSelectStatement(sql: "SELECT 'multiple'"), nil)
|
||||
}
|
||||
}
|
||||
|
||||
let dbQueue = try makeDatabaseQueue()
|
||||
try dbQueue.write { db in
|
||||
let request = CustomRequest()
|
||||
_ = try request.fetchCount(db)
|
||||
XCTAssertEqual(lastSQLQuery, "SELECT COUNT(*) FROM (SELECT 'multiple')")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user