feat: Add Embedded Swift support for SQLiteKit - #5
Draft
scottmarchant wants to merge 1 commit into
Draft
Conversation
scottmarchant
force-pushed
the
feat/embedded-support
branch
from
July 29, 2026 00:21
1921e84 to
339bacd
Compare
scottmarchant
force-pushed
the
feat/wasi-nio-free
branch
from
July 29, 2026 00:21
505c544 to
1927fd4
Compare
scottmarchant
force-pushed
the
feat/embedded-support
branch
from
July 29, 2026 03:24
339bacd to
c39806f
Compare
scottmarchant
force-pushed
the
feat/wasi-nio-free
branch
2 times, most recently
from
July 30, 2026 02:55
f0bff69 to
95a8333
Compare
scottmarchant
force-pushed
the
feat/embedded-support
branch
from
July 30, 2026 02:56
c39806f to
aadde47
Compare
scottmarchant
force-pushed
the
feat/wasi-nio-free
branch
from
July 30, 2026 03:14
95a8333 to
36e0e3b
Compare
scottmarchant
force-pushed
the
feat/embedded-support
branch
from
July 30, 2026 03:14
aadde47 to
02a2e96
Compare
Motivation: Embedded Swift has no Codable, no reflection, no casts to a generic type, and no Foundation. A handful of SQLiteKit declarations depend on one of those and are the only thing standing between the SwiftNIO-free configuration and a `wasm32-unknown-wasip1-embedded` build. Modifications: Elide or substitute exactly those declarations. Every gate is `#if hasFeature(Embedded)` or `#if canImport(Foundation)`, so no other target changes. - `SQLiteConfiguration.Storage.memory` derives its identifier from system randomness where `Foundation.UUID` is unavailable. - `SQLiteDatabaseVersion`'s `isEqual(to:)`/`isOlder(than:)` use `as? Self`, a cast to a generic type Embedded Swift forbids; there the `SQLDatabaseReportedVersion` protocol's `stringValue`-based defaults apply. - Query logging omits the interpolated bind list under Embedded Swift, which has no reflection. - The `Decodable` row-decoding entry points in `SQLiteRow+SQLRow` are elided, matching SQLKit's `SQLRow` protocol on that target. - `SQLiteDataDecoder` and `SQLiteDataEncoder` get Embedded-only variants: the decoder becomes an API-compatible placeholder (there is no Codable engine to drive), and the encoder maps SQLKit's driver-neutral `SQLDataValue` cases straight onto `SQLiteData`, which is what replaces `Encodable`'s `encode(to:)` as the extraction path there. Result: SQLiteKit compiles for `wasm32-unknown-wasip1-embedded`. On every other target the generated symbol graph is unchanged, the same symbols with byte-identical `docComment` line counts, and `diagnose-api-breaking-changes` reports no differences. Building for the Embedded target additionally requires an Embedded-clean `apple/swift-log`; see the pull request description.
scottmarchant
force-pushed
the
feat/embedded-support
branch
from
July 30, 2026 03:48
02a2e96 to
abe450b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4 (
feat/wasi-nio-free) and also depends on PassiveLogic/sql-kit#4, because the EmbeddedSQLiteDataEncoderconsumes SQLKit'sSQLBindValueandSQLDataValue. Retargets tobase/vapor-mainonce #4 merges, so this diff shows only the Embedded work, which is purely additive. Research grade, lower priority than #4, and last in line of the three repos.Makes SQLiteKit compile for
wasm32-unknown-wasip1-embedded.Changes:
SQLiteConfiguration.Storage.memoryderives its identifier from system randomness whereFoundation.UUIDis unavailable.SQLiteDatabaseVersion'sisEqual(to:)/isOlder(than:)useas? Self, a cast to a generic type that Embedded Swift forbids, so SQLKit'sstringValue-based protocol defaults apply there instead.Decodablerow-decoding entry points inSQLiteRow+SQLRoware elided, matching what SQLKit'sSQLRowexposes on that target.SQLiteDataEncodergains an Embedded implementation that maps SQLKit's driver-neutralSQLDataValuecases directly ontoSQLiteData, rather than being elided.SQLiteDataDecoderbecomes an API-compatible placeholder, since there is no Codable engine for it to drive.Where the full toolchain is present, nothing changes: every gate here is false off Embedded.
swift package diagnose-api-breaking-changesagainst #4's tip reports no breaking changes in SQLiteKit, and the 9-test suite passes unchanged.What Embedded loses: Codable-based row decoding (
SQLiteDataDecoderis a stub) and the bind list in query log metadata. Bound parameters still work, through theSQLDataValuemapping above rather than through Codable.Prerequisites outside this repo: the sql-kit Embedded PR above, and an Embedded-clean swift-log (upstream 1.14.0 does not compile under Embedded Swift; the build dies inside
Loggingbefore reaching SQLiteKit). The swift-log patch is verified against a local clone but not committed here, and the manifest still points at upstream.Verification: the Embedded build is green (
DEVELOPMENT-SNAPSHOT-2026-06-12-a-wasm32-unknown-wasip1-embedded, patched swift-log, sibling Embedded branches wired viaswift package edit --path), exercised end to end by a downstream consumer whose Embedded test suite passes against this branch. Native is verified unchanged rather than unchanged by construction: 9 tests green and no API breakage against #4. The parent PR's WASI results carry over.Notes for review: every gate is a capability gate (
hasFeature(Embedded)orcanImport), never a platform check; there is noos(WASI)anywhere in this stack. No SwiftPM traits, no manifest added, no tools-version bump, no new dependencies.