Skip to content
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

A minor overhaul #68

Merged
merged 19 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
11190b8
Bump minimum Swift version to 5.8. Update CI. General package cleanup…
gwynne May 2, 2024
e996789
Add explicit async versions of all ELF methods of SQLiteConnection
gwynne May 2, 2024
f2ca495
Improve handling of blob and text data in SQLiteData
gwynne May 2, 2024
b8ae701
Make `String` accept integer and real values as well as textual value…
gwynne May 2, 2024
9e3ea3d
SQLiteStatement: Use sqlite_prepare_v3() instead of _v2(). Factor out…
gwynne May 2, 2024
1a60e8d
Misc minor cleanup (Style only, nothing functional)
gwynne May 2, 2024
7cb2579
Tests: Make all tests async. Add helper to replace use of defer {}. A…
gwynne May 2, 2024
3028277
Remove incorrect new protocol requirements. Add passthroughs for the …
gwynne May 2, 2024
c51dcfe
Split the SQLDatabase protocol into its own file. Group SQLiteConnnec…
gwynne May 2, 2024
1c93f94
We always pass SQLITE_OPEN_FULLMUTEX (serialized mode) to sqlite3_ope…
gwynne May 3, 2024
2566f04
Add test that validates we're using SQLite in the correct (safest) th…
gwynne May 3, 2024
89e319f
Fix a couple of log messages
gwynne May 4, 2024
ccc22b5
Apply several SQLite compilation settings according to upstream docum…
gwynne May 4, 2024
0e5ca1a
As recommended in the docs, mark custom functions SQLITE_DIRECTONLY b…
gwynne May 4, 2024
8c9aa9b
Remove not yet available upcoming/experimental feature flags from the…
gwynne May 4, 2024
6daa67b
Update dependency minimums
gwynne May 10, 2024
6f72ea1
Add support for SQLite's extended result codes
gwynne May 10, 2024
84c80bd
Lots of documentation comments. Reorganize SQLiteConnection a little.…
gwynne May 10, 2024
575470b
Try to silence TSan false positives in 5.8
gwynne May 10, 2024
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
12 changes: 0 additions & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
version: 2
enable-beta-ecosystems: true
updates:
- package-ecosystem: "github-actions"
directory: "/"
Expand All @@ -11,14 +10,3 @@ updates:
dependencies:
patterns:
- "*"
- package-ecosystem: "swift"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 6
allow:
- dependency-type: all
groups:
all-dependencies:
patterns:
- "*"
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
dependents-check:
if: ${{ !(github.event.pull_request.draft || false) }}
runs-on: ubuntu-latest
container: swift:5.9-jammy
container: swift:5.10-jammy
steps:
- name: Check out package
uses: actions/checkout@v4
Expand All @@ -38,3 +38,4 @@ jobs:

unit-tests:
uses: vapor/ci/.github/workflows/run-unit-tests.yml@main
secrets: inherit
105 changes: 69 additions & 36 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.7
// swift-tools-version:5.8
import PackageDescription

