From 14567635e42cc2cfa399d755d308fb4bebe08735 Mon Sep 17 00:00:00 2001 From: Marc Prud'hommeaux Date: Tue, 3 Feb 2026 17:56:04 -0500 Subject: [PATCH] Android and Windows platform import/conditional accommodation --- GRDB/Core/StatementAuthorizer.swift | 2 ++ GRDB/Core/Support/Foundation/NSNumber.swift | 2 -- GRDB/Core/Support/Foundation/URL.swift | 2 -- GRDB/Core/Support/Foundation/UUID.swift | 2 -- Tests/GRDBTests/AssociationTableAliasTestsSQLTests.swift | 8 ++++---- Tests/GRDBTests/EncryptionTests.swift | 3 ++- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/GRDB/Core/StatementAuthorizer.swift b/GRDB/Core/StatementAuthorizer.swift index 6dc9c4ae5..a1e863f3d 100644 --- a/GRDB/Core/StatementAuthorizer.swift +++ b/GRDB/Core/StatementAuthorizer.swift @@ -14,6 +14,8 @@ import GRDBSQLite import string_h #elseif os(Linux) import Glibc +#elseif os(Android) +import Android #elseif os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) import Darwin #elseif os(Windows) diff --git a/GRDB/Core/Support/Foundation/NSNumber.swift b/GRDB/Core/Support/Foundation/NSNumber.swift index 3b5076fd3..b26d6ece7 100644 --- a/GRDB/Core/Support/Foundation/NSNumber.swift +++ b/GRDB/Core/Support/Foundation/NSNumber.swift @@ -1,4 +1,3 @@ -#if !os(Windows) import Foundation private let integerRoundingBehavior = NSDecimalNumberHandler( @@ -104,4 +103,3 @@ extension NSNumber: DatabaseValueConvertible { } private let posixLocale = Locale(identifier: "en_US_POSIX") -#endif diff --git a/GRDB/Core/Support/Foundation/URL.swift b/GRDB/Core/Support/Foundation/URL.swift index b3630b14a..541668b66 100644 --- a/GRDB/Core/Support/Foundation/URL.swift +++ b/GRDB/Core/Support/Foundation/URL.swift @@ -1,6 +1,5 @@ import Foundation -#if !os(Windows) /// NSURL stores its absoluteString in the database. extension NSURL: DatabaseValueConvertible { @@ -20,7 +19,6 @@ extension NSURL: DatabaseValueConvertible { return cast(URL(string: string)) } } -#endif /// URL stores its absoluteString in the database. extension URL: DatabaseValueConvertible { } diff --git a/GRDB/Core/Support/Foundation/UUID.swift b/GRDB/Core/Support/Foundation/UUID.swift index 47ba843ba..bb4a34210 100644 --- a/GRDB/Core/Support/Foundation/UUID.swift +++ b/GRDB/Core/Support/Foundation/UUID.swift @@ -12,7 +12,6 @@ import GRDBSQLite import Foundation -#if !os(Windows) /// NSUUID adopts DatabaseValueConvertible extension NSUUID: DatabaseValueConvertible { /// Returns a BLOB database value containing the uuid bytes. @@ -52,7 +51,6 @@ extension NSUUID: DatabaseValueConvertible { } } } -#endif /// UUID adopts DatabaseValueConvertible extension UUID: DatabaseValueConvertible { diff --git a/Tests/GRDBTests/AssociationTableAliasTestsSQLTests.swift b/Tests/GRDBTests/AssociationTableAliasTestsSQLTests.swift index f7ff69f36..33851cbb5 100644 --- a/Tests/GRDBTests/AssociationTableAliasTestsSQLTests.swift +++ b/Tests/GRDBTests/AssociationTableAliasTestsSQLTests.swift @@ -148,7 +148,7 @@ class AssociationTableAliasTestsSQLTests : GRDBTestCase { """ do { - let request = A + let request: QueryInterfaceRequest = A .aliased(alias) .select(\.name) .filter(key: 1) @@ -159,7 +159,7 @@ class AssociationTableAliasTestsSQLTests : GRDBTestCase { try assertEqualSQL(db, request, expectedSQL) } do { - let request = A + let request: QueryInterfaceRequest = A .select(\.name) .filter(key: 1) .filter { $0.name != nil && alias.name == "foo" } @@ -183,7 +183,7 @@ class AssociationTableAliasTestsSQLTests : GRDBTestCase { """ do { - let request = A + let request: QueryInterfaceRequest = A .aliased(alias) .select(\.name) .filter(key: 1) @@ -194,7 +194,7 @@ class AssociationTableAliasTestsSQLTests : GRDBTestCase { try assertEqualSQL(db, request, expectedSQL) } do { - let request = A + let request: QueryInterfaceRequest = A .select(\.name) .filter(key: 1) .filter { $0.name != nil && alias.name == "foo" } diff --git a/Tests/GRDBTests/EncryptionTests.swift b/Tests/GRDBTests/EncryptionTests.swift index a507827a8..3f2396965 100644 --- a/Tests/GRDBTests/EncryptionTests.swift +++ b/Tests/GRDBTests/EncryptionTests.swift @@ -758,7 +758,8 @@ let testBundle = Bundle(for: GRDBTestCase.self) } let dbQueue = try makeDatabaseQueue(configuration: config) try dbQueue.inDatabase { db in - XCTAssertEqual("commoncrypto", try db.cipherProvider) + let provider = try db.cipherProvider + XCTAssertTrue(["commoncrypto", "libtomcrypt"].contains(provider), "unrecognized cipherProvider: \(provider ?? "")") } }