Skip to content

Commit 8b6666e

Browse files
authored
Merge branch 'master' into deploymentTarget9
2 parents f040e14 + 5c49d0e commit 8b6666e

35 files changed

+693
-302
lines changed
File renamed without changes.

.github/workflows/build.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Build and test
2+
on: [push, pull_request]
3+
env:
4+
IOS_SIMULATOR: iPhone 12
5+
IOS_VERSION: 14.4
6+
jobs:
7+
build:
8+
runs-on: macos-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- name: Install
12+
run: |
13+
gem update bundler
14+
gem install xcpretty --no-document
15+
brew update
16+
brew outdated carthage || brew upgrade carthage
17+
- name: "Run tests (BUILD_SCHEME: SQLite iOS)"
18+
env:
19+
BUILD_SCHEME: SQLite iOS
20+
run: ./run-tests.sh
21+
- name: "Run tests (BUILD_SCHEME: SQLite Mac)"
22+
env:
23+
BUILD_SCHEME: SQLite Mac
24+
run: ./run-tests.sh
25+
- name: "Run tests (VALIDATOR_SUBSPEC: none)"
26+
env:
27+
VALIDATOR_SUBSPEC: none
28+
run: ./run-tests.sh
29+
- name: "Run tests (VALIDATOR_SUBSPEC: standard)"
30+
env:
31+
VALIDATOR_SUBSPEC: standard
32+
run: ./run-tests.sh
33+
- name: "Run tests (VALIDATOR_SUBSPEC: standalone)"
34+
env:
35+
VALIDATOR_SUBSPEC: standalone
36+
run: ./run-tests.sh
37+
- name: "Run tests (VALIDATOR_SUBSPEC: SQLCipher)"
38+
env:
39+
VALIDATOR_SUBSPEC: SQLCipher
40+
run: ./run-tests.sh
41+
- name: "Run tests (CARTHAGE_PLATFORM: iOS)"
42+
env:
43+
CARTHAGE_PLATFORM: iOS
44+
run: ./run-tests.sh
45+
- name: "Run tests (CARTHAGE_PLATFORM: Mac)"
46+
env:
47+
CARTHAGE_PLATFORM: Mac
48+
run: ./run-tests.sh
49+
- name: "Run tests (CARTHAGE_PLATFORM: watchOS)"
50+
env:
51+
CARTHAGE_PLATFORM: watchOS
52+
run: ./run-tests.sh
53+
- name: "Run tests (CARTHAGE_PLATFORM: tvOS)"
54+
env:
55+
CARTHAGE_PLATFORM: tvOS
56+
run: ./run-tests.sh
57+
- name: "Run tests (PACKAGE_MANAGER_COMMAND: test)"
58+
env:
59+
PACKAGE_MANAGER_COMMAND: test
60+
run: ./run-tests.sh

.travis.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
0.12.3 (18-05-2021), [diff][diff-0.12.2]
2+
========================================
3+
4+
* Swift 5.3 support.
5+
* Xcode 12.5 support.
6+
* Bumps minimum deployment versions.
7+
* Fixes up Package.swift to build SQLiteObjc module.
8+
19
0.11.6 (xxx), [diff][diff-0.11.6]
210
========================================
311

