PR: Feature - SQLite uuid Extension#170
PR: Feature - SQLite uuid Extension#170LucaCappelletti94 wants to merge 17 commits intoSpxg:masterfrom
uuid Extension#170Conversation
|
Thank you for your work. I haven't reviewed it yet, but would it be possible to put these changes in a new repository, such as |
|
I suppose so, but how is that crate then folded into the first one at compile time? Maybe it is straightforward, I just haven't understood. |
|
No ok sure, just I wasn't clear how it was compiled against sqlite. I will read more in details later. |
|
Would you prefer these extension to be in one or two crates? |
|
Just fyi, I also tried to use directly the I will continue with the original approach of just slightly reworking the |
|
Ok I managed to rewrite the whole thing solely using the |
|
I have updated the original post to reflect the changes made. |
|
I haven't looked at the implementation in detail yet, but it seems that those C shims from sqlite-wasm-rs are no longer needed, right? Then I think this can be considered your own project, rather than contributing code to sqlite-wasm-rs. |
Yes I think that as it is now, it should be rather modular. Still, with uuid being a very standard type it is somewhat reasonable to have it here and avoid future API changes potentially breaking something. That being said, if you prefer I can fold it into a crate of my own. |
Given that sqlite-wasm-rs is currently used by diesel and rusqlite, it now and in the future only provides SQLite C API, so it is stable.
Yeah, thanks for your work! |
|
Trivial question - are these extensions usable in diesel? Right now your example only shows how to load this extension in rustqlite. |
|
Adding extension is unrelated to diesel, just use |
|
Ok! My confusion was only caused by: |
|
yeah.. rusqlite re-exported the ffi from sqlite-wasm-rs |
|
For future reference, it is here: https://docs.rs/sqlite-wasm-uuid-rs/latest/sqlite_wasm_uuid_rs/ |
This PR introduces implementations of SQLite UUID extensions, specifically UUIDv4 (Random) and UUIDv7 (Time-ordered). These extensions are implemented as separate crates within the workspace (
extensions/uuid4,extensions/uuid7) usingsqlite-wasm-rsbindings and the nativeuuidcrate.This allows users to generate and manipulate RFC-9562 UUIDs directly within SQL queries in a WASM environment.
UUIDv4 (Random)
Based on the standard SQLite
uuid.cAPI but implemented in Rust.uuid(): Generates a random 36-char string.uuid_str(X): Standardizes input (Blob/Text) to 36-char string.uuid_blob(X): Converts input to 16-byte BLOB.uuid_blob(): (Added) Generates a new random 16-byte BLOB directly.UUIDv7 (Time-Ordered)
A new extension for timestamp-based UUIDs, providing better index locality for direct SQLite use.
uuid7(): Generates a time-ordered 36-char string.uuid7_blob(X): Converts input to 16-byte BLOB.uuid7_blob(): Generates a new time-ordered 16-byte BLOB directly.Testing
DEFAULTcolumn values in schemas.