Skip to content

Commit be7051a

Browse files
authored
Leverage improvements in SQLKit, SQLiteNIO, and SQLiteKit (#90)
* Package structure and docs updates * Code cleanup. Properly support SQLiteDataDecoder. * Fix SQliteDatabaseOutput * Fix Sendability warnings from AsyncKit * Handle extended result codes in the DatabaseError conformance * Clean up tests * Actually use the language feature flags * Support customized JSON coders and query logging levels, add support for the newer SQLKit stuff, route more things through SQLiteKit so we don't have as much duplicated functionality * Tidy code, async-ify the last non-async test, add custom JSON coders test * Update CI * Fix API breakages
1 parent d76674f commit be7051a

17 files changed

+559
-413
lines changed

.github/CONTRIBUTING.md

-34
This file was deleted.

.github/dependabot.yml

-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
version: 2
2-
enable-beta-ecosystems: true
32
updates:
43
- package-ecosystem: "github-actions"
54
directory: "/"
@@ -9,12 +8,3 @@ updates:
98
dependencies:
109
patterns:
1110
- "*"
12-
- package-ecosystem: "swift"
13-
directory: "/"
14-
schedule:
15-
interval: "daily"
16-
groups:
17-
dependencies:
18-
patterns:
19-
- "*"
20-

.github/workflows/test.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ on:
99
jobs:
1010
unit-tests:
1111
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
12-
with:
13-
with_tsan: false
12+
secrets: inherit

Package.swift

+27-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.7
1+
// swift-tools-version:5.8
22
import PackageDescription
33

44
let package = Package(
@@ -13,20 +13,33 @@ let package = Package(
1313
.library(name: "FluentSQLiteDriver", targets: ["FluentSQLiteDriver"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.45.0"),
17-
.package(url: "https://github.com/vapor/sqlite-kit.git", from: "4.4.1"),
18-
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.3"),
16+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.3"),
17+
.package(url: "https://github.com/vapor/sqlite-kit.git", from: "4.5.0"),
18+
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
1919
],
2020
targets: [
21-
.target(name: "FluentSQLiteDriver", dependencies: [
22-
.product(name: "FluentKit", package: "fluent-kit"),
23-
.product(name: "FluentSQL", package: "fluent-kit"),
24-
.product(name: "Logging", package: "swift-log"),
25-
.product(name: "SQLiteKit", package: "sqlite-kit"),
26-
]),
27-
.testTarget(name: "FluentSQLiteDriverTests", dependencies: [
28-
.product(name: "FluentBenchmark", package: "fluent-kit"),
29-
.target(name: "FluentSQLiteDriver"),
30-
]),
21+
.target(
22+
name: "FluentSQLiteDriver",
23+
dependencies: [
24+
.product(name: "FluentKit", package: "fluent-kit"),
25+
.product(name: "FluentSQL", package: "fluent-kit"),
26+
.product(name: "Logging", package: "swift-log"),
27+
.product(name: "SQLiteKit", package: "sqlite-kit"),
28+
],
29+
swiftSettings: swiftSettings
30+
),
31+
.testTarget(
32+
name: "FluentSQLiteDriverTests",
33+
dependencies: [
34+
.product(name: "FluentBenchmark", package: "fluent-kit"),
35+
.target(name: "FluentSQLiteDriver"),
36+
],
37+
swiftSettings: swiftSettings
38+
),
3139
]
3240
)
41+
42+
var swiftSettings: [SwiftSetting] { [
43+
.enableUpcomingFeature("ConciseMagicFile"),
44+
.enableUpcomingFeature("ForwardTrailingClosures"),
45+
] }

Package@swift-5.9.swift

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// swift-tools-version:5.9
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "fluent-sqlite-driver",
6+
platforms: [
7+
.macOS(.v10_15),
8+
.iOS(.v13),
9+
.watchOS(.v6),
10+
.tvOS(.v13),
11+
],
12+
products: [
13+
.library(name: "FluentSQLiteDriver", targets: ["FluentSQLiteDriver"]),
14+
],
15+
dependencies: [
16+
.package(url: "https://github.com/vapor/fluent-kit.git", from: "1.48.3"),
17+
.package(url: "https://github.com/vapor/sqlite-kit.git", from: "4.5.0"),
18+
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
19+
],
20+
targets: [
21+
.target(
22+
name: "FluentSQLiteDriver",
23+
dependencies: [
24+
.product(name: "FluentKit", package: "fluent-kit"),
25+
.product(name: "FluentSQL", package: "fluent-kit"),
26+
.product(name: "Logging", package: "swift-log"),
27+
.product(name: "SQLiteKit", package: "sqlite-kit"),
28+
],
29+
swiftSettings: swiftSettings
30+
),
31+
.testTarget(
32+
name: "FluentSQLiteDriverTests",
33+
dependencies: [
34+
.product(name: "FluentBenchmark", package: "fluent-kit"),
35+
.target(name: "FluentSQLiteDriver"),
36+
],
37+
swiftSettings: swiftSettings
38+
),
39+
]
40+
)
41+
42+
var swiftSettings: [SwiftSetting] { [
43+
.enableUpcomingFeature("ExistentialAny"),
44+
.enableUpcomingFeature("ConciseMagicFile"),
45+
.enableUpcomingFeature("ForwardTrailingClosures"),
46+
.enableUpcomingFeature("DisableOutwardActorInference"),
47+
.enableExperimentalFeature("StrictConcurrency=complete"),
48+
] }

README.md

+29-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
<p align="center">
22
<picture>
3-
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/fluent-sqlite-driver/assets/1130717/2d1702d2-d704-4e88-bfb7-614b6783fda7">
4-
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/fluent-sqlite-driver/assets/1130717/371062b5-033e-443e-82ae-e84c07362273">
5-
<img src="https://github.com/vapor/fluent-sqlite-driver/assets/1130717/371062b5-033e-443e-82ae-e84c07362273" height="96" alt="FluentSQLite">
6-
</picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/fluent-sqlite-driver/assets/1130717/8ea4e505-ae30-4f94-982c-39c86c01754f">
4+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/fluent-sqlite-driver/assets/1130717/9553b52f-7724-4d75-8a8b-5be564cd20d8">
5+
<img src="https://github.com/vapor/fluent-sqlite-driver/assets/1130717/9553b52f-7724-4d75-8a8b-5be564cd20d8" height="96" alt="FluentSQLiteDriver">
6+
</picture>
77
<br>
88
<br>
9-
<a href="https://docs.vapor.codes/4.0/"><img src="https://img.shields.io/badge/read_the-docs-2196f3.svg?logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxNiAxNiIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB4PSIxLjQiIHk9IjIuMzUiIHdpZHRoPSIxMy4yIiBoZWlnaHQ9IjkuOCIgc3R5bGU9ImZpbGw6ICNkZmRiZjM7IG9wYWNpdHk6IDAuMzMzMzM7Ii8%2BPHBhdGggc3R5bGU9ImZpbGw6ICNmZmY7IiBkPSJNMCwxLjc1YzAsLTAuNCAwLjM1LC0wLjg1IDAuNzUsLTAuODVjMi43LDAgNS4yNSwtMC42IDcuMjUsMS40YzIsLTIgNC4yNSwtMS40IDcuMjUsLTEuNGMwLjQsMCAwLjc1LDAuNCAwLjc1LDAuODV2MTAuNWMwLDAuNCAtMC4zNSwwLjc1IC0wLjc1LDAuNzVjLTIuNSwwIC00LjgsLTAuNiAtNi43NSwxLjNjLTAuMjUsMC4yNSAtMC43NSwwLjI1IC0xLDBjLTEuNzUsLTEuNyAtNC40NSwtMS4zIC02Ljc1LC0xLjNjLTAuNCwwIC0wLjc1LC0wLjM1IC0wLjc1LC0wLjc1em03LjI1LDEwLjI1di03LjI1Yy0wLjA4LC0yLjk1IC0zLjYsLTIuMjUgLTUuNzUsLTIuMjV2OWMxLjk1LDAgMy45NSwtMC4zIDUuNzUsMC41em0xLjUsLTcuMjV2Ny4yNWMxLjc1LC0wLjg1IDMuODUsLTAuNSA1Ljc1LC0wLjV2LTljLTIuMjUsMCAtNS43NSwtMC43IC01Ljc1LDIuMjV6Ii8%2BPC9zdmc%2BCg%3D%3D&labelColor=gray" alt="Documentation"></a>
10-
<a href="https://discord.gg/vap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NNzAuNTQsMTEuNTJjLS4xLTMuODktMTEuOS0zLjg5LTEyLDB2MTBjLTUuMjcuMTgtMjAuMzYsNy44NS0yNC40Niw4aC0xOC4zOGMtMS42LDAtNS43NTcsMi40NS01LjY5LDYuMDhjLjEsNC41NCw0LjcxLDYuNjUsOS4xOSw1LjkyYzAsMC0xNC45NTcsMzMuMTgtMTYuODgsMzcuNTJjLTMuMzcyLDcuNjEsMTIuNDcsMTQuOTcsMjIuOSwxNC43MmMxMS44LS42LDI2LjEyLTcuMzEsMjIuODYtMTMuOTJjLTIuNS01LjA3LTE2LjY4LTM4LjMyLTE2LjY4LTM4LjMyYzUuNzEsMCwxOC4zNy03Ljg1LDI3LjE0LTh2NzYuNzhoLTIwYy0zLjkxLDAtMy45MSwxMiwwLDEyaDUyYzMuOTEsMCwzLjkxLTEyLDAtMTJoLTIwdi03Ni43OGM4LjctLjEsMjEuMTQsNy45NywyNy4zNCw4YzAsMC0xNC40MSwzMi44NC0xNi44OCwzOC4zMmMtMi43MSw2LDExLjYxLDEzLjkyLDIyLjksMTMuOTJjMTEuOCwwLDI2LjEtNi4zNywyMi45LTEzLjkyYy0yLjItNS4zMS0xNi45LTM4LjMyLTE2LjktMzguMzJjNC44LjQ1LDkuNi0xLjU3LDkuNi01LjkyYy0uMS00LjYtNC02LjA5LTYuMS02LjA4YzAsMC0yMi43OS0uMi0xOC40LDBjMCwwLTE4Ljk4LTcuOTQtMjQuNDYtOHptMzIuODYsNDQuNjQsMTAuNCwyNGMtMy44LDEuNzMtMTguNTksMS4xMi0yMC44NCwwem0tNzcuNywwLDEwLjQ0LDI0Yy04LjAyLDMuMjgtMTUuMDEsMi45MS0yMC44NCwwYzAsMCwxMC4zNi0yMy45NiwxMC40LTI0eiIvPjwvc3ZnPgo%3D" alt="MIT License"></a>
12-
<a href="https://github.com/vapor/fluent-sqlite-driver/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/fluent-sqlite-driver/test.yml?event=push&logo=github&label=test&logoColor=%23ccc" alt="Continuous Integration"></a>
13-
<a href="https://codecov.io/github/vapor/fluent-sqlite-driver"><img src="https://img.shields.io/codecov/c/github/vapor/fluent-sqlite-driver?logo=codecov&label=Codecov&token=srIFeETGfJ"></a>
14-
<a href="https://swift.org"><img src="https://img.shields.io/badge/swift-5.7%2b-f07158?style=flat&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB2aWV3Qm94PSIwIDAgMjQgMjQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI%2BPHBhdGggZD0iTSA2LDI0YyAtMywwIC02LC0zIC02LC02diAtMTJjIDAsLTMgMywtNiA2LC02aCAxMmMgMywwIDYsMyA2LDZ2IDEyYyAwLDMgLTMsNiAtNiw2eiIgZmlsbD0iI2YwNzE1OCIvPjxwYXRoIGQ9Ik0gMTMuNTUsMy40YyA0LjE1LDIuMzkgNi4zLDcuNTMgNS4zLDExLjUgMS45NSwyLjggMS42NSw1LjE3IDEuMzgsNC42NiAtMS4yLC0yLjMzIC0zLjMzLC0xLjQyIC00LjM3LC0wLjcxIC0zLjksMS44MSAtMTAuMTYsMC4xOCAtMTMuNDYsLTUuMDMgMi45OCwyLjIgNy4yLDMuMTUgMTAuMywxLjI1IC00LjYsLTMuNTcgLTguNSwtOS4xNyAtOC41LC05LjI4IDIuMjgsMi4xNSA1Ljk4LDQuODQgNy4zLDUuNzEgLTIuOCwtMy4xIC01LjMsLTYuNjUgLTUuMiwtNi42NSAyLjczLDIuNjggNS42Niw1LjIgOC45LDcuMiAwLjM3LC0wLjc5IDEuNDMsLTQuNDcgLTEuNjUsLTguNjV6IiBmaWxsPSJ3aGl0ZSIvPjwvc3ZnPg%3D%3D&logoColor=%23f07158&labelColor=gray" alt="Swift 5.7+"></a>
9+
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
10+
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
11+
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
12+
<a href="https://github.com/vapor/fluent-sqlite-driver/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/fluent-sqlite-driver/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
13+
<a href="https://codecov.io/github/vapor/fluent-sqlite-driver"><img src="https://img.shields.io/codecov/c/github/vapor/fluent-sqlite-driver?style=plastic&logo=codecov&label=codecov"></a>
14+
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
1515
</p>
16+
1617
<br>
18+
19+
FluentSQLiteDriver is a [FluentKit] driver for SQLite clients. It provides support for using the Fluent ORM with SQLite databases, and uses [SQLiteKit] to provide [SQLKit] driver services, [SQLiteNIO] to connect and communicate databases asynchronously, and [AsyncKit] to provide connection pooling.
20+
21+
[FluentKit]: https://github.com/vapor/fluent-kit
22+
[SQLKit]: https://github.com/vapor/sql-kit
23+
[SQLiteKit]: https://github.com/vapor/sqlite-kit
24+
[SQLiteNIO]: https://github.com/vapor/sqlite-nio
25+
[AsyncKit]: https://github.com/vapor/async-kit
26+
27+
### Usage
28+
29+
Use the SPM string to easily include the dependendency in your `Package.swift` file:
30+
31+
```swift
32+
.package(url: "https://github.com/vapor/fluent-sqlite-driver.git", from: "4.0.0")
33+
```
34+
35+
For additional information, see [the Fluent documentation](https://docs.vapor.codes/fluent/overview/).
Loading
+12-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
# ``FluentSQLiteDriver``
22

3-
FluentSQLiteDriver is a package to integrate SQLiteNIO and and SQLiteKit with FluentKit to make it easy to use and write SQLite database operations in Swift.
3+
FluentSQLiteDriver is a [FluentKit] driver for SQLite clients.
4+
5+
## Overview
6+
7+
FluentSQLiteDriver provides support for using the Fluent ORM with SQLite databases. It uses [SQLiteKit] to provide [SQLKit] driver services, [SQLiteNIO] to connect and communicate with databases asynchronously, and [AsyncKit] to provide connection pooling.
8+
9+
[FluentKit]: https://github.com/vapor/fluent-kit
10+
[SQLKit]: https://github.com/vapor/sql-kit
11+
[SQLiteKit]: https://github.com/vapor/sqlite-kit
12+
[SQLiteNIO]: https://github.com/vapor/sqlite-nio
13+
[AsyncKit]: https://github.com/vapor/async-kit
14+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"theme": {
3+
"aside": { "border-radius": "16px", "border-style": "double", "border-width": "3px" },
4+
"border-radius": "0",
5+
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
6+
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
7+
"color": {
8+
"fluentsqlitedriver": "hsl(215, 45%, 58%)",
9+
"documentation-intro-fill": "radial-gradient(circle at top, var(--color-fluentsqlitedriver) 30%, #000 100%)",
10+
"documentation-intro-accent": "var(--color-fluentsqlitedriver)",
11+
"logo-base": { "dark": "#fff", "light": "#000" },
12+
"logo-shape": { "dark": "#000", "light": "#fff" },
13+
"fill": { "dark": "#000", "light": "#fff" }
14+
},
15+
"icons": { "technology": "/fluentsqlitedriver/images/vapor-fluentsqlitedriver-logo.svg" }
16+
},
17+
"features": {
18+
"quickNavigation": { "enable": true },
19+
"i18n": { "enable": true }
20+
}
21+
}
+1-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,8 @@
1-
#if swift(>=5.8)
2-
31
@_documentation(visibility: internal) @_exported import FluentKit
42
@_documentation(visibility: internal) @_exported import SQLiteKit
53

6-
#else
7-
8-
@_exported import FluentKit
9-
@_exported import SQLiteKit
10-
11-
#endif
12-
134
extension DatabaseID {
145
public static var sqlite: DatabaseID {
15-
return .init(string: "sqlite")
6+
.init(string: "sqlite")
167
}
178
}

0 commit comments

Comments
 (0)