Join Nostr
2026-02-23 06:53:37 UTC
in reply to

Georg Semmler on Nostr: nprofile1q…wmcwl This is not yet exposed by Diesel, but I would happily merge a PR ...

This is not yet exposed by Diesel, but I would happily merge a PR adding support for it.

Generally speaking such a PR would need to contain:

Expose the blob_open() function on SqliteConnection by returning a SqliteBlob type holding a reference to the underlying connection. (Possibly have a read only variant as well). I'm not sure how to handle the row_id lookup there yet. Possibly just expect the user to pass in a primary key value and look up the corresponding row id internally? Maybe even expect a T: IntoUpdateTarget as for update/delete? (Allows using Identifiable or a explicit "query" like users::table.find(42))
The SqliteBlob type needs to implement Drop to call sqlite3_blob_close() if it goes out of scope
The SqliteBlob type needs to implement Write and Read using sqlite3_blob_write and sqlite3_blob_read
We likely want to expose a len() and possibly a is_empty() method based on sqlite3_blob_bytes()
We might want to define zeroblob as sql function somewhere.
Write some tests and documentation.

Overall I think that's a meaningful addition to Diesels API, although I currently do not have the capacity to implement it soon. It still would be great to have that in an feature request, that possibly helps posting the issue to This Week in Rust and similar channels to get someone to try implementing it.