Skip to content

Remove redundant assignment (do not merge) #1165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ name: Build and test
on: [push, pull_request]
env:
IOS_SIMULATOR: iPhone 12
IOS_VERSION: "15.2"
IOS_VERSION: "16.0"
jobs:
build:
runs-on: macos-11
runs-on: macos-12
steps:
- uses: actions/checkout@v2
- name: Install
Expand Down
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import PackageDescription
let package = Package(
name: "SQLite.swift",
platforms: [
.iOS(.v9),
.macOS(.v10_10),
.watchOS(.v3),
.tvOS(.v9)
.iOS(.v11),
.macOS(.v10_13),
.watchOS(.v4),
.tvOS(.v11)
],
products: [
.library(
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ and the [companion repository][SQLiteDataAccessLayer2].

## Installation

> _Note:_ Version 0.11.6 and later requires Swift 5 (and [Xcode](https://developer.apple.com/xcode/downloads/) 10.2) or greater. Version 0.11.5 requires Swift 4.2 (and [Xcode](https://developer.apple.com/xcode/downloads/) 10.1) or greater.
> _Note:_Version 0.14.0 requires Swift 5.7 (and [Xcode](https://developer.apple.com/xcode/downloads/) 14) or greater.
> Version 0.11.6 and later requires Swift 5 (and [Xcode](https://developer.apple.com/xcode/downloads/) 10.2) or greater.

### Swift Package Manager

Expand Down
8 changes: 4 additions & 4 deletions SQLite.swift.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ Pod::Spec.new do |s|
s.default_subspec = 'standard'
s.swift_versions = ['5']

ios_deployment_target = '9.0'
tvos_deployment_target = '9.1'
osx_deployment_target = '10.10'
watchos_deployment_target = '3.0'
ios_deployment_target = '11.0'
tvos_deployment_target = '11.0'
osx_deployment_target = '10.13'
watchos_deployment_target = '4.0'

s.ios.deployment_target = ios_deployment_target
s.tvos.deployment_target = tvos_deployment_target
Expand Down
30 changes: 22 additions & 8 deletions SQLite.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
name = Debug;
};
Expand All @@ -1284,6 +1285,7 @@
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
name = Release;
};
Expand All @@ -1297,6 +1299,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
name = Debug;
};
Expand All @@ -1310,6 +1313,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = appletvos;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TVOS_DEPLOYMENT_TARGET = 11.0;
};
name = Release;
};
Expand All @@ -1333,6 +1337,7 @@
SKIP_INSTALL = YES;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
};
name = Debug;
};
Expand All @@ -1356,6 +1361,7 @@
SKIP_INSTALL = YES;
SWIFT_TREAT_WARNINGS_AS_ERRORS = YES;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
};
name = Release;
};
Expand Down Expand Up @@ -1408,19 +1414,19 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3";
TVOS_DEPLOYMENT_TARGET = 9.1;
TVOS_DEPLOYMENT_TARGET = 11.0;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 3.0;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
};
name = Debug;
};
Expand Down Expand Up @@ -1467,19 +1473,19 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
MACOSX_DEPLOYMENT_TARGET = 10.13;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_NAME = "";
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3";
TVOS_DEPLOYMENT_TARGET = 9.1;
TVOS_DEPLOYMENT_TARGET = 11.0;
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 3.0;
WATCHOS_DEPLOYMENT_TARGET = 4.0;
};
name = Release;
};
Expand All @@ -1496,6 +1502,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/SQLite/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 0.13.3;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLite;
Expand All @@ -1519,6 +1526,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = "$(SRCROOT)/Sources/SQLite/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 0.13.3;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLite;
Expand All @@ -1533,6 +1541,7 @@
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = Tests/SQLiteTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1545,6 +1554,7 @@
buildSettings = {
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = Tests/SQLiteTests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -1567,6 +1577,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Sources/SQLite/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLite;
PRODUCT_NAME = SQLite;
SDKROOT = macosx;
Expand All @@ -1591,6 +1602,7 @@
INFOPLIST_FILE = "$(SRCROOT)/Sources/SQLite/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLite;
PRODUCT_NAME = SQLite;
SDKROOT = macosx;
Expand All @@ -1608,6 +1620,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = Tests/SQLiteTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -1623,6 +1636,7 @@
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
INFOPLIST_FILE = Tests/SQLiteTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.13;
PRODUCT_BUNDLE_IDENTIFIER = com.stephencelis.SQLiteTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLite/Core/Connection+Attach.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension Connection {
#if SQLITE_SWIFT_SQLCIPHER
/// See https://www.zetetic.net/sqlcipher/sqlcipher-api/#attach
public func attach(_ location: Location, as schemaName: String, key: String? = nil) throws {
if let key = key {
if let key {
try run("ATTACH DATABASE ? AS ? KEY ?", location.description, schemaName, key)
} else {
try run("ATTACH DATABASE ? AS ?", location.description, schemaName)
Expand Down
18 changes: 9 additions & 9 deletions Sources/SQLite/Core/Connection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public final class Connection {
/// times it’s been called for this lock. If it returns `true`, it will
/// try again. If it returns `false`, no further attempts will be made.
public func busyHandler(_ callback: ((_ tries: Int) -> Bool)?) {
guard let callback = callback else {
guard let callback else {
sqlite3_busy_handler(handle, nil, nil)
busyHandler = nil
return
Expand Down Expand Up @@ -442,7 +442,7 @@ public final class Connection {
@available(watchOS, deprecated: 3.0)
@available(tvOS, deprecated: 10.0)
fileprivate func trace_v1(_ callback: ((String) -> Void)?) {
guard let callback = callback else {
guard let callback else {
sqlite3_trace(handle, nil /* xCallback */, nil /* pCtx */)
trace = nil
return
Expand All @@ -451,7 +451,7 @@ public final class Connection {
callback(String(cString: pointer.assumingMemoryBound(to: UInt8.self)))
}
sqlite3_trace(handle, { (context: UnsafeMutableRawPointer?, SQL: UnsafePointer<Int8>?) in
if let context = context, let SQL = SQL {
if let context, let SQL {
unsafeBitCast(context, to: Trace.self)(SQL)
}
},
Expand All @@ -462,7 +462,7 @@ public final class Connection {

@available(iOS 10.0, OSX 10.12, tvOS 10.0, watchOS 3.0, *)
fileprivate func trace_v2(_ callback: ((String) -> Void)?) {
guard let callback = callback else {
guard let callback else {
// If the X callback is NULL or if the M mask is zero, then tracing is disabled.
sqlite3_trace_v2(handle, 0 /* mask */, nil /* xCallback */, nil /* pCtx */)
trace = nil
Expand All @@ -478,7 +478,7 @@ public final class Connection {
// callback was invoked. The C argument is a copy of the context pointer.
// The P and X arguments are pointers whose meanings depend on T.
(_: UInt32, context: UnsafeMutableRawPointer?, pointer: UnsafeMutableRawPointer?, _: UnsafeMutableRawPointer?) in
if let pointer = pointer,
if let pointer,
let expandedSQL = sqlite3_expanded_sql(OpaquePointer(pointer)) {
unsafeBitCast(context, to: Trace.self)(expandedSQL)
sqlite3_free(expandedSQL)
Expand All @@ -500,7 +500,7 @@ public final class Connection {
/// `.Insert`, `.Update`, or `.Delete`), database name, table name, and
/// rowid.
public func updateHook(_ callback: ((_ operation: Operation, _ db: String, _ table: String, _ rowid: Int64) -> Void)?) {
guard let callback = callback else {
guard let callback else {
sqlite3_update_hook(handle, nil, nil)
updateHook = nil
return
Expand Down Expand Up @@ -528,7 +528,7 @@ public final class Connection {
/// committed. If this callback throws, the transaction will be rolled
/// back.
public func commitHook(_ callback: (() throws -> Void)?) {
guard let callback = callback else {
guard let callback else {
sqlite3_commit_hook(handle, nil, nil)
commitHook = nil
return
Expand All @@ -555,7 +555,7 @@ public final class Connection {
/// - Parameter callback: A callback invoked when a transaction is rolled
/// back.
public func rollbackHook(_ callback: (() -> Void)?) {
guard let callback = callback else {
guard let callback else {
sqlite3_rollback_hook(handle, nil, nil)
rollbackHook = nil
return
Expand Down Expand Up @@ -643,7 +643,7 @@ public final class Connection {
try check(sqlite3_create_collation_v2(handle, collation, SQLITE_UTF8,
unsafeBitCast(box, to: UnsafeMutableRawPointer.self), { (callback: UnsafeMutableRawPointer?, _,
lhs: UnsafeRawPointer?, _, rhs: UnsafeRawPointer?) in /* xCompare */
if let lhs = lhs, let rhs = rhs {
if let lhs, let rhs {
return unsafeBitCast(callback, to: Collation.self)(lhs, rhs)
} else {
fatalError("sqlite3_create_collation_v2 callback called with NULL pointer")
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLite/Core/Result.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ extension Result: CustomStringConvertible {
public var description: String {
switch self {
case let .error(message, errorCode, statement):
if let statement = statement {
if let statement {
return "\(message) (\(statement)) (code: \(errorCode))"
} else {
return "\(message) (code: \(errorCode))"
Expand Down
17 changes: 9 additions & 8 deletions Sources/SQLite/Core/Statement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,22 @@ public final class Statement {
}

fileprivate func bind(_ value: Binding?, atIndex idx: Int) {
if value == nil {
switch value {
case .none:
sqlite3_bind_null(handle, Int32(idx))
} else if let value = value as? Blob {
case let value as Blob:
sqlite3_bind_blob(handle, Int32(idx), value.bytes, Int32(value.bytes.count), SQLITE_TRANSIENT)
} else if let value = value as? Double {
case let value as Double:
sqlite3_bind_double(handle, Int32(idx), value)
} else if let value = value as? Int64 {
case let value as Int64:
sqlite3_bind_int64(handle, Int32(idx), value)
} else if let value = value as? String {
case let value as String:
sqlite3_bind_text(handle, Int32(idx), value, -1, SQLITE_TRANSIENT)
} else if let value = value as? Int {
case let value as Int:
self.bind(value.datatypeValue, atIndex: idx)
} else if let value = value as? Bool {
case let value as Bool:
self.bind(value.datatypeValue, atIndex: idx)
} else if let value = value {
case .some(let value):
fatalError("tried to bind unexpected value \(value)")
}
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/SQLite/Extensions/FTS4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public struct Tokenizer {
separators: Set<Character> = []) -> Tokenizer {
var arguments = [String]()

if let removeDiacritics = removeDiacritics {
if let removeDiacritics {
arguments.append("remove_diacritics=\(removeDiacritics ? 1 : 0)".quote())
}

Expand Down Expand Up @@ -208,13 +208,13 @@ open class FTSConfig {
func options() -> Options {
var options = Options()
options.append(formatColumnDefinitions())
if let tokenizer = tokenizer {
if let tokenizer {
options.append("tokenize", value: Expression<Void>(literal: tokenizer.description))
}
options.appendCommaSeparated("prefix", values: prefixes.sorted().map { String($0) })
if isContentless {
options.append("content", value: "")
} else if let externalContentSchema = externalContentSchema {
} else if let externalContentSchema {
options.append("content", value: externalContentSchema.tableName())
}
return options
Expand Down Expand Up @@ -245,7 +245,7 @@ open class FTSConfig {
}

@discardableResult mutating func append(_ key: String, value: Expressible?) -> Options {
if let value = value {
if let value {
arguments.append("=".join([Expression<Void>(literal: key), value]))
}
return self
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLite/Extensions/FTS5.swift
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ open class FTS5Config: FTSConfig {
override func options() -> Options {
var options = super.options()
options.append("content_rowid", value: contentRowId)
if let columnSize = columnSize {
if let columnSize {
options.append("columnsize", value: Expression<Int>(value: columnSize))
}
options.append("detail", value: detail)
Expand Down
Loading