Skip to content

Conversation

unhighghlow
Copy link

@unhighghlow unhighghlow commented Aug 23, 2025

This change adds a new feature sqlite-wasm Detects when the target is WASM, which, when enabled, replaces libsqlite3-sys with sqlite-wasm-rs.
It is a new database driver (in the sense that the sqlite-wasm feature should replace the sqlite feature, unlike sqlite-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 in Cargo.lock were modified, which I have no idea how to stop)
Edit: it now uses sqlite-wasm-rs when the target is wasm. This changes the behavior of compiling sqlx with sqlite on WASM from "compilation error" to "success". I don't think this is a breaking change

Problem 1

SQLite-WASM does not support load-extension, which is included in the default configuration for sqlite. There are multiple ways to solve this:

  1. Make sqlite-load-extension cause a build error on WASM, but keep it turned on by default
    • Pros:
      • No workarounds
      • No breaking changes
    • Cons:
      • Very inconvenient for users
    1. It is also possible to add a new feature sqlite-wasm, which decreases the inconvenience
  2. Make sqlite-load-extension cause a build error on WASM and remove it from the defaults
    • Pros:
      • No workarounds
      • No inconvenience
    • Cons:
      • Breaking change
  3. Make sqlite-load-extension cause a build error on WASM, but only when explicitly chosen, with the default being silently ignored
    • Pros:
      • No breaking changes
      • No inconvenience
    • Cons:
      • A janky workaround

Problem 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

  • Add basic functionality
  • Confirm that the APIs of sqlite-wasm-rs and libsqlite3-sys are identical (to be fair I don't really know)
    Oh no

This library is not thread-safe

  • Expose sqlite-wasm-rs features
  • Add docs
  • Add tests

@unhighghlow unhighghlow changed the title Feature: New(-ish) SQLite-for-WASM database backend Feature: SQLite-for-WASM support Aug 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SQLite-for-WASM with SQLx
1 participant