Documentation/Index.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
- [Sorting Rows](#sorting-rows)
3636
- [Limiting and Paging Results](#limiting-and-paging-results)
3737
- [Aggregation](#aggregation)
38+
- [Upserting Rows](#upserting-rows)
3839
- [Updating Rows](#updating-rows)
3940
- [Deleting Rows](#deleting-rows)
4041
- [Transactions and Savepoints](#transactions-and-savepoints)
@@ -266,8 +267,8 @@ var path = NSSearchPathForDirectoriesInDomains(
266267
).first! + "/" + Bundle.main.bundleIdentifier!
267268
268269
// create parent directory iff it doesn’t exist
269-
try FileManager.default.createDirectoryAtPath(
270-
path, withIntermediateDirectories: true, attributes: nil
270+
try FileManager.default.createDirectory(
271+
atPath: path, withIntermediateDirectories: true, attributes: nil
271272
)
272273
273274
let db = try Connection("\(path)/db.sqlite3")
@@ -955,8 +956,10 @@ equate or compare different types will prevent compilation.
955956
| `~=` | `(Interval, Comparable) -> Bool` | `BETWEEN` |
956957
| `&&` | `Bool -> Bool` | `AND` |
957958
| `\|\|`| `Bool -> Bool` | `OR` |
959+
| `===` | `Equatable -> Bool` | `IS` |
960+
| `!==` | `Equatable -> Bool` | `IS NOT` |
958961

959-
> *When comparing against `nil`, SQLite.swift will use `IS` and `IS NOT`
962+
> * When comparing against `nil`, SQLite.swift will use `IS` and `IS NOT`
960963
> accordingly.
961964

962965

@@ -1098,6 +1101,33 @@ let count = try db.scalar(users.filter(name != nil).count)
10981101
> // SELECT count(DISTINCT "name") FROM "users"
10991102
> ```
11001103

1104+
## Upserting Rows
1105+
1106+
We can upsert rows into a table by calling a [query’s](#queries) `upsert`
1107+
function with a list of [setters](#setters)—typically [typed column
1108+
expressions](#expressions) and values (which can also be expressions)—each
1109+
joined by the `<-` operator. Upserting is like inserting, except if there is a
1110+
conflict on the specified column value, SQLite will perform an update on the row instead.
1111+
1112+
```swift
1113+
try db.run(users.upsert(email <- "alice@mac.com", name <- "Alice"), onConflictOf: email)
1114+
// INSERT INTO "users" ("email", "name") VALUES ('alice@mac.com', 'Alice') ON CONFLICT (\"email\") DO UPDATE SET \"name\" = \"excluded\".\"name\"
1115+
```
1116+
1117+
The `upsert` function, when run successfully, returns an `Int64` representing
1118+
the inserted row’s [`ROWID`][ROWID].
1119+
1120+
```swift
1121+
do {
1122+
let rowid = try db.run(users.upsert(email <- "alice@mac.com", name <- "Alice", onConflictOf: email))
1123+
print("inserted id: \(rowid)")
1124+
} catch {
1125+
print("insertion failed: \(error)")
1126+
}
1127+
```
1128+
1129+
The [`insert`](#inserting-rows), [`update`](#updating-rows), and [`delete`](#deleting-rows) functions
1130+
follow similar patterns.
11011131

11021132
## Updating Rows
11031133

@@ -1557,7 +1587,7 @@ Both of the above methods also have the following optional parameter:
15571587
There are a few restrictions on using Codable types:
15581588

15591589
- The encodable and decodable objects can only use the following types:
1560-
- Int, Bool, Float, Double, String
1590+
- Int, Bool, Float, Double, String, Date
15611591
- Nested Codable types that will be encoded as JSON to a single column
15621592
- These methods will not handle object relationships for you. You must write
15631593
your own Codable and Decodable implementations if you wish to support this.
@@ -1792,12 +1822,12 @@ let config = FTS5Config()
17921822
.column(subject)
17931823
.column(body, [.unindexed])
17941824
1795-
try db.run(emails.create(.FTS5(config))
1825+
try db.run(emails.create(.FTS5(config)))
17961826
// CREATE VIRTUAL TABLE "emails" USING fts5("subject", "body" UNINDEXED)
17971827
17981828
// Note that FTS5 uses a different syntax to select columns, so we need to rewrite
17991829
// the last FTS4 query above as:
1800-
let replies = emails.filter(emails.match("subject:\"Re:\"*))
1830+
let replies = emails.filter(emails.match("subject:\"Re:\"*"))
18011831
// SELECT * FROM "emails" WHERE "emails" MATCH 'subject:"Re:"*'
18021832
18031833
// https://www.sqlite.org/fts5.html#_changes_to_select_statements_

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
BUILD_TOOL = xcodebuild
22
BUILD_SCHEME = SQLite Mac
33
IOS_SIMULATOR = iPhone XS
4-
IOS_VERSION = 12.2
4+
IOS_VERSION = 12.4
55
ifeq ($(BUILD_SCHEME),SQLite iOS)
66
BUILD_ARGUMENTS = -scheme "$(BUILD_SCHEME)" -destination "platform=iOS Simulator,name=$(IOS_SIMULATOR),OS=$(IOS_VERSION)"
77
else

Package.swift

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,46 @@
1-
// swift-tools-version:4.0
1+
// swift-tools-version:5.3
22
import PackageDescription
33

44
let package = Package(
55
name: "SQLite.swift",
6-
products: [.library(name: "SQLite", targets: ["SQLite"])],
6+
products: [
7+
.library(
8+
name: "SQLite",
9+
targets: ["SQLite"]
10+
)
11+
],
712
targets: [
8-
.target(name: "SQLite", dependencies: ["SQLiteObjc"]),
9-
.target(name: "SQLiteObjc"),
10-
.testTarget(name: "SQLiteTests", dependencies: ["SQLite"], path: "Tests/SQLiteTests")
11-
],
12-
swiftLanguageVersions: [4, 5]
13+
.target(
14+
name: "SQLite",
15+
dependencies: ["SQLiteObjc"],
16+
exclude: [
17+
"Info.plist"
18+
]
19+
),
20+
.target(
21+
name: "SQLiteObjc",
22+
dependencies: [],
23+
exclude: [
24+
"SQLiteObjc.h",
25+
"fts3_tokenizer.h",
26+
"include/README.md"
27+
]
28+
),
29+
.testTarget(
30+
name: "SQLiteTests",
31+
dependencies: [
32+
"SQLite"
33+
],
34+
path: "Tests/SQLiteTests",
35+
exclude: [
36+
"Info.plist"
37+
],
38+
resources: [
39+
.copy("fixtures/encrypted-3.x.sqlite"),
40+
.copy("fixtures/encrypted-4.x.sqlite")
41+
]
42+
)
43+
]
1344
)
1445

1546
#if os(Linux)

0 commit comments

Comments
 (0)