From 57d0c27fd2821d3cc984538486c08112ad0ad8d7 Mon Sep 17 00:00:00 2001 From: Tibor Bodecs Date: Thu, 19 Feb 2026 10:28:48 +0100 Subject: [PATCH 1/2] apply naming conventions --- Makefile | 2 +- Package.resolved | 18 ++ Package.swift | 12 +- README.md | 29 +-- .../DatabaseClientSQLite.swift} | 14 +- .../DatabaseConnectionSQLite.swift} | 10 +- .../DatabaseRowSQLite.swift} | 6 +- .../DatabaseRowSequenceSQLite.swift} | 8 +- .../DatabaseServiceSQLite.swift} | 6 +- .../DatabaseTransactionErrorSQLite.swift} | 6 +- Sources/SQLiteNIOExtras/SQLiteClient.swift | 2 +- .../SQLiteConnectionPool.swift | 2 +- .../SQLiteConnectionPoolError.swift | 2 +- .../SQLiteTransactionError.swift | 2 +- .../FeatherDatabaseSQLiteTestSuite.swift} | 167 ++++++++++++++++-- .../SQLiteDatabaseRowSequenceTests.swift | 154 ---------------- .../SQLiteNIOExtrasTestSuite.swift | 2 +- 17 files changed, 223 insertions(+), 219 deletions(-) rename Sources/{FeatherSQLiteDatabase/SQLiteDatabaseClient.swift => FeatherDatabaseSQLite/DatabaseClientSQLite.swift} (88%) rename Sources/{FeatherSQLiteDatabase/SQLiteDatabaseConnection.swift => FeatherDatabaseSQLite/DatabaseConnectionSQLite.swift} (90%) rename Sources/{FeatherSQLiteDatabase/SQLiteDatabaseRow.swift => FeatherDatabaseSQLite/DatabaseRowSQLite.swift} (97%) rename Sources/{FeatherSQLiteDatabase/SQLiteDatabaseRowSequence.swift => FeatherDatabaseSQLite/DatabaseRowSequenceSQLite.swift} (89%) rename Sources/{FeatherSQLiteDatabase/SQLiteDatabaseService.swift => FeatherDatabaseSQLite/DatabaseServiceSQLite.swift} (90%) rename Sources/{FeatherSQLiteDatabase/SQLiteDatabaseTransactionError.swift => FeatherDatabaseSQLite/DatabaseTransactionErrorSQLite.swift} (90%) rename Tests/{FeatherSQLiteDatabaseTests/FeatherSQLiteDatabaseTestSuite.swift => FeatherDatabaseSQLiteTests/FeatherDatabaseSQLiteTestSuite.swift} (89%) delete mode 100644 Tests/FeatherSQLiteDatabaseTests/SQLiteDatabaseRowSequenceTests.swift diff --git a/Makefile b/Makefile index 2c60fcf..a884bce 100644 --- a/Makefile +++ b/Makefile @@ -44,4 +44,4 @@ test: swift test --parallel docker-test: - docker build -t feather-sqlite-database-tests . -f ./docker/tests/Dockerfile && docker run --rm feather-sqlite-database-tests + docker build -t feather-database-sqlite-tests . -f ./docker/tests/Dockerfile && docker run --rm feather-database-sqlite-tests diff --git a/Package.resolved b/Package.resolved index e999eda..80425a7 100644 --- a/Package.resolved +++ b/Package.resolved @@ -19,6 +19,15 @@ "version" : "1.12.3" } }, + { + "identity" : "swift-async-algorithms", + "kind" : "remoteSourceControl", + "location" : "https://github.com/apple/swift-async-algorithms.git", + "state" : { + "revision" : "2971dd5d9f6e0515664b01044826bcea16e59fac", + "version" : "1.1.2" + } + }, { "identity" : "swift-atomics", "kind" : "remoteSourceControl", @@ -55,6 +64,15 @@ "version" : "2.94.0" } }, + { + "identity" : "swift-service-lifecycle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/swift-server/swift-service-lifecycle", + "state" : { + "revision" : "1de37290c0ab3c5a96028e0f02911b672fd42348", + "version" : "2.9.1" + } + }, { "identity" : "swift-system", "kind" : "remoteSourceControl", diff --git a/Package.swift b/Package.swift index a623bab..fa1734d 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ var defaultSwiftSettings: [SwiftSetting] = // https://forums.swift.org/t/experimental-support-for-lifetime-dependencies-in-swift-6-2-and-beyond/78638 .enableExperimentalFeature("Lifetimes"), // https://github.com/swiftlang/swift/pull/65218 - .enableExperimentalFeature("AvailabilityMacro=featherSQLiteDatabase 1.0:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"), + .enableExperimentalFeature("AvailabilityMacro=FeatherDatabaseSQLite 1.0:macOS 15.0, iOS 18.0, tvOS 18.0, watchOS 11.0, visionOS 2.0"), ] #if compiler(>=6.2) @@ -23,7 +23,7 @@ defaultSwiftSettings.append( let package = Package( - name: "feather-sqlite-database", + name: "feather-database-sqlite", platforms: [ .macOS(.v15), .iOS(.v18), @@ -32,7 +32,7 @@ let package = Package( .visionOS(.v2), ], products: [ - .library(name: "FeatherSQLiteDatabase", targets: ["FeatherSQLiteDatabase"]), + .library(name: "FeatherDatabaseSQLite", targets: ["FeatherDatabaseSQLite"]), ], traits: [ "ServiceLifecycleSupport", @@ -59,7 +59,7 @@ let package = Package( swiftSettings: defaultSwiftSettings ), .target( - name: "FeatherSQLiteDatabase", + name: "FeatherDatabaseSQLite", dependencies: [ .target(name: "SQLiteNIOExtras"), .product(name: "FeatherDatabase", package: "feather-database"), @@ -79,9 +79,9 @@ let package = Package( swiftSettings: defaultSwiftSettings ), .testTarget( - name: "FeatherSQLiteDatabaseTests", + name: "FeatherDatabaseSQLiteTests", dependencies: [ - .target(name: "FeatherSQLiteDatabase"), + .target(name: "FeatherDatabaseSQLite"), .product( name: "ServiceLifecycleTestKit", package: "swift-service-lifecycle", diff --git a/README.md b/README.md index 6abb512..a62bab3 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,9 @@ SQLite driver implementation for the abstract [Feather Database](https://github.com/feather-framework/feather-database) Swift API package. [ - ![Release: 1.0.0-beta.7](https://img.shields.io/badge/Release-1%2E0%2E0--beta%2E7-F05138) + ![Release: 1.0.0-beta.8](https://img.shields.io/badge/Release-1%2E0%2E0--beta%2E8-F05138) ]( - https://github.com/feather-framework/feather-sqlite-database/releases/tag/1.0.0-beta.7 + https://github.com/feather-framework/feather-database-sqlite/releases/tag/1.0.0-beta.8 ) ## Features @@ -36,13 +36,13 @@ SQLite driver implementation for the abstract [Feather Database](https://github. Add the dependency to your `Package.swift`: ```swift -.package(url: "https://github.com/feather-framework/feather-sqlite-database", exact: "1.0.0-beta.5"), +.package(url: "https://github.com/feather-framework/feather-database-sqlite", exact: "1.0.0-beta.8"), ``` -Then add `FeatherSQLiteDatabase` to your target dependencies: +Then add `FeatherDatabaseSQLite` to your target dependencies: ```swift -.product(name: "FeatherSQLiteDatabase", package: "feather-sqlite-database"), +.product(name: "FeatherDatabaseSQLite", package: "feather-database-sqlite"), ``` ### Package traits @@ -52,8 +52,8 @@ To enable an additional trait on the package, update the package dependency: ```diff .package( - url: "https://github.com/feather-framework/feather-sqlite-database", - exact: "1.0.0-beta.4", + url: "https://github.com/feather-framework/feather-database-sqlite", + exact: "1.0.0-beta.8", + traits: [ + .defaults, + "ServiceLifecycleSupport", @@ -63,7 +63,7 @@ To enable an additional trait on the package, update the package dependency: Available traits: -- `ServiceLifecycleSupport` (default): Adds support for `SQLiteClientService`, a `ServiceLifecycle.Service` implementation for managing SQLite clients. +- `ServiceLifecycleSupport` (default): Adds support for `DatabaseServiceSQLite`, a `ServiceLifecycle.Service` implementation for managing SQLite clients. ## Usage @@ -73,7 +73,7 @@ API documentation is available at the link below: [ ![DocC API documentation](https://img.shields.io/badge/DocC-API_documentation-F05138) ]( - https://feather-framework.github.io/feather-sqlite-database/ + https://feather-framework.github.io/feather-database-sqlite/ ) Here is a brief example: @@ -81,8 +81,9 @@ Here is a brief example: ```swift import Logging import SQLiteNIO +import SQLiteNIOExtras import FeatherDatabase -import FeatherSQLiteDatabase +import FeatherDatabaseSQLite var logger = Logger(label: "example") logger.logLevel = .info @@ -94,7 +95,7 @@ let configuration = SQLiteClient.Configuration( let client = SQLiteClient(configuration: configuration) -let database = SQLiteDatabaseClient( +let database = DatabaseClientSQLite( client: client, logger: logger ) @@ -127,8 +128,8 @@ await client.shutdown() The following database driver implementations are available for use: -- [Postgres](https://github.com/feather-framework/feather-postgres-database) -- [MySQL](https://github.com/feather-framework/feather-mysql-database) +- [Postgres](https://github.com/feather-framework/feather-database-postgres) +- [MySQL](https://github.com/feather-framework/feather-database-mysql) ## Development @@ -141,4 +142,4 @@ The following database driver implementations are available for use: ## Contributing -[Pull requests](https://github.com/feather-framework/feather-sqlite-database/pulls) are welcome. Please keep changes focused and include tests for new logic. +[Pull requests](https://github.com/feather-framework/feather-database-sqlite/pulls) are welcome. Please keep changes focused and include tests for new logic. diff --git a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseClient.swift b/Sources/FeatherDatabaseSQLite/DatabaseClientSQLite.swift similarity index 88% rename from Sources/FeatherSQLiteDatabase/SQLiteDatabaseClient.swift rename to Sources/FeatherDatabaseSQLite/DatabaseClientSQLite.swift index ef17fcd..c001be6 100644 --- a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseClient.swift +++ b/Sources/FeatherDatabaseSQLite/DatabaseClientSQLite.swift @@ -1,6 +1,6 @@ // -// SQLiteDatabaseClient.swift -// feather-sqlite-database +// DatabaseClientSQLite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10.. // @@ -12,9 +12,9 @@ import SQLiteNIOExtras /// A SQLite-backed database client. /// /// Use this client to execute queries and manage transactions on SQLite. -public struct SQLiteDatabaseClient: DatabaseClient { +public struct DatabaseClientSQLite: DatabaseClient { - public typealias Connection = SQLiteDatabaseConnection + public typealias Connection = DatabaseConnectionSQLite let client: SQLiteClient var logger: Logger @@ -47,7 +47,7 @@ public struct SQLiteDatabaseClient: DatabaseClient { do { return try await client.withConnection { connection in try await closure( - SQLiteDatabaseConnection( + DatabaseConnectionSQLite( connection: connection, logger: logger ) @@ -72,7 +72,7 @@ public struct SQLiteDatabaseClient: DatabaseClient { do { return try await client.withTransaction { connection in try await closure( - SQLiteDatabaseConnection( + DatabaseConnectionSQLite( connection: connection, logger: logger ) @@ -81,7 +81,7 @@ public struct SQLiteDatabaseClient: DatabaseClient { } catch let error as SQLiteTransactionError { throw .transaction( - SQLiteDatabaseTransactionError( + DatabaseTransactionErrorSQLite( underlyingError: error ) ) diff --git a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseConnection.swift b/Sources/FeatherDatabaseSQLite/DatabaseConnectionSQLite.swift similarity index 90% rename from Sources/FeatherSQLiteDatabase/SQLiteDatabaseConnection.swift rename to Sources/FeatherDatabaseSQLite/DatabaseConnectionSQLite.swift index c3d7528..2716b6c 100644 --- a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseConnection.swift +++ b/Sources/FeatherDatabaseSQLite/DatabaseConnectionSQLite.swift @@ -1,6 +1,6 @@ // -// SQLiteDatabaseConnection.swift -// feather-sqlite-database +// DatabaseConnectionSQLite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10. // @@ -45,9 +45,9 @@ extension DatabaseQuery { } } -public struct SQLiteDatabaseConnection: DatabaseConnection { +public struct DatabaseConnectionSQLite: DatabaseConnection { - public typealias RowSequence = SQLiteDatabaseRowSequence + public typealias RowSequence = DatabaseRowSequenceSQLite var connection: SQLiteConnection public var logger: Logger @@ -72,7 +72,7 @@ public struct SQLiteDatabaseConnection: DatabaseConnection { sqliteQuery.bindings ) return try await handler( - SQLiteDatabaseRowSequence( + DatabaseRowSequenceSQLite( elements: result.map { .init(row: $0) } diff --git a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseRow.swift b/Sources/FeatherDatabaseSQLite/DatabaseRowSQLite.swift similarity index 97% rename from Sources/FeatherSQLiteDatabase/SQLiteDatabaseRow.swift rename to Sources/FeatherDatabaseSQLite/DatabaseRowSQLite.swift index 3203bf5..6ee4aba 100644 --- a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseRow.swift +++ b/Sources/FeatherDatabaseSQLite/DatabaseRowSQLite.swift @@ -1,6 +1,6 @@ // -// SQLiteDatabaseRow.swift -// feather-sqlite-database +// DatabaseRowSQLite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10. // @@ -8,7 +8,7 @@ import FeatherDatabase import SQLiteNIO -public struct SQLiteDatabaseRow: DatabaseRow { +public struct DatabaseRowSQLite: DatabaseRow { var row: SQLiteRow struct SingleValueDecoder: Decoder, SingleValueDecodingContainer { diff --git a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseRowSequence.swift b/Sources/FeatherDatabaseSQLite/DatabaseRowSequenceSQLite.swift similarity index 89% rename from Sources/FeatherSQLiteDatabase/SQLiteDatabaseRowSequence.swift rename to Sources/FeatherDatabaseSQLite/DatabaseRowSequenceSQLite.swift index a18a6a3..3a70ff8 100644 --- a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseRowSequence.swift +++ b/Sources/FeatherDatabaseSQLite/DatabaseRowSequenceSQLite.swift @@ -1,6 +1,6 @@ // -// SQLiteDatabaseRowSequence.swift -// feather-sqlite-database +// DatabaseRowSequenceSQLite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10. // @@ -11,8 +11,8 @@ import SQLiteNIO /// A query result backed by SQLite rows. /// /// Use this type to iterate or collect SQLite query results. -public struct SQLiteDatabaseRowSequence: DatabaseRowSequence { - public typealias Row = SQLiteDatabaseRow +public struct DatabaseRowSequenceSQLite: DatabaseRowSequence { + public typealias Row = DatabaseRowSQLite let elements: [Row] diff --git a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseService.swift b/Sources/FeatherDatabaseSQLite/DatabaseServiceSQLite.swift similarity index 90% rename from Sources/FeatherSQLiteDatabase/SQLiteDatabaseService.swift rename to Sources/FeatherDatabaseSQLite/DatabaseServiceSQLite.swift index d79ec54..4998647 100644 --- a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseService.swift +++ b/Sources/FeatherDatabaseSQLite/DatabaseServiceSQLite.swift @@ -1,6 +1,6 @@ // -// SQLiteDatabaseService.swift -// feather-sqlite-database +// DatabaseServiceSQLite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 29.. // @@ -11,7 +11,7 @@ import SQLiteNIOExtras import ServiceLifecycle /// A `Service` wrapper around an `SQLiteClient`. -public struct SQLiteDatabaseService: Service { +public struct DatabaseServiceSQLite: Service { /// The underlying SQLite client instance. public var client: SQLiteClient diff --git a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseTransactionError.swift b/Sources/FeatherDatabaseSQLite/DatabaseTransactionErrorSQLite.swift similarity index 90% rename from Sources/FeatherSQLiteDatabase/SQLiteDatabaseTransactionError.swift rename to Sources/FeatherDatabaseSQLite/DatabaseTransactionErrorSQLite.swift index 926137f..52347a2 100644 --- a/Sources/FeatherSQLiteDatabase/SQLiteDatabaseTransactionError.swift +++ b/Sources/FeatherDatabaseSQLite/DatabaseTransactionErrorSQLite.swift @@ -1,6 +1,6 @@ // -// SQLiteDatabaseTransactionError.swift -// feather-sqlite-database +// DatabaseTransactionErrorSQLite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10. // @@ -11,7 +11,7 @@ import SQLiteNIOExtras /// Transaction error details for SQLite operations. /// /// Use this to capture errors from transaction phases. -public struct SQLiteDatabaseTransactionError: DatabaseTransactionError { +public struct DatabaseTransactionErrorSQLite: DatabaseTransactionError { var underlyingError: SQLiteTransactionError diff --git a/Sources/SQLiteNIOExtras/SQLiteClient.swift b/Sources/SQLiteNIOExtras/SQLiteClient.swift index d0c8c57..a57dab1 100644 --- a/Sources/SQLiteNIOExtras/SQLiteClient.swift +++ b/Sources/SQLiteNIOExtras/SQLiteClient.swift @@ -1,6 +1,6 @@ // // SQLiteClient.swift -// feather-sqlite-database +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 26.. // diff --git a/Sources/SQLiteNIOExtras/SQLiteConnectionPool.swift b/Sources/SQLiteNIOExtras/SQLiteConnectionPool.swift index f11ac60..308c28e 100644 --- a/Sources/SQLiteNIOExtras/SQLiteConnectionPool.swift +++ b/Sources/SQLiteNIOExtras/SQLiteConnectionPool.swift @@ -1,6 +1,6 @@ // // SQLiteConnectionPool.swift -// feather-sqlite-database +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 26.. // diff --git a/Sources/SQLiteNIOExtras/SQLiteConnectionPoolError.swift b/Sources/SQLiteNIOExtras/SQLiteConnectionPoolError.swift index 6cf2f80..336a1db 100644 --- a/Sources/SQLiteNIOExtras/SQLiteConnectionPoolError.swift +++ b/Sources/SQLiteNIOExtras/SQLiteConnectionPoolError.swift @@ -1,6 +1,6 @@ // // SQLiteConnectionPoolError.swift -// feather-sqlite-database +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 02. 02.. // diff --git a/Sources/SQLiteNIOExtras/SQLiteTransactionError.swift b/Sources/SQLiteNIOExtras/SQLiteTransactionError.swift index f0b38b3..be55bcd 100644 --- a/Sources/SQLiteNIOExtras/SQLiteTransactionError.swift +++ b/Sources/SQLiteNIOExtras/SQLiteTransactionError.swift @@ -1,6 +1,6 @@ // // SQLiteTransactionError.swift -// feather-sqlite-database +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 02. 03.. // diff --git a/Tests/FeatherSQLiteDatabaseTests/FeatherSQLiteDatabaseTestSuite.swift b/Tests/FeatherDatabaseSQLiteTests/FeatherDatabaseSQLiteTestSuite.swift similarity index 89% rename from Tests/FeatherSQLiteDatabaseTests/FeatherSQLiteDatabaseTestSuite.swift rename to Tests/FeatherDatabaseSQLiteTests/FeatherDatabaseSQLiteTestSuite.swift index 55c1cb3..a9446d5 100644 --- a/Tests/FeatherSQLiteDatabaseTests/FeatherSQLiteDatabaseTestSuite.swift +++ b/Tests/FeatherDatabaseSQLiteTests/FeatherDatabaseSQLiteTestSuite.swift @@ -1,6 +1,6 @@ // -// FeatherSQLiteDatabaseTestSuite.swift -// feather-sqlite-database +// FeatherDatabaseSQLiteTestSuite.swift +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10.. // @@ -10,7 +10,7 @@ import Logging import SQLiteNIO import Testing -@testable import FeatherSQLiteDatabase +@testable import FeatherDatabaseSQLite @testable import SQLiteNIOExtras #if ServiceLifecycleSupport @@ -18,10 +18,10 @@ import ServiceLifecycleTestKit #endif @Suite -struct FeatherSQLiteDatabaseTestSuite { +struct FeatherDatabaseSQLiteTestSuite { func runUsingTestDatabaseClient( - _ closure: ((SQLiteDatabaseClient) async throws -> Void) + _ closure: ((DatabaseClientSQLite) async throws -> Void) ) async throws { var logger = Logger(label: "test") logger.logLevel = .info @@ -33,7 +33,7 @@ struct FeatherSQLiteDatabaseTestSuite { let client = SQLiteClient(configuration: configuration) - let database = SQLiteDatabaseClient( + let database = DatabaseClientSQLite( client: client, logger: logger ) @@ -1126,12 +1126,151 @@ struct FeatherSQLiteDatabaseTestSuite { } } } + + @Test + func rowSequenceIteratesRowsInOrder() async throws { + try await runUsingTestDatabaseClient { database in + try await database.withConnection { connection in + try await connection.run( + query: #""" + CREATE TABLE IF NOT EXISTS "planets" ( + "id" INTEGER PRIMARY KEY, + "name" TEXT + ); + """# + ) + + try await connection.run( + query: #""" + INSERT INTO "planets" ("id", "name") + VALUES + (1, 'Mercury'), + (2, 'Venus'); + """# + ) + + let sequence = try await connection.run( + query: #""" + SELECT * + FROM "planets" + ORDER BY "id" ASC; + """# + ) + + var iterator = sequence.makeAsyncIterator() + + let first = await iterator.next() + #expect(first != nil) + #expect( + try first?.decode(column: "name", as: String.self) + == "Mercury" + ) + + let second = await iterator.next() + #expect(second != nil) + #expect( + try second?.decode(column: "name", as: String.self) + == "Venus" + ) + + let third = await iterator.next() + #expect(third == nil) + } + } + } + + @Test + func rowSequenceCollectReturnsAllRows() async throws { + try await runUsingTestDatabaseClient { database in + try await database.withConnection { connection in + try await connection.run( + query: #""" + CREATE TABLE IF NOT EXISTS "greetings" ( + "id" INTEGER PRIMARY KEY, + "name" TEXT + ); + """# + ) + + try await connection.run( + query: #""" + INSERT INTO "greetings" ("id", "name") + VALUES + (1, 'Hello'), + (2, 'World'); + """# + ) + + let sequence = try await connection.run( + query: #""" + SELECT + "id", + "name" + FROM "greetings" + ORDER BY "id" ASC; + """# + ) + + let rows = try await sequence.collect() + #expect(rows.count == 2) + + let firstName = try rows[0] + .decode( + column: "name", + as: String.self + ) + let secondName = try rows[1] + .decode( + column: "name", + as: String.self + ) + + #expect(firstName == "Hello") + #expect(secondName == "World") + } + } + } + + @Test + func rowSequenceHandlesEmptyResults() async throws { + try await runUsingTestDatabaseClient { database in + try await database.withConnection { connection in + try await connection.run( + query: #""" + CREATE TABLE IF NOT EXISTS "empty_rows" ( + "id" INTEGER PRIMARY KEY, + "name" TEXT + ); + """# + ) + + let sequence = try await connection.run( + query: #""" + SELECT + "id", + "name" + FROM "empty_rows" + WHERE + 1=0; + """# + ) + + let rows = try await sequence.collect() + #expect(rows.isEmpty) + + var iterator = sequence.makeAsyncIterator() + let first = await iterator.next() + #expect(first == nil) + } + } + } + } #if ServiceLifecycleSupport import ServiceLifecycle -extension FeatherSQLiteDatabaseTestSuite { +extension FeatherDatabaseSQLiteTestSuite { @Test func serviceLifecycleSupport() async throws { @@ -1143,8 +1282,8 @@ extension FeatherSQLiteDatabaseTestSuite { logger: logger, ) let client = SQLiteClient(configuration: configuration) - let database = SQLiteDatabaseClient(client: client, logger: logger) - let service = SQLiteDatabaseService(client) + let database = DatabaseClientSQLite(client: client, logger: logger) + let service = DatabaseServiceSQLite(client) let serviceGroup = ServiceGroup( services: [service], @@ -1195,7 +1334,7 @@ extension FeatherSQLiteDatabaseTestSuite { logger: logger ) let client = SQLiteClient(configuration: configuration) - let service = SQLiteDatabaseService(client) + let service = DatabaseServiceSQLite(client) try await withThrowingTaskGroup(of: Void.self) { group in group.addTask { @@ -1232,7 +1371,7 @@ extension FeatherSQLiteDatabaseTestSuite { logger: logger ) let client = SQLiteClient(configuration: configuration) - let service = SQLiteDatabaseService(client) + let service = DatabaseServiceSQLite(client) let serviceGroup = ServiceGroup( services: [service], logger: logger @@ -1273,7 +1412,7 @@ extension FeatherSQLiteDatabaseTestSuite { logger: logger ) let client = SQLiteClient(configuration: configuration) - let database = SQLiteDatabaseClient( + let database = DatabaseClientSQLite( client: client, logger: logger ) @@ -1308,7 +1447,7 @@ extension FeatherSQLiteDatabaseTestSuite { configuration: .init( services: [ .init( - service: SQLiteDatabaseService(client) + service: DatabaseServiceSQLite(client) ), .init( service: MigrationService(database: database), @@ -1342,7 +1481,7 @@ extension FeatherSQLiteDatabaseTestSuite { logger: logger ) let client = SQLiteClient(configuration: configuration) - let service = SQLiteDatabaseService(client) + let service = DatabaseServiceSQLite(client) try await testGracefulShutdown { trigger in try await withThrowingTaskGroup { group in diff --git a/Tests/FeatherSQLiteDatabaseTests/SQLiteDatabaseRowSequenceTests.swift b/Tests/FeatherSQLiteDatabaseTests/SQLiteDatabaseRowSequenceTests.swift deleted file mode 100644 index 6662a8c..0000000 --- a/Tests/FeatherSQLiteDatabaseTests/SQLiteDatabaseRowSequenceTests.swift +++ /dev/null @@ -1,154 +0,0 @@ -// -// SQLiteDatabaseRowSequenceTests.swift -// feather-sqlite-database -// -// Created by Tibor Bödecs on 2026. 02. 09. -// - -import FeatherDatabase -import SQLiteNIO -import SQLiteNIOExtras -import Testing - -@testable import FeatherSQLiteDatabase - -extension FeatherSQLiteDatabaseTestSuite { - - @Test - func rowSequenceIteratesRowsInOrder() async throws { - try await runUsingTestDatabaseClient { database in - try await database.withConnection { connection in - try await connection.run( - query: #""" - CREATE TABLE IF NOT EXISTS "planets" ( - "id" INTEGER PRIMARY KEY, - "name" TEXT - ); - """# - ) - - try await connection.run( - query: #""" - INSERT INTO "planets" ("id", "name") - VALUES - (1, 'Mercury'), - (2, 'Venus'); - """# - ) - - let sequence = try await connection.run( - query: #""" - SELECT * - FROM "planets" - ORDER BY "id" ASC; - """# - ) - - var iterator = sequence.makeAsyncIterator() - - let first = await iterator.next() - #expect(first != nil) - #expect( - try first?.decode(column: "name", as: String.self) - == "Mercury" - ) - - let second = await iterator.next() - #expect(second != nil) - #expect( - try second?.decode(column: "name", as: String.self) - == "Venus" - ) - - let third = await iterator.next() - #expect(third == nil) - } - } - } - - @Test - func rowSequenceCollectReturnsAllRows() async throws { - try await runUsingTestDatabaseClient { database in - try await database.withConnection { connection in - try await connection.run( - query: #""" - CREATE TABLE IF NOT EXISTS "greetings" ( - "id" INTEGER PRIMARY KEY, - "name" TEXT - ); - """# - ) - - try await connection.run( - query: #""" - INSERT INTO "greetings" ("id", "name") - VALUES - (1, 'Hello'), - (2, 'World'); - """# - ) - - let sequence = try await connection.run( - query: #""" - SELECT - "id", - "name" - FROM "greetings" - ORDER BY "id" ASC; - """# - ) - - let rows = try await sequence.collect() - #expect(rows.count == 2) - - let firstName = try rows[0] - .decode( - column: "name", - as: String.self - ) - let secondName = try rows[1] - .decode( - column: "name", - as: String.self - ) - - #expect(firstName == "Hello") - #expect(secondName == "World") - } - } - } - - @Test - func rowSequenceHandlesEmptyResults() async throws { - try await runUsingTestDatabaseClient { database in - try await database.withConnection { connection in - try await connection.run( - query: #""" - CREATE TABLE IF NOT EXISTS "empty_rows" ( - "id" INTEGER PRIMARY KEY, - "name" TEXT - ); - """# - ) - - let sequence = try await connection.run( - query: #""" - SELECT - "id", - "name" - FROM "empty_rows" - WHERE - 1=0; - """# - ) - - let rows = try await sequence.collect() - #expect(rows.isEmpty) - - var iterator = sequence.makeAsyncIterator() - let first = await iterator.next() - #expect(first == nil) - } - } - } -} diff --git a/Tests/SQLiteNIOExtrasTests/SQLiteNIOExtrasTestSuite.swift b/Tests/SQLiteNIOExtrasTests/SQLiteNIOExtrasTestSuite.swift index 6999413..009769c 100644 --- a/Tests/SQLiteNIOExtrasTests/SQLiteNIOExtrasTestSuite.swift +++ b/Tests/SQLiteNIOExtrasTests/SQLiteNIOExtrasTestSuite.swift @@ -1,6 +1,6 @@ // // SQLiteNIOExtrasTestSuite.swift -// feather-sqlite-database +// feather-database-sqlite // // Created by Tibor Bödecs on 2026. 01. 10.. // From 4a6b192da00ecd663e898f1509b208f1d1acbac8 Mon Sep 17 00:00:00 2001 From: Tibor Bodecs Date: Thu, 19 Feb 2026 10:30:50 +0100 Subject: [PATCH 2/2] fix reamde --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a62bab3..046b816 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Feather SQLite Database +# Feather Database SQLite SQLite driver implementation for the abstract [Feather Database](https://github.com/feather-framework/feather-database) Swift API package.