let package = Package(
Expand All @@ -13,8 +13,8 @@ let package = Package(
.library(name: "SQLiteNIO", targets: ["SQLiteNIO"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.58.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.62.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
],
targets: [
.plugin(
Expand All @@ -25,38 +25,71 @@ let package = Package(
),
exclude: ["001-warnings-and-data-race.patch"]
),
.target(name: "CSQLite", cSettings: [
// Derived from sqlite3 version 3.43.0
.define("SQLITE_DQS", to: "0"),
.define("SQLITE_ENABLE_API_ARMOR"),
.define("SQLITE_ENABLE_COLUMN_METADATA"),
.define("SQLITE_ENABLE_DBSTAT_VTAB"),
.define("SQLITE_ENABLE_FTS3"),
.define("SQLITE_ENABLE_FTS3_PARENTHESIS"),
.define("SQLITE_ENABLE_FTS3_TOKENIZER"),
.define("SQLITE_ENABLE_FTS4"),
.define("SQLITE_ENABLE_FTS5"),
.define("SQLITE_ENABLE_MEMORY_MANAGEMENT"),
.define("SQLITE_ENABLE_PREUPDATE_HOOK"),
.define("SQLITE_ENABLE_RTREE"),
.define("SQLITE_ENABLE_SESSION"),
.define("SQLITE_ENABLE_STMTVTAB"),
.define("SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION"),
.define("SQLITE_ENABLE_UNLOCK_NOTIFY"),
.define("SQLITE_MAX_VARIABLE_NUMBER", to: "250000"),
.define("SQLITE_LIKE_DOESNT_MATCH_BLOBS"),
.define("SQLITE_OMIT_DEPRECATED"),
.define("SQLITE_OMIT_LOAD_EXTENSION"),
.define("SQLITE_OMIT_SHARED_CACHE"),
.define("SQLITE_SECURE_DELETE"),
.define("SQLITE_THREADSAFE", to: "2"),
.define("SQLITE_USE_URI"),
]),
.target(name: "SQLiteNIO", dependencies: [
.target(name: "CSQLite"),
.product(name: "Logging", package: "swift-log"),
.product(name: "NIO", package: "swift-nio"),
]),
.testTarget(name: "SQLiteNIOTests", dependencies: ["SQLiteNIO"]),
.target(
name: "CSQLite",
cSettings: sqliteCSettings
),
.target(
name: "SQLiteNIO",
dependencies: [
.target(name: "CSQLite"),
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "SQLiteNIOTests",
dependencies: [
.target(name: "SQLiteNIO"),
],
swiftSettings: swiftSettings
),
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency=complete"),
] }
gwynne marked this conversation as resolved.
Show resolved Hide resolved

var sqliteCSettings: [CSetting] { [
// Derived from sqlite3 version 3.43.0
.define("SQLITE_DEFAULT_MEMSTATUS", to: "0"),
.define("SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS"),
.define("SQLITE_DQS", to: "0"),
.define("SQLITE_ENABLE_API_ARMOR", .when(configuration: .debug)),
.define("SQLITE_ENABLE_COLUMN_METADATA"),
.define("SQLITE_ENABLE_DBSTAT_VTAB"),
.define("SQLITE_ENABLE_FTS3"),
.define("SQLITE_ENABLE_FTS3_PARENTHESIS"),
.define("SQLITE_ENABLE_FTS3_TOKENIZER"),
.define("SQLITE_ENABLE_FTS4"),
.define("SQLITE_ENABLE_FTS5"),
.define("SQLITE_ENABLE_NULL_TRIM"),
.define("SQLITE_ENABLE_RTREE"),
.define("SQLITE_ENABLE_SESSION"),
.define("SQLITE_ENABLE_STMTVTAB"),
.define("SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION"),
.define("SQLITE_ENABLE_UNLOCK_NOTIFY"),
.define("SQLITE_MAX_VARIABLE_NUMBER", to: "250000"),
.define("SQLITE_LIKE_DOESNT_MATCH_BLOBS"),
.define("SQLITE_OMIT_AUTHORIZATION"),
.define("SQLITE_OMIT_COMPLETE"),
.define("SQLITE_OMIT_DEPRECATED"),
.define("SQLITE_OMIT_DESERIALIZE"),
.define("SQLITE_OMIT_GET_TABLE"),
.define("SQLITE_OMIT_LOAD_EXTENSION"),
.define("SQLITE_OMIT_PROGRESS_CALLBACK"),
.define("SQLITE_OMIT_SHARED_CACHE"),
.define("SQLITE_OMIT_TCL_VARIABLE"),
.define("SQLITE_OMIT_TRACE"),
.define("SQLITE_SECURE_DELETE"),
.define("SQLITE_THREADSAFE", to: "1"),
.define("SQLITE_UNTESTABLE"),
.define("SQLITE_USE_URI"),
] }
99 changes: 99 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "sqlite-nio",
platforms: [
.macOS(.v10_15),
.iOS(.v13),
.watchOS(.v6),
.tvOS(.v13),
],
products: [
.library(name: "SQLiteNIO", targets: ["SQLiteNIO"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.62.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.0"),
],
targets: [
.plugin(
name: "VendorSQLite",
capability: .command(
intent: .custom(verb: "vendor-sqlite", description: "Vendor SQLite"),
permissions: [
.allowNetworkConnections(scope: .all(ports: [443]), reason: "Retrieve the latest build of SQLite"),
.writeToPackageDirectory(reason: "Update the vendored SQLite files"),
]
),
exclude: ["001-warnings-and-data-race.patch"]
),
.target(
name: "CSQLite",
cSettings: sqliteCSettings
),
.target(
name: "SQLiteNIO",
dependencies: [
.target(name: "CSQLite"),
.product(name: "Logging", package: "swift-log"),
.product(name: "NIOCore", package: "swift-nio"),
.product(name: "NIOPosix", package: "swift-nio"),
.product(name: "NIOFoundationCompat", package: "swift-nio"),
],
swiftSettings: swiftSettings
),
.testTarget(
name: "SQLiteNIOTests",
dependencies: [
.target(name: "SQLiteNIO"),
],
swiftSettings: swiftSettings
),
]
)

var swiftSettings: [SwiftSetting] { [
.enableUpcomingFeature("ExistentialAny"),
.enableUpcomingFeature("ConciseMagicFile"),
.enableUpcomingFeature("ForwardTrailingClosures"),
.enableUpcomingFeature("DisableOutwardActorInference"),
.enableExperimentalFeature("StrictConcurrency=complete"),
] }

var sqliteCSettings: [CSetting] { [
// Derived from sqlite3 version 3.43.0
.define("SQLITE_DEFAULT_MEMSTATUS", to: "0"),
.define("SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS"),
.define("SQLITE_DQS", to: "0"),
.define("SQLITE_ENABLE_API_ARMOR", .when(configuration: .debug)),
.define("SQLITE_ENABLE_COLUMN_METADATA"),
.define("SQLITE_ENABLE_DBSTAT_VTAB"),
.define("SQLITE_ENABLE_FTS3"),
.define("SQLITE_ENABLE_FTS3_PARENTHESIS"),
.define("SQLITE_ENABLE_FTS3_TOKENIZER"),
.define("SQLITE_ENABLE_FTS4"),
.define("SQLITE_ENABLE_FTS5"),
.define("SQLITE_ENABLE_NULL_TRIM"),
.define("SQLITE_ENABLE_RTREE"),
.define("SQLITE_ENABLE_SESSION"),
.define("SQLITE_ENABLE_STMTVTAB"),
.define("SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION"),
.define("SQLITE_ENABLE_UNLOCK_NOTIFY"),
.define("SQLITE_MAX_VARIABLE_NUMBER", to: "250000"),
.define("SQLITE_LIKE_DOESNT_MATCH_BLOBS"),
.define("SQLITE_OMIT_AUTHORIZATION"),
.define("SQLITE_OMIT_COMPLETE"),
.define("SQLITE_OMIT_DEPRECATED"),
.define("SQLITE_OMIT_DESERIALIZE"),
.define("SQLITE_OMIT_GET_TABLE"),
.define("SQLITE_OMIT_LOAD_EXTENSION"),
.define("SQLITE_OMIT_PROGRESS_CALLBACK"),
.define("SQLITE_OMIT_SHARED_CACHE"),
.define("SQLITE_OMIT_TCL_VARIABLE"),
.define("SQLITE_OMIT_TRACE"),
.define("SQLITE_SECURE_DELETE"),
.define("SQLITE_THREADSAFE", to: "1"),
.define("SQLITE_UNTESTABLE"),
.define("SQLITE_USE_URI"),
] }
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<a href="https://docs.vapor.codes/4.0/"><img src="https://design.vapor.codes/images/readthedocs.svg" alt="Documentation"></a>
<a href="https://discord.gg/vapor"><img src="https://design.vapor.codes/images/discordchat.svg" alt="Team Chat"></a>
<a href="LICENSE"><img src="https://design.vapor.codes/images/mitlicense.svg" alt="MIT License"></a>
<a href="https://github.com/vapor/sqlite-nio/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/sqlite-nio/test.yml?event=push&style=plastic&logo=github&label=test&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/sqlite-nio"><img src="https://img.shields.io/codecov/c/github/vapor/sqlite-nio?style=plastic&logo=codecov&label=Codecov"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift57up.svg" alt="Swift 5.7+"></a>
<a href="https://github.com/vapor/sqlite-nio/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/vapor/sqlite-nio/test.yml?event=push&style=plastic&logo=github&label=tests&logoColor=%23ccc" alt="Continuous Integration"></a>
<a href="https://codecov.io/github/vapor/sqlite-nio"><img src="https://img.shields.io/codecov/c/github/vapor/sqlite-nio?style=plastic&logo=codecov&label=codecov"></a>
<a href="https://swift.org"><img src="https://design.vapor.codes/images/swift58up.svg" alt="Swift 5.8+"></a>
</p>

<br>
Expand Down
5 changes: 2 additions & 3 deletions Sources/SQLiteNIO/Docs.docc/Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
@TitleHeading(Package)
}

🪶 Non-blocking, event-driven Swift client for SQLite with embedded libsqlite
🪶 Non-blocking, event-driven Swift client for SQLite with embedded `libsqlite`.

## Supported Versions

This package is compatible with all platforms supported by [SwiftNIO 2.x](https://github.com/apple/swift-nio/). It has
been specifically tested on the following platforms:
This package is compatible with all platforms supported by [SwiftNIO 2.x](https://github.com/apple/swift-nio/). It has been specifically tested on the following platforms:

- Ubuntu 20.04 ("Focal") and 22.04 ("Jammy")
- Amazon Linux 2
Expand Down
2 changes: 1 addition & 1 deletion Sources/SQLiteNIO/Docs.docc/theme-settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"theme": {
"aside": { "border-radius": "6px", "border-style": "double", "border-width": "3px" },
"aside": { "border-radius": "16px", "border-style": "double", "border-width": "3px" },
"border-radius": "0",
"button": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
"code": { "border-radius": "16px", "border-width": "1px", "border-style": "solid" },
Expand Down
12 changes: 0 additions & 12 deletions Sources/SQLiteNIO/Exports.swift
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#if swift(>=5.8)

@_documentation(visibility: internal) @_exported import struct NIOCore.ByteBuffer
@_documentation(visibility: internal) @_exported import class NIOPosix.NIOThreadPool
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoop
@_documentation(visibility: internal) @_exported import protocol NIOCore.EventLoopGroup
@_documentation(visibility: internal) @_exported import class NIOPosix.MultiThreadedEventLoopGroup

#else

@_exported import struct NIOCore.ByteBuffer
@_exported import class NIOPosix.NIOThreadPool
@_exported import protocol NIOCore.EventLoop
@_exported import protocol NIOCore.EventLoopGroup
@_exported import class NIOPosix.MultiThreadedEventLoopGroup

#endif
Loading
Loading