Skip to content

feat: adding sync support#166

Merged
lex148 merged 1 commit intoweldsorm:sync_sqlitefrom
SilentVoid13:main
Jan 7, 2026
Merged

feat: adding sync support#166
lex148 merged 1 commit intoweldsorm:sync_sqlitefrom
SilentVoid13:main

Conversation

@SilentVoid13
Copy link
Contributor

I really enjoy welds' simple ergonomics as an ORM. However one thing I miss is sync support, as I prefer it over async in most cases. Making a whole program async just to communicate with the database isn't ideal.

This PR adds sync support via maybe_async.
This has multiple advantages:

  • No code duplication, which means no added maintenance burden
  • Easy to understand/use (a simple proc-macro)

Here is a summary of the changes I made to support sync:

  • welds: welds' core was already more or less async-free, it only required it to communicate with welds-connection. Adding a bunch of #[maybe_async::maybe_async] was enough to convert it.
  • welds-macros: changes were minimal as well, it only required a few tweaks to only emit async fn/ .await in the async case
  • welds-connections: changes are more consequent as I added a new synchronous client to use with the new sync API. It's an sqlite client using rusqlite

New features added:

  • __sync: internal feature used to enable/disable sync code compilation
  • sqlite-sync: enables the sync sqlite client
  • full-sync: same as full but for sync features

A couple of things to note:

  • sync/async code is mutually exclusive, you can't compile both sync and async code at the same time. Allowing such a use case would require a much more consequent refactor
  • I had to pin the exact rusqlite version because the libsqlite3-sys version was conflicting with sqlx. Maybe there's a more elegant solution

Although this PR might seem big, it's mostly just slapping a bunch of #[maybe_async::maybe_async] to enable both async and sync code. Hope you'll consider merging it!

@lex148 lex148 changed the base branch from main to sync_sqlite January 7, 2026 00:20
@lex148
Copy link
Contributor

lex148 commented Jan 7, 2026

This is awesome, yeah I want to merge it!
I am going to pull it into it's own branch first so I can add a bunch of tests and give it the works before it hits main.

Thanks for all the hard work!

@lex148 lex148 merged commit 2940491 into weldsorm:sync_sqlite Jan 7, 2026
8 checks passed
@SilentVoid13
Copy link
Contributor Author

Glad to hear that! Happy to help if you need or have any questions to improve the PR. Thank you for this great lib

@lex148
Copy link
Contributor

lex148 commented Jan 9, 2026

Hey @SilentVoid13. thought you might like to know all the tests are passing and this has made it to main.

@SilentVoid13
Copy link
Contributor Author

that's awesome, thank you for the speed!

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