Skip to content

Conversation

@weiznich
Copy link
Member

@weiznich weiznich commented Dec 12, 2025

This commit adds support for using diesel with the SQLite backend
in a no-std (core + alloc) environment.

This mainly means fixing a lot of imports to use the relevant items from core or alloc instead. Notable exceptions are:

  • There is no hashmap in alloc, so we need to pull in hashbrown for this
  • There is no panicing/abort support in core so we need our custom shims for these.
  • Global instrumentation setting is not supported yet (cfged away) as it requires lock which are not supported on embedded targets.

This commit also introduces a new std default feature for enabling std lib support. If disabled the users need to manually enable the hashbrown feature to pull in hashbrown for hashmap support. Cargo doesn't support pulling in dependencies for disabled features.

Finally this commit also adds a example/sqlite/embedded example project that demonstrates how to use this on a esp32-c6.

This is marked as a draft for now as there are a few upstream things that I would like to resolve properly before merging this:

  • Get a new release of libsqlite3-sys with no_std support
  • Get a standalone release of the memfs implementation from sqlite-wasm-rs so that we don't need to vendor their implementation here.
  • (Resolve the merge conflicts)

@weiznich weiznich requested a review from a team December 12, 2025 10:29
@weiznich weiznich force-pushed the diesel/no_std branch 4 times, most recently from 05905e3 to cf53096 Compare December 19, 2025 10:40
@weiznich weiznich marked this pull request as ready for review January 23, 2026 14:10
@weiznich weiznich force-pushed the diesel/no_std branch 7 times, most recently from f8a6772 to 0bdf1c0 Compare January 23, 2026 16:22
@weiznich
Copy link
Member Author

@LucaCappelletti94 You ask where you could help. This PR could use a review from someone that's not me 😉

Copy link
Contributor

@LucaCappelletti94 LucaCappelletti94 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few minor core -> ::core changes needed for consistency

) -> QueryResult<()>
where
F: Fn(#(#arg_name,)*) -> Ret + std::panic::UnwindSafe + Send + 'static,
F: Fn(#(#arg_name,)*) -> Ret + core::panic::UnwindSafe + Send + 'static,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should be ::core I believe

) -> QueryResult<()>
where
F: FnMut(#(#arg_name,)*) -> Ret + std::panic::UnwindSafe + Send + 'static,
F: FnMut(#(#arg_name,)*) -> Ret + core::panic::UnwindSafe + Send + 'static,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should be ::core I believe

) -> QueryResult<()>
where
F: Fn() -> Ret + std::panic::UnwindSafe + Send + 'static,
F: Fn() -> Ret + core::panic::UnwindSafe + Send + 'static,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should be ::core I believe

) -> QueryResult<()>
where
F: FnMut() -> Ret + std::panic::UnwindSafe + Send + 'static,
F: FnMut() -> Ret + core::panic::UnwindSafe + Send + 'static,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should be ::core I believe

+ std::panic::UnwindSafe
+ std::panic::RefUnwindSafe,
+ core::panic::UnwindSafe
+ core::panic::RefUnwindSafe,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency these should be ::core I believe

This commit adds support for using diesel with the SQLite backend
 in a no-std (core + alloc) environment. 

This mainly means fixing a lot of imports to use the relevant items from
core or alloc instead. Notable exceptions are:

* There is no hashmap in alloc, so we need to pull in hashbrown for this
* There is no panicing/abort support in core so we need our custom shims
  for these.
* Global instrumentation setting is not supported yet (cfged away) as it
  requires lock which are not supported on embedded targets.

This commit also introduces a new `std` default feature for enabling `std` lib
support. If disabled the users need to manually enable the `hashbrown`
feature to pull in hashbrown for hashmap support. Cargo doesn't support
pulling in dependencies for disabled features.

Finally this commit also adds a `example/sqlite/embedded` example
project that demonstrates how to use this on a esp32-c6.
@weiznich weiznich added this pull request to the merge queue Jan 30, 2026
Merged via the queue into diesel-rs:main with commit 6bde6e2 Jan 30, 2026
36 checks passed
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.

2 participants