Tests for the singleResult hint and fetchCount

This commit is contained in:
Gwendal Roué committed 2019-04-17 21:31:53 +02:00
1 parent 65fe2bb50c
commit 21c0175a71
1 file changed
+17
+17
View File
@@ -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')")
}
}
}