Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GRDB 7: DatabaseCursor has a primary associated type #1605

Merged
merged 1 commit into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
- [ ] GRDB7: Sendable: SQL (ac33856f)
- [ ] GRDB7: Split Row.swift (2ce8a619)
- [ ] GRDB7: Cleanup ValueReducer (6c73b1c5)
- [ ] GRDB7: DatabaseCursor has a primary associated type (b11c5dd2)
- [X] GRDB7: DatabaseCursor has a primary associated type (b11c5dd2)
- [ ] GRDB7: Enable Strict Concurrency Checks (6aa43ded)
- [ ] GRDB7: Sendable: OrderedDictionary (e022c35b)
- [ ] GRDB7: Rename ReadWriteBox to ReadWriteLock (7f5205ef)
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