From b2286aaaabb2869337a6ec5831bc2048e9563bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 25 Aug 2024 13:07:22 +0200 Subject: [PATCH] DatabaseCursor has a primary associated type --- GRDB/Core/Statement.swift | 2 +- TODO.md | 2 +- Tests/GRDBTests/DatabaseCursorTests.swift | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index 698855b19..395688709 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -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: Cursor { /// Must be initialized to false. var _isDone: Bool { get set } diff --git a/TODO.md b/TODO.md index e2e85fa2b..06c27e3f0 100644 --- a/TODO.md +++ b/TODO.md @@ -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) diff --git a/Tests/GRDBTests/DatabaseCursorTests.swift b/Tests/GRDBTests/DatabaseCursorTests.swift index d18191488..19e53f370 100644 --- a/Tests/GRDBTests/DatabaseCursorTests.swift +++ b/Tests/GRDBTests/DatabaseCursorTests.swift @@ -213,6 +213,15 @@ class DatabaseCursorTests: GRDBTestCase { // } } + // This test passes if it compiles + func testAssociatedType() throws { + func accept(_ cursor: some DatabaseCursor) { } + func useCursor(_ db: Database) throws { + let cursor = try String.fetchCursor(db, sql: "SELECT 'foo'") + accept(cursor) + } + } + // For profiling tests let profilingSQL = """ WITH RECURSIVE