Skip to content

Commit

Permalink
DatabaseCursor has a primary associated type
Browse files Browse the repository at this point in the history
  • Loading branch information
groue committed Aug 25, 2024
1 parent 490b4e5 commit be57748
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion GRDB/Core/Statement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ extension Statement {
/// [`sqlite3_reset`](https://www.sqlite.org/c3ref/reset.html) when the cursor
/// is created, and when it is deallocated. Don't share the same prepared
/// statement between two cursors!
public protocol DatabaseCursor: Cursor {
public protocol DatabaseCursor<Element>: Cursor {
/// Must be initialized to false.
var _isDone: Bool { get set }

Expand Down
9 changes: 9 additions & 0 deletions Tests/GRDBTests/DatabaseCursorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ class DatabaseCursorTests: GRDBTestCase {
// }
}

// This test passes if it compiles
func testAssociatedType() throws {
func accept(_ cursor: some DatabaseCursor<String>) { }
func useCursor(_ db: Database) throws {
let cursor = try String.fetchCursor(db, sql: "SELECT 'foo'")
accept(cursor)
}
}

// For profiling tests
let profilingSQL = """
WITH RECURSIVE
Expand Down

0 comments on commit be57748

Please sign in to comment.