Rename Request.fetching(_:) to Request.asRequest(of:)

This commit is contained in:
Gwendal Roué committed 2017-05-22 18:55:51 +02:00
1 parent cd107711a9
commit f858bcbe5b
11 files changed
+144 -127

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ Release Notes
- `DatabaseEventKind.impacts(_ selectionInfo:SelectStatement.SelectionInfo)` now returns an non-optional boolean.
- `DatabaseWriter.availableDatabaseConnection` has been replaced by `DatabaseWriter.unsafeReentrantWrite()`.
- `Request.bound(to:)` has been renamed `Request.fetching(_:)`.
- `Request.bound(to:)` has been renamed `Request.asRequest(of:)`.
## 0.108.0
+3 -2
View File
@@ -45,14 +45,15 @@ extension Request {
/// The returned request can fetch if the type T is fetchable (Row,
/// value, record).
///
/// // minHeight in Double?
/// let minHeight = Person
/// .select(min(heightColumn))
/// .fetching(Double.self) // <--
/// .asRequest(of: Double.self) // <--
/// .fetchOne(db)
///
/// - parameter type: The fetched type T
/// - returns: A typed request bound to type T.
public func fetching<T>(_ type: T.Type) -> AnyTypedRequest<T> {
public func asRequest<T>(of type: T.Type) -> AnyTypedRequest<T> {
return AnyTypedRequest { try self.prepare($0) }
}
+1 -1
View File
@@ -1,4 +1,4 @@
extension Request {
@available(*, unavailable, renamed:"fetching(_:)")
@available(*, unavailable, renamed:"asRequest(of:)")
public func bound<T>(to type: T.Type) -> AnyTypedRequest<T> { preconditionFailure() }
}
+3 -3
View File
@@ -38,7 +38,7 @@ public final class FetchedRecordsController<Record: RowConvertible> {
/// This function should return true if the two records have the
/// same identity. For example, they have the same id.
public convenience init(_ databaseWriter: DatabaseWriter, sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, queue: DispatchQueue = .main, isSameRecord: ((Record, Record) -> Bool)? = nil) throws {
try self.init(databaseWriter, request: SQLRequest(sql, arguments: arguments, adapter: adapter).fetching(Record.self), queue: queue, isSameRecord: isSameRecord)
try self.init(databaseWriter, request: SQLRequest(sql, arguments: arguments, adapter: adapter).asRequest(of: Record.self), queue: queue, isSameRecord: isSameRecord)
}
/// Creates a fetched records controller initialized from a fetch request
@@ -157,7 +157,7 @@ public final class FetchedRecordsController<Record: RowConvertible> {
/// This method must be used from the controller's dispatch queue (the
/// main queue unless stated otherwise in the controller's initializer).
public func setRequest(sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil) throws {
try setRequest(SQLRequest(sql, arguments: arguments, adapter: adapter).fetching(Record.self))
try setRequest(SQLRequest(sql, arguments: arguments, adapter: adapter).asRequest(of: Record.self))
}
/// Registers changes notification callbacks.
@@ -374,7 +374,7 @@ extension FetchedRecordsController where Record: TableMapping {
/// notified of changes in this queue. The controller itself must be
/// used from this queue.
public convenience init(_ databaseWriter: DatabaseWriter, sql: String, arguments: StatementArguments? = nil, adapter: RowAdapter? = nil, queue: DispatchQueue = .main) throws {
try self.init(databaseWriter, request: SQLRequest(sql, arguments: arguments, adapter: adapter).fetching(Record.self), queue: queue)
try self.init(databaseWriter, request: SQLRequest(sql, arguments: arguments, adapter: adapter).asRequest(of: Record.self), queue: queue)
}
/// Creates a fetched records controller initialized from a fetch request
+21 -5
View File
@@ -3145,10 +3145,26 @@ let maxScore = try Int.fetchOne(db, request) // Int?
let request = Player.select(min(scoreColumn), max(scoreColumn))
let row = try Row.fetchOne(db, request)!
let minScore = row.value(atIndex: 0) as Int
let maxScore = row.value(atIndex: 1) as Int
let minScore = row.value(atIndex: 0) as Int?
let maxScore = row.value(atIndex: 1) as Int?
```
The examples above can also be rewritten using the `asRequest(of:)` method:
```swift
let maxScore = try Player.select(max(scoreColumn))
.asRequest(of: Int.self)
.fetchOne(db)
let row = try Player.select(min(scoreColumn), max(scoreColumn))
.asRequest(of: Row.self)
.fetchOne(db)!
let minScore = row.value(atIndex: 0) as Int?
let maxScore = row.value(atIndex: 1) as Int?
```
More information about `asRequest(of:)` can be found in the [Custom Requests](#custom-requests) chapter.
## Delete Requests
@@ -3287,7 +3303,7 @@ Rebind the fetched type of requests:
```swift
let maxScore = Player.select(max(scoreColumn))
.fetching(Int.self)
.asRequest(of: Int.self)
.fetchOne(db)
```
@@ -3297,7 +3313,7 @@ Bind custom SQL requests to your record types:
extension Person {
static func customRequest(...) -> AnyTypedRequest<Person> {
let request = SQLRequest("SELECT ...", arguments: ...)
return request.fetching(Person.self)
return request.asRequest(of: Person.self)
}
}
@@ -3322,7 +3338,7 @@ struct BookAuthorPair : RowConvertible {
"SELECT books.*, authors.* " +
"FROM books " +
"JOIN authors ON authors.id = books.authorID")
.fetching(BookAuthorPair.self)
.asRequest(of: BookAuthorPair.self)
.adapted { db in
// The scopes are used in init(row:)
try ScopeAdapter([
+1 -1
View File
@@ -25,7 +25,7 @@ v1.0 checklit
Besides, not all requests have a naturel Fetched type: request.fetchCount(db) doesn't care about the type of the request, for example.
- [X] Question AnyRequest and AnyTypedRequest as results (for example, `SQLRequest("...").bound(to: MyRecord.self)` returns AnyTypedRequest).
It's not worth the effort to introduce more concrete request types (AdaptedRequest, AdaptedTypedRequest, BoundRequest)
- [X] Question the naming of the `request.bound(to:T.self)` method. Prefer... `request.fetching(T.self)`? `request.of(T.self)`?
- [X] Question the naming of the `request.bound(to:T.self)` method. Prefer... `request..asRequest(of: T.self)`
- [ ] Make GRDB less stringly-typed. When a user defines a static list of columns for a record type, those columns should be easier to use:
- [ ] Persistable.persistentDictionary requires string keys, doesn't accept columns
- [ ] If possible, improve on `Person.filter(Person.email != nil)` or `Person.filter(Person.Column.email != nil)` (see [#186](https://github.com/groue/GRDB.swift/issues/186))
@@ -42,7 +42,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql))
try test(Fetched.fetchCursor(statement))
try test(Fetched.fetchCursor(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, 2"
@@ -51,7 +51,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter))
try test(Fetched.fetchCursor(statement, adapter: adapter))
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db))
}
}
}
@@ -86,7 +86,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -94,7 +94,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
}
}
@@ -118,7 +118,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -126,7 +126,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
}
}
@@ -143,7 +143,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql))
try test(Fetched.fetchAll(statement))
try test(Fetched.fetchAll(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, 2"
@@ -152,7 +152,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter))
try test(Fetched.fetchAll(statement, adapter: adapter))
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db))
}
}
}
@@ -178,7 +178,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -186,7 +186,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
}
}
@@ -210,7 +210,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -218,7 +218,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
}
}
@@ -236,7 +236,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, 1 WHERE 0"
@@ -245,7 +245,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
do {
@@ -258,7 +258,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, NULL"
@@ -267,7 +267,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
do {
@@ -280,7 +280,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, 1"
@@ -289,7 +289,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
}
@@ -316,7 +316,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -324,7 +324,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
}
}
@@ -348,7 +348,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -356,7 +356,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
}
}
@@ -377,7 +377,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql))
try test(Optional<Fetched>.fetchCursor(statement))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchCursor(db))
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchCursor(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, NULL"
@@ -386,7 +386,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql, adapter: adapter))
try test(Optional<Fetched>.fetchCursor(statement, adapter: adapter))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchCursor(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchCursor(db))
}
}
}
@@ -421,7 +421,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -429,7 +429,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchCursor(db), sql: sql)
}
}
}
@@ -453,7 +453,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -461,7 +461,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchCursor(db), sql: sql)
}
}
}
@@ -480,7 +480,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql))
try test(Optional<Fetched>.fetchAll(statement))
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchAll(db))
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchAll(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, NULL"
@@ -489,7 +489,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql, adapter: adapter))
try test(Optional<Fetched>.fetchAll(statement, adapter: adapter))
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchAll(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchAll(db))
}
}
}
@@ -515,7 +515,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -523,7 +523,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
}
}
@@ -547,7 +547,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -555,7 +555,7 @@ class DatabaseValueConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
}
}
+8 -8
View File
@@ -668,7 +668,7 @@ class AdapterRowTests : RowTestCase {
try dbQueue.inDatabase { db in
do {
let row = try SQLRequest("SELECT 0 AS a0, 1 AS a1, 2 AS a2", adapter: SuffixRowAdapter(fromIndex: 1))
.fetching(Row.self)
.asRequest(of: Row.self)
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a1", "a2"])
XCTAssertEqual(Array(row.databaseValues), [1.databaseValue, 2.databaseValue])
@@ -676,7 +676,7 @@ class AdapterRowTests : RowTestCase {
do {
let row = try SQLRequest("SELECT 0 AS a0, 1 AS a1, 2 AS a2")
.adapted { _ in SuffixRowAdapter(fromIndex: 1) }
.fetching(Row.self)
.asRequest(of: Row.self)
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a1", "a2"])
XCTAssertEqual(Array(row.databaseValues), [1.databaseValue, 2.databaseValue])
@@ -684,7 +684,7 @@ class AdapterRowTests : RowTestCase {
do {
let row = try SQLRequest("SELECT 0 AS a0, 1 AS a1, 2 AS a2", adapter: SuffixRowAdapter(fromIndex: 1))
.adapted { _ in SuffixRowAdapter(fromIndex: 1) }
.fetching(Row.self)
.asRequest(of: Row.self)
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a2"])
XCTAssertEqual(Array(row.databaseValues), [2.databaseValue])
@@ -692,7 +692,7 @@ class AdapterRowTests : RowTestCase {
do {
let row = try SQLRequest("SELECT 0 AS a0", adapter: ColumnMapping(["a1": "a0"]))
.adapted { _ in ColumnMapping(["a2": "a1"]) }
.fetching(Row.self)
.asRequest(of: Row.self)
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a2"])
XCTAssertEqual(Array(row.databaseValues), [0.databaseValue])
@@ -705,14 +705,14 @@ class AdapterRowTests : RowTestCase {
try dbQueue.inDatabase { db in
do {
let row = try SQLRequest("SELECT 0 AS a0, 1 AS a1, 2 AS a2", adapter: SuffixRowAdapter(fromIndex: 1))
.fetching(Row.self)
.asRequest(of: Row.self)
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a1", "a2"])
XCTAssertEqual(Array(row.databaseValues), [1.databaseValue, 2.databaseValue])
}
do {
let row = try SQLRequest("SELECT 0 AS a0, 1 AS a1, 2 AS a2")
.fetching(Row.self)
.asRequest(of: Row.self)
.adapted { _ in SuffixRowAdapter(fromIndex: 1) }
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a1", "a2"])
@@ -720,7 +720,7 @@ class AdapterRowTests : RowTestCase {
}
do {
let row = try SQLRequest("SELECT 0 AS a0, 1 AS a1, 2 AS a2", adapter: SuffixRowAdapter(fromIndex: 1))
.fetching(Row.self)
.asRequest(of: Row.self)
.adapted { _ in SuffixRowAdapter(fromIndex: 1) }
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a2"])
@@ -728,7 +728,7 @@ class AdapterRowTests : RowTestCase {
}
do {
let row = try SQLRequest("SELECT 0 AS a0", adapter: ColumnMapping(["a1": "a0"]))
.fetching(Row.self)
.asRequest(of: Row.self)
.adapted { _ in ColumnMapping(["a2": "a1"]) }
.fetchOne(db)!
XCTAssertEqual(Array(row.columnNames), ["a2"])
+20 -20
View File
@@ -46,7 +46,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql))
try test(Fetched.fetchCursor(statement))
try test(Fetched.fetchCursor(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db))
}
do {
let sql = "SELECT 0 AS firstName, 'Arthur' AS firstName, 'Martin' AS lastName UNION ALL SELECT 0, 'Barbara', 'Gourde'"
@@ -55,7 +55,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter))
try test(Fetched.fetchCursor(statement, adapter: adapter))
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db))
}
}
}
@@ -90,7 +90,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT 0, throw(), NULL"
@@ -98,7 +98,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
}
}
@@ -122,7 +122,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -130,7 +130,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
}
}
@@ -148,7 +148,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql))
try test(Fetched.fetchAll(statement))
try test(Fetched.fetchAll(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db))
}
do {
let sql = "SELECT 0 AS firstName, 'Arthur' AS firstName, 'Martin' AS lastName UNION ALL SELECT 0, 'Barbara', 'Gourde'"
@@ -157,7 +157,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter))
try test(Fetched.fetchAll(statement, adapter: adapter))
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db))
}
}
}
@@ -183,7 +183,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -191,7 +191,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
}
}
@@ -215,7 +215,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -223,7 +223,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
}
}
@@ -241,7 +241,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, 1 WHERE 0"
@@ -250,7 +250,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
do {
@@ -264,7 +264,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0 AS firstName, 'Arthur' AS firstName, 'Martin' AS lastName"
@@ -273,7 +273,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
}
@@ -300,7 +300,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -308,7 +308,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
}
}
@@ -332,7 +332,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -340,7 +340,7 @@ class RowConvertibleTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
}
}
+20 -20
View File
@@ -27,7 +27,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchCursor(db, sql))
try test(Row.fetchCursor(statement))
try test(Row.fetchCursor(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Row.self).fetchCursor(db))
try test(SQLRequest(sql).asRequest(of: Row.self).fetchCursor(db))
}
do {
let sql = "SELECT 0 AS firstName, 'Arthur' AS firstName, 'Martin' AS lastName UNION ALL SELECT 0, 'Barbara', 'Gourde'"
@@ -36,7 +36,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchCursor(db, sql, adapter: adapter))
try test(Row.fetchCursor(statement, adapter: adapter))
try test(Row.fetchCursor(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchCursor(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchCursor(db))
}
}
}
@@ -71,7 +71,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchCursor(db, sql), sql: sql)
try test(Row.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Row.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Row.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Row.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT 0, throw(), NULL"
@@ -79,7 +79,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Row.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Row.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchCursor(db), sql: sql)
}
}
}
@@ -103,7 +103,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchCursor(db, sql), sql: sql)
try test(Row.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Row.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Row.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Row.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -111,7 +111,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Row.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Row.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchCursor(db), sql: sql)
}
}
}
@@ -129,7 +129,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchAll(db, sql))
try test(Row.fetchAll(statement))
try test(Row.fetchAll(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Row.self).fetchAll(db))
try test(SQLRequest(sql).asRequest(of: Row.self).fetchAll(db))
}
do {
let sql = "SELECT 0 AS firstName, 'Arthur' AS firstName, 'Martin' AS lastName UNION ALL SELECT 0, 'Barbara', 'Gourde'"
@@ -138,7 +138,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchAll(db, sql, adapter: adapter))
try test(Row.fetchAll(statement, adapter: adapter))
try test(Row.fetchAll(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchAll(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchAll(db))
}
}
}
@@ -164,7 +164,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchAll(db, sql), sql: sql)
try test(Row.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Row.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Row.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Row.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -172,7 +172,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Row.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Row.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchAll(db), sql: sql)
}
}
}
@@ -196,7 +196,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchAll(db, sql), sql: sql)
try test(Row.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Row.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Row.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Row.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -204,7 +204,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Row.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Row.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchAll(db), sql: sql)
}
}
}
@@ -222,7 +222,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql))
try test(Row.fetchOne(statement))
try test(Row.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Row.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Row.self).fetchOne(db))
}
do {
let sql = "SELECT 0, 1 WHERE 0"
@@ -231,7 +231,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql, adapter: adapter))
try test(Row.fetchOne(statement, adapter: adapter))
try test(Row.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchOne(db))
}
}
do {
@@ -245,7 +245,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql))
try test(Row.fetchOne(statement))
try test(Row.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Row.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Row.self).fetchOne(db))
}
do {
let sql = "SELECT 0 AS firstName, 'Arthur' AS firstName, 'Martin' AS lastName"
@@ -254,7 +254,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql, adapter: adapter))
try test(Row.fetchOne(statement, adapter: adapter))
try test(Row.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchOne(db))
}
}
}
@@ -281,7 +281,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql), sql: sql)
try test(Row.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Row.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Row.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Row.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -289,7 +289,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Row.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Row.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchOne(db), sql: sql)
}
}
}
@@ -313,7 +313,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql), sql: sql)
try test(Row.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Row.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Row.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Row.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -321,7 +321,7 @@ class RowFetchTests: GRDBTestCase {
try test(Row.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Row.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Row.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Row.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Row.self).fetchOne(db), sql: sql)
}
}
}
@@ -99,7 +99,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql))
try test(Fetched.fetchCursor(statement))
try test(Fetched.fetchCursor(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, 2"
@@ -108,7 +108,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter))
try test(Fetched.fetchCursor(statement, adapter: adapter))
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db))
}
}
}
@@ -143,7 +143,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -151,7 +151,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
}
}
@@ -175,7 +175,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -183,7 +183,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchCursor(db), sql: sql)
}
}
}
@@ -201,7 +201,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql))
try test(Fetched.fetchAll(statement))
try test(Fetched.fetchAll(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, 2"
@@ -210,7 +210,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter))
try test(Fetched.fetchAll(statement, adapter: adapter))
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db))
}
}
}
@@ -236,7 +236,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -244,7 +244,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
}
}
@@ -268,7 +268,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -276,7 +276,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchAll(db), sql: sql)
}
}
}
@@ -294,7 +294,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, 1 WHERE 0"
@@ -303,7 +303,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
do {
@@ -316,7 +316,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, NULL"
@@ -325,7 +325,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
do {
@@ -338,7 +338,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql))
try test(Fetched.fetchOne(statement))
try test(Fetched.fetchOne(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db))
}
do {
let sql = "SELECT 0, 1"
@@ -347,7 +347,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter))
try test(Fetched.fetchOne(statement, adapter: adapter))
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db))
}
}
}
@@ -374,7 +374,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -382,7 +382,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
}
}
@@ -406,7 +406,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql)), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -414,7 +414,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Fetched.fetchOne(db, sql, adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Fetched.fetchOne(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Fetched.self).fetchOne(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Fetched.self).fetchOne(db), sql: sql)
}
}
}
@@ -437,7 +437,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql))
try test(Optional<Fetched>.fetchCursor(statement))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchCursor(db))
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchCursor(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, NULL"
@@ -446,7 +446,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql, adapter: adapter))
try test(Optional<Fetched>.fetchCursor(statement, adapter: adapter))
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchCursor(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchCursor(db))
}
}
}
@@ -470,7 +470,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchCursor(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -478,7 +478,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchCursor(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchCursor(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchCursor(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchCursor(db), sql: sql)
}
}
}
@@ -498,7 +498,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql))
try test(Optional<Fetched>.fetchAll(statement))
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql)))
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchAll(db))
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchAll(db))
}
do {
let sql = "SELECT 0, 1 UNION ALL SELECT 0, NULL"
@@ -507,7 +507,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql, adapter: adapter))
try test(Optional<Fetched>.fetchAll(statement, adapter: adapter))
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql, adapter: adapter)))
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchAll(db))
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchAll(db))
}
}
}
@@ -533,7 +533,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT 0, throw()"
@@ -541,7 +541,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
}
}
@@ -565,7 +565,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql)), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql)), sql: sql)
try test(SQLRequest(sql).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
do {
let sql = "SELECT * FROM nonExistingTable"
@@ -573,7 +573,7 @@ class StatementColumnConvertibleFetchTests: GRDBTestCase {
try test(Optional<Fetched>.fetchAll(db, sql, adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db.makeSelectStatement(sql), adapter: adapter), sql: sql)
try test(Optional<Fetched>.fetchAll(db, SQLRequest(sql, adapter: adapter)), sql: sql)
try test(SQLRequest(sql, adapter: adapter).fetching(Optional<Fetched>.self).fetchAll(db), sql: sql)
try test(SQLRequest(sql, adapter: adapter).asRequest(of: Optional<Fetched>.self).fetchAll(db), sql: sql)
}
}
}