Skip to content

Commit 395a6ea

Browse files
authored
Update for new SQLKit and support more URL string formats (#325)
* Update package infrastructure, bump Swift minimum to 5.8, add ExistentialAny and StrictConcurrency compliance * Leverage the new SQLKit functionality, remove various crashing codepaths from the encoder and decoder, add more features to the dialect, improve NULL handling, other misc cleanup * Remove obsolete file * Add Swift 5.9 manifest * Improve docs * Add support for additional MySQL URL formats. * Add 100% doc comments coverage (rather trivial for this package) * Add tests for new URL formats and use the undeprecated SQLBenchmarker API * Make MySQLConfiguration Sendable
1 parent a9375f8 commit 395a6ea

22 files changed

+866
-355
lines changed

.github/CODEOWNERS

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
* @0xTim @gwynne
1+
* @gwynne
2+
/.github/CONTRIBUTING.md @gwynne @0xTim
3+
/.github/workflows/*.yml @gwynne @0xTim
4+
/.github/workflows/test.yml @gwynne
5+
/.spi.yml @gwynne @0xTim
6+
/.gitignore @gwynne @0xTim
7+
/LICENSE @gwynne @0xTim
8+
/README.md @gwynne @0xTim

.github/workflows/api-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ jobs:
1111
with:
1212
package_name: mysql-kit
1313
modules: MySQLKit
14-
pathsToInvalidate: /mysqlkit
14+
pathsToInvalidate: /mysqlkit/*

.github/workflows/test.yml

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,18 @@ env:
2323
MYSQL_PASSWORD_B: 'test_password'
2424

2525
jobs:
26-
2726
api-breakage:
28-
if: ${{ !(github.event.pull_request.draft || false) }}
27+
if: ${{ github.event_name == 'pull_request' && !(github.event.pull_request.draft || false) }}
2928
runs-on: ubuntu-latest
30-
container: swift:5.9-jammy
29+
container: swift:jammy
3130
steps:
32-
- name: Check out code
31+
- name: Checkout
3332
uses: actions/checkout@v4
3433
with: { 'fetch-depth': 0 }
35-
- name: Run API breakage check action
36-
uses: vapor/ci/.github/actions/ci-swift-check-api-breakage@reusable-workflows
34+
- name: API breaking changes
35+
run: |
36+
git config --global --add safe.directory "${GITHUB_WORKSPACE}"
37+
swift package diagnose-api-breaking-changes origin/main
3738
3839
dependents:
3940
if: ${{ !(github.event.pull_request.draft || false) }}
@@ -53,13 +54,13 @@ jobs:
5354
MYSQL_USER: test_username
5455
MYSQL_PASSWORD: test_password
5556
MYSQL_DATABASE: test_database
56-
container: swift:5.9-jammy
57+
container: swift:5.10-jammy
5758
strategy:
5859
fail-fast: false
5960
matrix:
6061
dbimage:
6162
- mysql:5.7
62-
- mysql:8.1
63+
- mysql:8
6364
- mariadb:11
6465
- percona:8.0
6566
steps:
@@ -85,15 +86,15 @@ jobs:
8586
dbimage:
8687
- mysql:5.7
8788
- mysql:8.0
88-
- mysql:8.1
89+
- mysql:8.3
8990
- mariadb:10.4
9091
- mariadb:11
9192
- percona:8.0
9293
runner:
9394
# List is deliberately incomplete; we want to avoid running 50 jobs on every commit
94-
- swift:5.7-focal
95-
- swift:5.9-jammy
96-
- swiftlang/swift:nightly-5.10-jammy
95+
- swift:5.8-focal
96+
- swift:5.10-jammy
97+
- swiftlang/swift:nightly-6.0-jammy
9798
container: ${{ matrix.runner }}
9899
runs-on: ubuntu-latest
99100
services:
@@ -105,43 +106,36 @@ jobs:
105106
MYSQL_PASSWORD: test_password
106107
MYSQL_DATABASE: test_database
107108
steps:
108-
- name: Save MySQL version to env
109-
run: |
110-
echo MYSQL_VERSION='${{ matrix.dbimage }}' >> $GITHUB_ENV
111-
- name: Display versions
112-
shell: bash
113-
run: |
114-
if [[ '${{ contains(matrix.container, 'nightly') }}' == 'true' ]]; then
115-
SWIFT_PLATFORM="$(source /etc/os-release && echo "${ID}${VERSION_ID}")" SWIFT_VERSION="$(cat /.swift_tag)"
116-
printf 'SWIFT_PLATFORM=%s\nSWIFT_VERSION=%s\n' "${SWIFT_PLATFORM}" "${SWIFT_VERSION}" >>"${GITHUB_ENV}"
117-
fi
118-
printf 'OS: %s\nTag: %s\nVersion:\n' "${SWIFT_PLATFORM}-${RUNNER_ARCH}" "${SWIFT_VERSION}" && swift --version
119109
- name: Check out package
120110
uses: actions/checkout@v4
121111
- name: Run local tests with coverage and TSan
122112
run: swift test --enable-code-coverage --sanitize=thread
123113
- name: Submit coverage report to Codecov.io
124-
uses: vapor/[email protected]
114+
uses: vapor/[email protected]
115+
with:
116+
codecov_token: ${{ secrets.CODECOV_TOKEN }}
125117

126118
# Run unit tests (macOS). Don't bother with lots of variations, Linux will cover that.
127119
macos-unit:
128120
if: ${{ !(github.event.pull_request.draft || false) }}
129121
strategy:
130122
fail-fast: false
131123
matrix:
132-
formula: [ '[email protected]' ]
133-
macos: [ 'macos-13' ]
134-
xcode: [ 'latest-stable' ]
135-
runs-on: ${{ matrix.macos }}
124+
include:
125+
- macos-version: macos-13
126+
xcode-version: '~14.3'
127+
- macos-version: macos-14
128+
xcode-version: latest
129+
runs-on: ${{ matrix.macos-version }}
136130
steps:
137131
- name: Select latest available Xcode
138132
uses: maxim-lobanov/setup-xcode@v1
139-
with:
140-
xcode-version: ${{ matrix.xcode }}
133+
with:
134+
xcode-version: ${{ matrix.xcode-version }}
141135
- name: Install MySQL server from Homebrew
142-
run: brew install ${{ matrix.formula }} && brew link --force ${{ matrix.formula }}
136+
run: brew install mysql && brew link --force mysql
143137
- name: Start MySQL server
144-
run: brew services start ${{ matrix.formula }}
138+
run: brew services start mysql
145139
- name: Wait for MySQL server to be ready
146140
run: until echo | mysql -uroot; do sleep 1; done
147141
timeout-minutes: 5

Package.swift

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.6
1+
// swift-tools-version:5.8
22
import PackageDescription
33

44
let package = Package(
@@ -13,25 +13,40 @@ let package = Package(
1313
.library(name: "MySQLKit", targets: ["MySQLKit"]),
1414
],
1515
dependencies: [
16-
.package(url: "https://github.com/vapor/mysql-nio.git", from: "1.0.0"),
16+
.package(url: "https://github.com/vapor/mysql-nio.git", from: "1.7.1"),
1717
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.28.0"),
18-
.package(url: "https://github.com/vapor/async-kit.git", from: "1.0.0"),
19-
.package(url: "https://github.com/apple/swift-crypto.git", "1.0.0" ..< "4.0.0"),
20-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.0.0"),
21-
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.14.0"),
18+
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
19+
.package(url: "https://github.com/apple/swift-crypto.git", "2.0.0" ..< "4.0.0"),
20+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.64.0"),
21+
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.26.0"),
2222
],
2323
targets: [
24-
.target(name: "MySQLKit", dependencies: [
25-
.product(name: "AsyncKit", package: "async-kit"),
26-
.product(name: "MySQLNIO", package: "mysql-nio"),
27-
.product(name: "SQLKit", package: "sql-kit"),
28-
.product(name: "Crypto", package: "swift-crypto"),
29-
.product(name: "NIOFoundationCompat", package: "swift-nio"),
30-
.product(name: "NIOSSL", package: "swift-nio-ssl"),
31-
]),
32-
.testTarget(name: "MySQLKitTests", dependencies: [
33-
.target(name: "MySQLKit"),
34-
.product(name: "SQLKitBenchmark", package: "sql-kit"),
35-
]),
24+
.target(
25+
name: "MySQLKit",
26+
dependencies: [
27+
.product(name: "AsyncKit", package: "async-kit"),
28+
.product(name: "MySQLNIO", package: "mysql-nio"),
29+
.product(name: "SQLKit", package: "sql-kit"),
30+
.product(name: "Crypto", package: "swift-crypto"),
31+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
32+
.product(name: "NIOSSL", package: "swift-nio-ssl"),
33+
],
34+
swiftSettings: swiftSettings
35+
),
36+
.testTarget(
37+
name: "MySQLKitTests",
38+
dependencies: [
39+
.product(name: "SQLKitBenchmark", package: "sql-kit"),
40+
.target(name: "MySQLKit"),
41+
],
42+
swiftSettings: swiftSettings
43+
),
3644
]
3745
)
46+
47+
var swiftSettings: [SwiftSetting] { [
48+
.enableUpcomingFeature("ConciseMagicFile"),
49+
.enableUpcomingFeature("ForwardTrailingClosures"),
50+
.enableUpcomingFeature("DisableOutwardActorInference"),
51+
.enableExperimentalFeature("StrictConcurrency=complete"),
52+
] }

[email protected]

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// swift-tools-version:5.9
2+
import PackageDescription
3+
4+
let package = Package(
5+
name: "mysql-kit",
6+
platforms: [
7+
.macOS(.v10_15),
8+
.iOS(.v13),
9+
.watchOS(.v6),
10+
.tvOS(.v13),
11+
],
12+
products: [
13+
.library(name: "MySQLKit", targets: ["MySQLKit"]),
14+
],
15+
dependencies: [
16+
.package(url: "https://github.com/vapor/mysql-nio.git", from: "1.7.1"),
17+
.package(url: "https://github.com/vapor/sql-kit.git", from: "3.29.2"),
18+
.package(url: "https://github.com/vapor/async-kit.git", from: "1.19.0"),
19+
.package(url: "https://github.com/apple/swift-crypto.git", "2.0.0" ..< "4.0.0"),
20+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.64.0"),
21+
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.26.0"),
22+
],
23+
targets: [
24+
.target(
25+
name: "MySQLKit",
26+
dependencies: [
27+
.product(name: "AsyncKit", package: "async-kit"),
28+
.product(name: "MySQLNIO", package: "mysql-nio"),
29+
.product(name: "SQLKit", package: "sql-kit"),
30+
.product(name: "Crypto", package: "swift-crypto"),
31+
.product(name: "NIOFoundationCompat", package: "swift-nio"),
32+
.product(name: "NIOSSL", package: "swift-nio-ssl"),
33+
],
34+
swiftSettings: swiftSettings
35+
),
36+
.testTarget(
37+
name: "MySQLKitTests",
38+
dependencies: [
39+
.product(name: "SQLKitBenchmark", package: "sql-kit"),
40+
.target(name: "MySQLKit"),
41+
],
42+
swiftSettings: swiftSettings
43+
),
44+
]
45+
)
46+
47+
var swiftSettings: [SwiftSetting] { [
48+
.enableUpcomingFeature("ExistentialAny"),
49+
.enableUpcomingFeature("ConciseMagicFile"),
50+
.enableUpcomingFeature("ForwardTrailingClosures"),
51+
.enableUpcomingFeature("DisableOutwardActorInference"),
52+
.enableExperimentalFeature("StrictConcurrency=complete"),
53+
] }

README.md

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,42 @@
1-
<img src="https://user-images.githubusercontent.com/1342803/75589537-fbfc9100-5a48-11ea-8732-e75dfe32e338.png" height="64" alt="MySQL">
2-
3-
<a href="https://docs.vapor.codes/4.0/">
4-
<img src="http://img.shields.io/badge/read_the-docs-2196f3.svg" alt="Documentation">
5-
</a>
6-
<a href="https://discord.gg/vapor">
7-
<img src="https://img.shields.io/discord/431917998102675485.svg" alt="Team Chat">
8-
</a>
9-
<a href="LICENSE">
10-
<img src="http://img.shields.io/badge/license-MIT-brightgreen.svg" alt="MIT License">
11-
</a>
12-
<a href="https://github.com/vapor/sql-kit/actions">
13-
<img src="https://github.com/vapor/sql-kit/workflows/test/badge.svg" alt="Continuous Integration">
14-
</a>
15-
<a href="https://swift.org">
16-
<img src="http://img.shields.io/badge/swift-5.2-brightgreen.svg" alt="Swift 5.2">
17-
</a>
1+
<p align="center">
2+
<picture>
3+
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/vapor/mysql-kit/assets/1130717/d5582d0a-f8b2-4fab-aeea-79b170bebc28">
4+
<source media="(prefers-color-scheme: light)" srcset="https://github.com/vapor/mysql-kit/assets/1130717/71d0fa71-5ded-492c-9657-4206f233419e">
5+
<img src="https://github.com/vapor/mysql-kit/assets/1130717/71d0fa71-5ded-492c-9657-4206f233419e" height="96" alt="MySQLKit">
6+
</picture>
187
<br>
198
<br>
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/mysql-kit/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/mysql-kit/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
13+
<a href="https://codecov.io/github/vapor/mysql-kit"><img src="https://img.shields.io/codecov/c/github/vapor/mysql-kit?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>
15+
</p>
2016

21-
🐬 Non-blocking, event-driven Swift client for MySQL.
17+
<br>
2218

23-
### Major Releases
19+
MySQLKit is an [SQLKit] driver for MySQL clients. It supports building and serializing MySQL-dialect SQL queries. MySQLKit uses [MySQLNIO] to connect and communicate with the database server asynchronously. [AsyncKit] is used to provide connection pooling.
2420

25-
The table below shows a list of MySQLKit major releases alongside their compatible NIO and Swift versions.
21+
[SQLKit]: https://github.com/vapor/sql-kit
22+
[MySQLNIO]: https://github.com/vapor/mysql-nio
23+
[AsyncKit]: https://github.com/vapor/async-kit
2624

27-
|Version|NIO|Swift|SPM|
28-
|---|---|---|---|
29-
|4.0|2.0|5.2+|`from: "4.0.0"`|
30-
|3.0|1.0|4.0+|`from: "3.0.0"`|
31-
|2.0|N/A|3.1+|`from: "2.0.0"`|
32-
|1.0|N/A|3.1+|`from: "1.0.0"`|
25+
### Usage
3326

34-
Use the SPM string to easily include the dependency in your `Package.swift` file.
27+
Use the SPM string to easily include the dependendency in your `Package.swift` file.
3528

3629
```swift
37-
.package(url: "https://github.com/vapor/mysql-kit.git", from: ...)
30+
.package(url: "https://github.com/vapor/mysql-kit.git", from: "4.0.0")
3831
```
3932

4033
### Supported Platforms
4134

4235
MySQLKit supports the following platforms:
4336

44-
- Ubuntu 16.04+
37+
- Ubuntu 20.04+
4538
- macOS 10.15+
4639

47-
## Overview
48-
49-
MySQLKit is a MySQL client library built on [SQLKit](https://github.com/vapor/sql-kit). It supports building and serializing MySQL-dialect SQL queries. MySQLKit uses [MySQLNIO](https://github.com/vapor/mysql-nio) to connect and communicate with the database server asynchronously. [AsyncKit](https://github.com/vapor/async-kit) is used to provide connection pooling.
50-
5140
### Configuration
5241

5342
Database connection options and credentials are specified using a `MySQLConfiguration` struct.
@@ -141,4 +130,4 @@ let sql = mysql.sql() // SQLDatabase
141130
let planets = try sql.select().column("*").from("planets").all().wait()
142131
```
143132

144-
Visit [SQLKit's docs](https://github.com/vapor/sql-kit) for more information on using `SQLDatabase`.
133+
Visit [SQLKit's docs](https://api.vapor.codes/sqlkit/documentation/sqlkit) for more information on using `SQLDatabase`.

0 commit comments

Comments
 (0)