         XCTAssertFalse(s.fetched)
     }
     
-    func testFetchFromSQL() {
-        assertNoError {
-            let dbQueue = try makeDatabaseQueue()
-            try dbQueue.inDatabase { db in
-                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
-                let ss = SimpleRowConvertible.fetch(db, "SELECT * FROM structs")
-                let s = Array(ss).first!
-                XCTAssertEqual(s.firstName, "Arthur")
-                XCTAssertEqual(s.lastName, "Martin")
-                XCTAssertTrue(s.fetched)
-            }
-        }
-    }
-    
-    func testFetchAllFromSQL() {
-        assertNoError {
-            let dbQueue = try makeDatabaseQueue()
-            try dbQueue.inDatabase { db in
-                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
-                let ss = SimpleRowConvertible.fetchAll(db, "SELECT * FROM structs")
-                let s = ss.first!
-                XCTAssertEqual(s.firstName, "Arthur")
-                XCTAssertEqual(s.lastName, "Martin")
-                XCTAssertTrue(s.fetched)
-            }
-        }
-    }
-    
-    func testFetchOneFromSQL() {
-        assertNoError {
-            let dbQueue = try makeDatabaseQueue()
-            try dbQueue.inDatabase { db in
-                let missingS = SimpleRowConvertible.fetchOne(db, "SELECT * FROM structs")
-                XCTAssertTrue(missingS == nil)
-                
-                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
-                let s = SimpleRowConvertible.fetchOne(db, "SELECT * FROM structs")!
-                XCTAssertEqual(s.firstName, "Arthur")
-                XCTAssertEqual(s.lastName, "Martin")
-                XCTAssertTrue(s.fetched)
-            }
-        }
-    }
-    
-    func testFetchFromSQLWithAdapter() {
-        assertNoError {
-            let dbQueue = try makeDatabaseQueue()
-            dbQueue.inDatabase { db in
-                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
-                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
-                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
-                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
-                let ss = Person.fetch(db, sql, arguments: arguments, adapter: adapter)
-                let s = Array(ss).first!
-                XCTAssertEqual(s.firstName, "Stan")
-                XCTAssertEqual(s.lastName, "Laurel")
-                XCTAssertTrue(s.fetched)
-                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
-                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
-                XCTAssertTrue(s.bestFriend!.fetched)
-            }
-        }
-    }
-    
-    func testFetchAllFromSQLWithAdapter() {
-        assertNoError {
-            let dbQueue = try makeDatabaseQueue()
-            dbQueue.inDatabase { db in
-                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
-                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
-                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
-                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
-                let ss = Person.fetchAll(db, sql, arguments: arguments, adapter: adapter)
-                let s = ss.first!
-                XCTAssertEqual(s.firstName, "Stan")
-                XCTAssertEqual(s.lastName, "Laurel")
-                XCTAssertTrue(s.fetched)
-                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
-                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
-                XCTAssertTrue(s.bestFriend!.fetched)
-            }
-        }
-    }
-    
-    func testFetchOneFromSQLWithAdapter() {
-        assertNoError {
-            let dbQueue = try makeDatabaseQueue()
-            dbQueue.inDatabase { db in
-                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
-                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
-                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
-                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
-                let s = Person.fetchOne(db, sql, arguments: arguments, adapter: adapter)!
-                XCTAssertEqual(s.firstName, "Stan")
-                XCTAssertEqual(s.lastName, "Laurel")
-                XCTAssertTrue(s.fetched)
-                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
-                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
-                XCTAssertTrue(s.bestFriend!.fetched)
-            }
-        }
-    }
-    
-    func testFetchFromStatement() {
+    func testFetchCursorFromStatement() {
+        assertNoError {
+            let dbQueue = try makeDatabaseQueue()
+            try dbQueue.inDatabase { db in
+                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
+                let statement = try db.makeSelectStatement("SELECT * FROM structs")
+                let cursor = try SimpleRowConvertible.fetchCursor(statement)
+                let s = try cursor.next()!
+                XCTAssertEqual(s.firstName, "Arthur")
+                XCTAssertEqual(s.lastName, "Martin")
+                XCTAssertTrue(s.fetched)
+            }
+        }
+    }
+    
+    func testFetchCursorFromStatementWithAdapter() {
+        assertNoError {
+            let dbQueue = try makeDatabaseQueue()
+            try dbQueue.inDatabase { db in
+                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
+                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
+                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
+                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
+                let statement = try db.makeSelectStatement(sql)
+                let cursor = try Person.fetchCursor(statement, arguments: arguments, adapter: adapter)
+                let s = try cursor.next()!
+                XCTAssertEqual(s.firstName, "Stan")
+                XCTAssertEqual(s.lastName, "Laurel")
+                XCTAssertTrue(s.fetched)
+                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
+                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
+                XCTAssertTrue(s.bestFriend!.fetched)
+            }
+        }
+    }
+    
+    func testFetchSequenceFromStatement() {
         assertNoError {
             let dbQueue = try makeDatabaseQueue()
             try dbQueue.inDatabase { db in

                XCTAssertEqual(s.firstName, "Arthur")
                XCTAssertEqual(s.lastName, "Martin")
                XCTAssertTrue(s.fetched)
            }
        }
    }

            }
        }
    }
    
    func testFetchCursorFromSQL() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            try dbQueue.inDatabase { db in
                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
                let cursor = try SimpleRowConvertible.fetchCursor(db, "SELECT * FROM structs")
                let s = try cursor.next()!
                XCTAssertEqual(s.firstName, "Arthur")
                XCTAssertEqual(s.lastName, "Martin")
                XCTAssertTrue(s.fetched)
            }
        }
    }
    
    func testFetchCursorFromSQLWithAdapter() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            try dbQueue.inDatabase { db in
                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                let cursor = try Person.fetchCursor(db, sql, arguments: arguments, adapter: adapter)
                let s = try cursor.next()!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
    
    func testFetchSequenceFromSQL() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            try dbQueue.inDatabase { db in
                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
                let ss = SimpleRowConvertible.fetch(db, "SELECT * FROM structs")
                let s = Array(ss).first!
                XCTAssertEqual(s.firstName, "Arthur")
                XCTAssertEqual(s.lastName, "Martin")
                XCTAssertTrue(s.fetched)
            }
        }
    }
    
    func testFetchSequenceFromSQLWithAdapter() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            dbQueue.inDatabase { db in
                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                let ss = Person.fetch(db, sql, arguments: arguments, adapter: adapter)
                let s = Array(ss).first!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
    
    func testFetchAllFromSQL() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            try dbQueue.inDatabase { db in
                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
                let ss = SimpleRowConvertible.fetchAll(db, "SELECT * FROM structs")
                let s = ss.first!
                XCTAssertEqual(s.firstName, "Arthur")
                XCTAssertEqual(s.lastName, "Martin")
                XCTAssertTrue(s.fetched)
            }
        }
    }
    
    func testFetchAllFromSQLWithAdapter() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            dbQueue.inDatabase { db in
                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                let ss = Person.fetchAll(db, sql, arguments: arguments, adapter: adapter)
                let s = ss.first!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
    
    func testFetchOneFromSQL() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            try dbQueue.inDatabase { db in
                let missingS = SimpleRowConvertible.fetchOne(db, "SELECT * FROM structs")
                XCTAssertTrue(missingS == nil)
                
                try db.execute("INSERT INTO structs (firstName, lastName) VALUES (?, ?)", arguments: ["Arthur", "Martin"])
                let s = SimpleRowConvertible.fetchOne(db, "SELECT * FROM structs")!
                XCTAssertEqual(s.firstName, "Arthur")
                XCTAssertEqual(s.lastName, "Martin")
                XCTAssertTrue(s.fetched)
            }
        }
    }
    
    func testFetchOneFromSQLWithAdapter() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            dbQueue.inDatabase { db in
                let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                    .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                let s = Person.fetchOne(db, sql, arguments: arguments, adapter: adapter)!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
    
    func testFetchCursorFromFetchRequest() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            try dbQueue.inDatabase { db in
                struct Request : FetchRequest {
                    func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
                        let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                            .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                        let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                        let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                        
                        let statement = try db.makeSelectStatement(sql)
                        statement.arguments = arguments
                        return (statement, adapter)
                    }
                }
                let cursor = try Person.fetchCursor(db, Request())
                let s = try cursor.next()!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
    
    func testFetchSequenceFromFetchRequest() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            dbQueue.inDatabase { db in
                struct Request : FetchRequest {
                    func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
                        let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                            .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                        let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                        let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                        
                        let statement = try db.makeSelectStatement(sql)
                        statement.arguments = arguments
                        return (statement, adapter)
                    }
                }
                let ss = Person.fetch(db, Request())
                let s = Array(ss).first!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
    
    func testFetchAllFromFetchRequest() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            dbQueue.inDatabase { db in
                struct Request : FetchRequest {
                    func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
                        let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                            .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                        let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                        let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])
                        
                        let statement = try db.makeSelectStatement(sql)
                        statement.arguments = arguments
                        return (statement, adapter)
                    }
                }
                let ss = Person.fetchAll(db, Request())
                let s = ss.first!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }

    func testFetchOneFromFetchRequest() {
        assertNoError {
            let dbQueue = try makeDatabaseQueue()
            dbQueue.inDatabase { db in
                struct Request : FetchRequest {
                    func prepare(_ db: Database) throws -> (SelectStatement, RowAdapter?) {
                        let adapter = ColumnMapping(["firstName": "firstName1", "lastName": "lastName1"])
                            .addingScopes(["bestFriend": ColumnMapping(["firstName": "firstName2", "lastName": "lastName2"])])
                        let sql = "SELECT ? AS firstName1, ? AS lastName1, ? AS firstName2, ? AS lastName2"
                        let arguments = StatementArguments(["Stan", "Laurel", "Oliver", "Hardy"])

                        let statement = try db.makeSelectStatement(sql)
                        statement.arguments = arguments
                        return (statement, adapter)
                    }
                }
                let s = Person.fetchOne(db, Request())!
                XCTAssertEqual(s.firstName, "Stan")
                XCTAssertEqual(s.lastName, "Laurel")
                XCTAssertTrue(s.fetched)
                XCTAssertEqual(s.bestFriend!.firstName, "Oliver")
                XCTAssertEqual(s.bestFriend!.lastName, "Hardy")
                XCTAssertTrue(s.bestFriend!.fetched)
            }
        }
    }
}
