Skip to content

Commit a60810f

Browse files
authored
Merge pull request #1819 from groue/dev/SQLCipher-cleanup
Accept multiple SQLCipher libraries
2 parents 48a17ce + c35095c commit a60810f

40 files changed

+348
-261
lines changed

GRDB/Core/Database+Schema.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ extension Database {
141141
}
142142
}
143143

144-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
144+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
145145
/// Returns information about a table or a view
146146
func table(_ tableName: String) throws -> TableInfo? {
147147
for schemaID in try fetchSchemaIdentifiers() {
@@ -575,7 +575,7 @@ extension Database {
575575
/// - precondition: table exists.
576576
private func fetchTableHasRowID(_ table: DatabaseObjectID) throws -> Bool {
577577
// Prefer PRAGMA table_list if available
578-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
578+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
579579
// Maybe SQLCipher is too old: check actual version
580580
if sqlite3_libversion_number() >= 3037000 {
581581
return try self.table(for: table)!.isWithoutRowIDTable == false

GRDB/Core/DatabaseWriter.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ extension DatabaseWriter {
552552
// This method is declared on DatabaseWriter instead of DatabaseReader,
553553
// so that it is not available on DatabaseSnaphot. VACUUM INTO is not
554554
// available inside the transaction that is kept open by DatabaseSnaphot.
555-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
555+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
556556
/// Creates a new database file at the specified path with a minimum
557557
/// amount of disk space.
558558
///
@@ -665,7 +665,7 @@ extension DatabaseWriter {
665665
try await writeWithoutTransaction { try $0.execute(sql: "VACUUM") }
666666
}
667667

668-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
668+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
669669
/// Creates a new database file at the specified path with a minimum
670670
/// amount of disk space.
671671
///

GRDB/Dump/Database+Dump.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ extension Database {
324324
}
325325

326326
private func isShadowTable(_ tableName: String) throws -> Bool {
327-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
327+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
328328
// Maybe SQLCipher is too old: check actual version
329329
if Database.sqliteLibVersionNumber >= 3037000 {
330330
guard let table = try table(tableName) else {

GRDB/FTS/FTS3.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ public struct FTS3 {
4040
/// the `remove_diacritics=1` tokenizer argument.
4141
case removeLegacy
4242

43-
#if GRDBCUSTOMSQLITE
43+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
4444
/// Remove diacritics from Latin script characters. This option matches
4545
/// the `remove_diacritics=2` tokenizer argument.
4646
case remove
47-
#elseif !GRDBCIPHER
47+
#else
4848
/// Remove diacritics from Latin script characters. This option matches
4949
/// the `remove_diacritics=2` tokenizer argument.
5050
@available(iOS 14, macOS 10.16, tvOS 14, *) // SQLite 3.27+

GRDB/FTS/FTS3TokenizerDescriptor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,10 @@ public struct FTS3TokenizerDescriptor: Sendable {
9595
break
9696
case .keep:
9797
arguments.append("remove_diacritics=0")
98-
#if GRDBCUSTOMSQLITE
98+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
9999
case .remove:
100100
arguments.append("remove_diacritics=2")
101-
#elseif !GRDBCIPHER
101+
#else
102102
case .remove:
103103
arguments.append("remove_diacritics=2")
104104
#endif

GRDB/FTS/FTS5.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,12 @@ public struct FTS5 {
6363
/// Remove diacritics from Latin script characters. This
6464
/// option matches the raw "remove_diacritics=1" tokenizer argument.
6565
case removeLegacy
66-
#if GRDBCUSTOMSQLITE
66+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
6767
/// Remove diacritics from Latin script characters. This
6868
/// option matches the raw "remove_diacritics=2" tokenizer argument,
6969
/// available from SQLite 3.27.0
7070
case remove
71-
#elseif !GRDBCIPHER
71+
#else
7272
/// Remove diacritics from Latin script characters. This
7373
/// option matches the raw "remove_diacritics=2" tokenizer argument,
7474
/// available from SQLite 3.27.0

GRDB/FTS/FTS5TokenizerDescriptor.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,10 @@ public struct FTS5TokenizerDescriptor: Sendable {
182182
break
183183
case .keep:
184184
components.append(contentsOf: ["remove_diacritics", "0"])
185-
#if GRDBCUSTOMSQLITE
185+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
186186
case .remove:
187187
components.append(contentsOf: ["remove_diacritics", "2"])
188-
#elseif !GRDBCIPHER
188+
#else
189189
case .remove:
190190
components.append(contentsOf: ["remove_diacritics", "2"])
191191
#endif

GRDB/JSON/SQLJSONExpressible.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ extension SQLSpecificExpressible {
154154
}
155155
}
156156

157-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
157+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
158158
extension SQLJSONExpressible {
159159
/// The `->>` SQL operator.
160160
///

GRDB/JSON/SQLJSONFunctions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
1+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
22
// MARK: - JSON
33

44
extension Database {

GRDB/QueryInterface/Request/QueryInterfaceRequest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ extension QueryInterfaceRequest {
646646
// MARK: - Batch Delete and Fetch
647647

648648
extension QueryInterfaceRequest {
649-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
649+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
650650
/// Returns a `DELETE RETURNING` prepared statement.
651651
///
652652
/// For example:
@@ -1176,7 +1176,7 @@ extension QueryInterfaceRequest {
11761176
// MARK: - Batch Update and Fetch
11771177

11781178
extension QueryInterfaceRequest {
1179-
#if GRDBCUSTOMSQLITE || GRDBCIPHER
1179+
#if GRDBCUSTOMSQLITE || SQLITE_HAS_CODEC
11801180
/// Returns an `UPDATE RETURNING` prepared statement.
11811181
///
11821182
/// For example:

0 commit comments

Comments
 (0)