Feature: SQLite-for-WASM support #3994
Draft
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.
This change
adds a new featureDetects when the target is WASM, which, when enabled, replacessqlite-wasm
libsqlite3-sys
withsqlite-wasm-rs
.It is a new database driver (in the sense that thesqlite-wasm
feature should replace thesqlite
feature, unlikesqlite-unbundled
)But it is also not new, since no new APIs were created
Does your PR solve an issue?
fixes #2985
Is this a breaking change?
No, as the new database driver:sqlite-wasm
is only activated with the new feature, and without it, no dependencies or APIs are changed. (Except for the fact that some versions inCargo.lock
were modified, which I have no idea how to stop)Edit: it now uses
sqlite-wasm-rs
when the target iswasm
. This changes the behavior of compiling sqlx with sqlite on WASM from "compilation error" to "success". I don't think this is a breaking changeProblem 1
SQLite-WASM does not support
load-extension
, which is included in the default configuration for sqlite. There are multiple ways to solve this:sqlite-load-extension
cause a build error on WASM, but keep it turned on by defaultsqlite-wasm
, which decreases the inconveniencesqlite-load-extension
cause a build error on WASM and remove it from the defaultssqlite-load-extension
cause a build error on WASM, but only when explicitly chosen, with the default being silently ignoredProblem 2
The sqlite version used for compile-time checking (the system one) is different from the sqlite version used at runtime (WASM). This isn't actually a big problem, because the same already happens when using
sqlite-unbundled
Todo
sqlite-wasm-rs
andlibsqlite3-sys
are identical (to be fair I don't really know)Oh no
sqlite-wasm-rs
features