mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-24 04:07:47 +00:00
Availability checks: assume iOS >= 9.0
This commit is contained in:
1 parent
62ef344a6c
commit
a230fe400d
11 files changed
+36
-26
No files matched your search
@@ -248,12 +248,17 @@ struct StatementCache {
|
||||
//
|
||||
// However SQLITE_PREPARE_PERSISTENT was only introduced in
|
||||
// SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
|
||||
//
|
||||
// TODO: use SQLITE_PREPARE_PERSISTENT if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *)
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
let statement = try db.makeSelectStatement(sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
|
||||
let statement = try db.makeSelectStatement(sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
|
||||
#else
|
||||
let statement = try db.makeSelectStatement(sql)
|
||||
let statement: SelectStatement
|
||||
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
|
||||
// SQLite 3.24.0 or more
|
||||
statement = try db.makeSelectStatement(sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
|
||||
} else {
|
||||
// SQLite 3.19.3 or less
|
||||
statement = try db.makeSelectStatement(sql)
|
||||
}
|
||||
#endif
|
||||
selectStatements[sql] = statement
|
||||
return statement
|
||||
@@ -273,12 +278,17 @@ struct StatementCache {
|
||||
//
|
||||
// However SQLITE_PREPARE_PERSISTENT was only introduced in
|
||||
// SQLite 3.20.0 http://www.sqlite.org/changes.html#version_3_20
|
||||
//
|
||||
// TODO: use SQLITE_PREPARE_PERSISTENT if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *)
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
let statement = try db.makeUpdateStatement(sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
|
||||
#else
|
||||
let statement = try db.makeUpdateStatement(sql)
|
||||
let statement: UpdateStatement
|
||||
if #available(iOS 12.0, OSX 10.14, watchOS 5.0, *) {
|
||||
// SQLite 3.24.0 or more
|
||||
statement = try db.makeUpdateStatement(sql, prepFlags: SQLITE_PREPARE_PERSISTENT)
|
||||
} else {
|
||||
// SQLite 3.19.3 or less
|
||||
statement = try db.makeUpdateStatement(sql)
|
||||
}
|
||||
#endif
|
||||
updateStatements[sql] = statement
|
||||
return statement
|
||||
|
||||
@@ -379,7 +379,7 @@ extension Database {
|
||||
add(function: .lowercase)
|
||||
add(function: .uppercase)
|
||||
|
||||
if #available(iOS 9.0, OSX 10.11, watchOS 3.0, *) {
|
||||
if #available(OSX 10.11, watchOS 3.0, *) {
|
||||
add(function: .localizedCapitalize)
|
||||
add(function: .localizedLowercase)
|
||||
add(function: .localizedUppercase)
|
||||
@@ -418,7 +418,7 @@ extension Database {
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
closeConnection_v2(sqliteConnection, sqlite3_close_v2)
|
||||
#else
|
||||
if #available(iOS 8.2, OSX 10.10, OSXApplicationExtension 10.10, *) {
|
||||
if #available(OSX 10.10, OSXApplicationExtension 10.10, *) {
|
||||
closeConnection_v2(sqliteConnection, sqlite3_close_v2)
|
||||
} else {
|
||||
closeConnection_v1(sqliteConnection)
|
||||
|
||||
@@ -147,7 +147,7 @@ extension ResultCode {
|
||||
#if GRDBCUSTOMSQLITE || GRDBCIPHER
|
||||
return String(cString: sqlite3_errstr(rawValue))
|
||||
#else
|
||||
if #available(iOS 8.2, OSX 10.10, OSXApplicationExtension 10.10, iOSApplicationExtension 8.2, *) {
|
||||
if #available(OSX 10.10, OSXApplicationExtension 10.10, *) {
|
||||
return String(cString: sqlite3_errstr(rawValue))
|
||||
} else {
|
||||
return nil
|
||||
|
||||
@@ -543,7 +543,7 @@ extension DatabaseFunction {
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Player.select(nameColumn.localizedCapitalized)
|
||||
/// let names = try String.fetchAll(dbQueue, request) // [String]
|
||||
@available(iOS 9.0, OSX 10.11, watchOS 3.0, *)
|
||||
@available(OSX 10.11, watchOS 3.0, *)
|
||||
public static let localizedCapitalize = DatabaseFunction("swiftLocalizedCapitalizedString", argumentCount: 1, pure: true) { dbValues in
|
||||
guard let string = String.fromDatabaseValue(dbValues[0]) else {
|
||||
return nil
|
||||
@@ -563,7 +563,7 @@ extension DatabaseFunction {
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Player.select(nameColumn.localizedLowercased)
|
||||
/// let names = try String.fetchAll(dbQueue, request) // [String]
|
||||
@available(iOS 9.0, OSX 10.11, watchOS 3.0, *)
|
||||
@available(OSX 10.11, watchOS 3.0, *)
|
||||
public static let localizedLowercase = DatabaseFunction("swiftLocalizedLowercaseString", argumentCount: 1, pure: true) { dbValues in
|
||||
guard let string = String.fromDatabaseValue(dbValues[0]) else {
|
||||
return nil
|
||||
@@ -583,7 +583,7 @@ extension DatabaseFunction {
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Player.select(nameColumn.localizedUppercased)
|
||||
/// let names = try String.fetchAll(dbQueue, request) // [String]
|
||||
@available(iOS 9.0, OSX 10.11, watchOS 3.0, *)
|
||||
@available(OSX 10.11, watchOS 3.0, *)
|
||||
public static let localizedUppercase = DatabaseFunction("swiftLocalizedUppercaseString", argumentCount: 1, pure: true) { dbValues in
|
||||
guard let string = String.fromDatabaseValue(dbValues[0]) else {
|
||||
return nil
|
||||
|
||||
@@ -78,7 +78,7 @@ public struct FTS3Pattern {
|
||||
/// FTS3Pattern(matchingAnyTokenIn: "foo bar") // foo OR bar
|
||||
///
|
||||
/// - parameter string: The string to turn into an FTS3 pattern
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
public init?(matchingAnyTokenIn string: String) {
|
||||
let tokens = FTS3TokenizerDescriptor.simple.tokenize(string)
|
||||
guard !tokens.isEmpty else { return nil }
|
||||
@@ -92,7 +92,7 @@ public struct FTS3Pattern {
|
||||
/// FTS3Pattern(matchingAllTokensIn: "foo bar") // foo bar
|
||||
///
|
||||
/// - parameter string: The string to turn into an FTS3 pattern
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
public init?(matchingAllTokensIn string: String) {
|
||||
let tokens = FTS3TokenizerDescriptor.simple.tokenize(string)
|
||||
guard !tokens.isEmpty else { return nil }
|
||||
@@ -106,7 +106,7 @@ public struct FTS3Pattern {
|
||||
/// FTS3Pattern(matchingPhrase: "foo bar") // "foo bar"
|
||||
///
|
||||
/// - parameter string: The string to turn into an FTS3 pattern
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
public init?(matchingPhrase string: String) {
|
||||
let tokens = FTS3TokenizerDescriptor.simple.tokenize(string)
|
||||
guard !tokens.isEmpty else { return nil }
|
||||
|
||||
@@ -67,7 +67,7 @@ public struct FTS3TokenizerDescriptor {
|
||||
/// these characters as token characters.
|
||||
///
|
||||
/// See https://www.sqlite.org/fts3.html#tokenizer
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
public static func unicode61(removeDiacritics: Bool = true, separators: Set<Character> = [], tokenCharacters: Set<Character> = []) -> FTS3TokenizerDescriptor {
|
||||
// query_only pragma was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
@@ -96,7 +96,7 @@ public struct FTS3TokenizerDescriptor {
|
||||
return _tokenize(string)
|
||||
}
|
||||
#else
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
func tokenize(_ string: String) -> [String] {
|
||||
return _tokenize(string)
|
||||
}
|
||||
|
||||
+1
-1
@@ -288,7 +288,7 @@ public final class FTS4ColumnDefinition {
|
||||
/// See https://www.sqlite.org/fts3.html#the_notindexed_option
|
||||
///
|
||||
/// - returns: Self so that you can further refine the column definition.
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
@discardableResult
|
||||
public func notIndexed() -> Self {
|
||||
// notindexed FTS4 option was added in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
|
||||
|
||||
@@ -119,7 +119,7 @@ public struct DatabaseMigrator {
|
||||
registerMigration(Migration(identifier: identifier, disabledForeignKeyChecks: true, migrate: migrate))
|
||||
}
|
||||
#else
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
/// Registers an advanced migration, as described at https://www.sqlite.org/lang_altertable.html#otheralter
|
||||
///
|
||||
/// // Add a NOT NULL constraint on players.name:
|
||||
|
||||
@@ -17,7 +17,7 @@ struct Migration {
|
||||
self.migrate = migrate
|
||||
}
|
||||
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
// PRAGMA foreign_key_check was introduced in SQLite 3.7.16 http://www.sqlite.org/changes.html#version_3_7_16
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
init(identifier: String, disabledForeignKeyChecks: Bool, migrate: @escaping (Database) throws -> Void) {
|
||||
|
||||
@@ -187,7 +187,7 @@ extension SQLSpecificExpressible {
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Player.select(nameColumn.localizedCapitalized)
|
||||
/// let names = try String.fetchAll(dbQueue, request) // [String]
|
||||
@available(iOS 9.0, OSX 10.11, watchOS 3.0, *)
|
||||
@available(OSX 10.11, watchOS 3.0, *)
|
||||
public var localizedCapitalized: SQLExpression {
|
||||
return DatabaseFunction.localizedCapitalize.apply(sqlExpression)
|
||||
}
|
||||
@@ -198,7 +198,7 @@ extension SQLSpecificExpressible {
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Player.select(nameColumn.localizedLowercased)
|
||||
/// let names = try String.fetchAll(dbQueue, request) // [String]
|
||||
@available(iOS 9.0, OSX 10.11, watchOS 3.0, *)
|
||||
@available(OSX 10.11, watchOS 3.0, *)
|
||||
public var localizedLowercased: SQLExpression {
|
||||
return DatabaseFunction.localizedLowercase.apply(sqlExpression)
|
||||
}
|
||||
@@ -209,7 +209,7 @@ extension SQLSpecificExpressible {
|
||||
/// let nameColumn = Column("name")
|
||||
/// let request = Player.select(nameColumn.localizedUppercased)
|
||||
/// let names = try String.fetchAll(dbQueue, request) // [String]
|
||||
@available(iOS 9.0, OSX 10.11, watchOS 3.0, *)
|
||||
@available(OSX 10.11, watchOS 3.0, *)
|
||||
public var localizedUppercased: SQLExpression {
|
||||
return DatabaseFunction.localizedUppercase.apply(sqlExpression)
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ extension Database {
|
||||
/// - withoutRowID: If true, uses WITHOUT ROWID optimization.
|
||||
/// - body: A closure that defines table columns and constraints.
|
||||
/// - throws: A DatabaseError whenever an SQLite error occurs.
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
public func create(table name: String, temporary: Bool = false, ifNotExists: Bool = false, withoutRowID: Bool, body: (TableDefinition) -> Void) throws {
|
||||
// WITHOUT ROWID was added in SQLite 3.8.2 http://www.sqlite.org/changes.html#version_3_8_2
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
@@ -198,7 +198,7 @@ extension Database {
|
||||
/// - unique: If true, creates a unique index.
|
||||
/// - ifNotExists: If false, no error is thrown if index already exists.
|
||||
/// - condition: The condition that indexed rows must verify.
|
||||
@available(iOS 8.2, OSX 10.10, *)
|
||||
@available(OSX 10.10, *)
|
||||
public func create(index name: String, on table: String, columns: [String], unique: Bool = false, ifNotExists: Bool = false, condition: SQLExpressible) throws {
|
||||
// Partial indexes were introduced in SQLite 3.8.0 http://www.sqlite.org/changes.html#version_3_8_0
|
||||
// It is available from iOS 8.2 and OS X 10.10 https://github.com/yapstudios/YapDatabase/wiki/SQLite-version-(bundled-with-OS)
|
||||
|
||||
Reference in new issue
Block a user