Skip to content

Commit 9023fbc

Browse files
committed
Add documenation, update changelog
1 parent 41ce378 commit 9023fbc

File tree

4 files changed

+60
-3
lines changed

4 files changed

+60
-3
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
0.14.0 (tbd), [diff][diff-0.14.0]
2+
========================================
3+
4+
* Support ATTACH/DETACH ([#30][], [##1142][])
5+
* Support WITH clause ([#1139][])
6+
* Add value conformance for NSURL ([#1141][])
7+
* Add decoding for UUID ([#1137][])
8+
* Fix insertMany([Encodable]) ([#1130][], [#1138]][])
9+
* Fix incorrect spelling of 'remove_diacritics' ([#1128][])
10+
* Fix project build order ([#1131][])
11+
* Performance improvements ([#1109][], [#1115][], [#1132][])
12+
113
0.13.3 (25-01-2022), [diff][diff-0.13.3]
214
========================================
315

@@ -110,7 +122,9 @@
110122
[diff-0.13.1]: https://github.com/stephencelis/SQLite.swift/compare/0.13.0...0.13.1
111123
[diff-0.13.2]: https://github.com/stephencelis/SQLite.swift/compare/0.13.1...0.13.2
112124
[diff-0.13.3]: https://github.com/stephencelis/SQLite.swift/compare/0.13.2...0.13.3
125+
[diff-0.14.0]: https://github.com/stephencelis/SQLite.swift/compare/0.13.3...0.14.0
113126

127+
[#30]: https://github.com/stephencelis/SQLite.swift/issues/30
114128
[#142]: https://github.com/stephencelis/SQLite.swift/issues/142
115129
[#315]: https://github.com/stephencelis/SQLite.swift/issues/315
116130
[#426]: https://github.com/stephencelis/SQLite.swift/pull/426
@@ -150,6 +164,16 @@
150164
[#1095]: https://github.com/stephencelis/SQLite.swift/pull/1095
151165
[#1100]: https://github.com/stephencelis/SQLite.swift/pull/1100
152166
[#1105]: https://github.com/stephencelis/SQLite.swift/pull/1105
167+
[#1109]: https://github.com/stephencelis/SQLite.swift/issues/1109
153168
[#1112]: https://github.com/stephencelis/SQLite.swift/pull/1112
169+
[#1115]: https://github.com/stephencelis/SQLite.swift/pull/1115
154170
[#1119]: https://github.com/stephencelis/SQLite.swift/pull/1119
155171
[#1121]: https://github.com/stephencelis/SQLite.swift/pull/1121
172+
[#1128]: https://github.com/stephencelis/SQLite.swift/issues/1128
173+
[#1130]: https://github.com/stephencelis/SQLite.swift/issues/1130
174+
[#1131]: https://github.com/stephencelis/SQLite.swift/pull/1131
175+
[#1132]: https://github.com/stephencelis/SQLite.swift/pull/1132
176+
[#1137]: https://github.com/stephencelis/SQLite.swift/pull/1137
177+
[#1138]: https://github.com/stephencelis/SQLite.swift/pull/1138
178+
[#1139]: https://github.com/stephencelis/SQLite.swift/pull/1139
179+
[#1142]: https://github.com/stephencelis/SQLite.swift/pull/1142

Documentation/Index.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- [Read-Write Databases](#read-write-databases)
1111
- [Read-Only Databases](#read-only-databases)
1212
- [In-Memory Databases](#in-memory-databases)
13+
- [URI parameters](#uri-parameters)
1314
- [Thread-Safety](#thread-safety)
1415
- [Building Type-Safe SQL](#building-type-safe-sql)
1516
- [Expressions](#expressions)
@@ -61,9 +62,9 @@
6162
- [Custom Collations](#custom-collations)
6263
- [Full-text Search](#full-text-search)
6364
- [Executing Arbitrary SQL](#executing-arbitrary-sql)
65+
- [Attaching and detaching databases](#attaching-and-detaching-databases)
6466
- [Logging](#logging)
6567

66-
6768
[]: #sqliteswift-documentation
6869

6970

@@ -334,6 +335,16 @@ let db = try Connection(.temporary)
334335
In-memory databases are automatically deleted when the database connection is
335336
closed.
336337

338+
#### URI parameters
339+
340+
We can pass `.uri` to the `Connection` initializer to control more aspects of
341+
the database connection with the help of `URIQueryParameter`s:
342+
343+
```swift
344+
let db = try Connection(.uri("file.sqlite", parameters: [.cache(.private)], .noLock(true)]))
345+
```
346+
347+
See [Uniform Resource Identifiers](https://www.sqlite.org/uri.html) for more details.
337348

338349
#### Thread-Safety
339350

@@ -2070,6 +2081,25 @@ let backup = try db.backup(usingConnection: target)
20702081
try backup.step()
20712082
```
20722083

2084+
## Attaching and detaching databases
2085+
2086+
We can [ATTACH](https://www3.sqlite.org/lang_attach.html) and [DETACH](https://www3.sqlite.org/lang_detach.html)
2087+
databases to an existing connection:
2088+
2089+
```swift
2090+
let db = try Connection("db.sqlite")
2091+
2092+
try db.attach(.uri("external.sqlite", parameters: [.mode(.readOnly)), as: "external")
2093+
// ATTACH DATABASE 'file:external.sqlite?mode=ro' AS 'external'
2094+
2095+
let table = Table("table", database: "external")
2096+
let count = try db.scalar(table.count)
2097+
// SELECT count(*) FROM 'external.table'
2098+
2099+
try db.detach("external")
2100+
// DETACH DATABASE 'external'
2101+
```
2102+
20732103
## Logging
20742104

20752105
We can log SQL using the database’s `trace` function.

SQLite.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
3DF7B78C28842C23005DD8CA /* ResultTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResultTests.swift; sourceTree = "<group>"; };
278278
3DF7B790288449BA005DD8CA /* URIQueryParameter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URIQueryParameter.swift; sourceTree = "<group>"; };
279279
3DF7B79528846FCC005DD8CA /* Resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Resources; sourceTree = "<group>"; };
280+
3DF7B79A2884C353005DD8CA /* CHANGELOG.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = "<group>"; };
280281
49EB68C31F7B3CB400D89D40 /* Coding.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Coding.swift; sourceTree = "<group>"; };
281282
997DF2AD287FC06D00F8DF95 /* Query+with.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Query+with.swift"; sourceTree = "<group>"; };
282283
A121AC451CA35C79005A31D1 /* SQLite.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SQLite.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -534,6 +535,7 @@
534535
isa = PBXGroup;
535536
children = (
536537
EE247B771C3F40D700AE3E12 /* README.md */,
538+
3DF7B79A2884C353005DD8CA /* CHANGELOG.md */,
537539
EE247B8B1C3F820300AE3E12 /* CONTRIBUTING.md */,
538540
EE247B931C3F826100AE3E12 /* SQLite.swift.podspec */,
539541
EE247B8D1C3F821200AE3E12 /* Makefile */,

Sources/SQLite/Core/URIQueryParameter.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Foundation
22

3+
/// See https://www.sqlite.org/uri.html
34
public enum URIQueryParameter: CustomStringConvertible {
45
public enum FileMode: String {
56
case readOnly = "ro", readWrite = "rw", readWriteCreate = "rwc", memory
@@ -29,7 +30,7 @@ public enum URIQueryParameter: CustomStringConvertible {
2930
case nolock(Bool)
3031

3132
/// The psow query parameter overrides the `powersafe_overwrite` property of the database file being opened.
32-
case psow(Bool)
33+
case powersafeOverwrite(Bool)
3334

3435
/// The vfs query parameter causes the database connection to be opened using the VFS called NAME.
3536
case vfs(String)
@@ -45,7 +46,7 @@ public enum URIQueryParameter: CustomStringConvertible {
4546
case .modeOf(let filename): return .init(name: "modeOf", value: filename)
4647
case .mode(let fileMode): return .init(name: "mode", value: fileMode.rawValue)
4748
case .nolock(let bool): return .init(name: "nolock", value: NSNumber(value: bool).description)
48-
case .psow(let bool): return .init(name: "psow", value: NSNumber(value: bool).description)
49+
case .powersafeOverwrite(let bool): return .init(name: "psow", value: NSNumber(value: bool).description)
4950
case .vfs(let name): return .init(name: "vfs", value: name)
5051
}
5152
}

0 commit comments

Comments
 (0)