Support for SQLite's JSON/JSONB has landed on diesel
Hello there!
I'm proud to announce one of my first major public contribution to the Rust ecosystem.
My PR to add support for SQLite's JSON/JSONB in diesel, the safe, extensible ORM and Query Builder for Rust, has just been merged on \master\\.
Here is a concrete example of what used to be available to the PostgreSQL backend only, but is now supported on SQLite too:
table! {
contacts {
id -> Integer,
name -> Text,
address -> Jsonb,
}
}
let santas_address: serde_json::Value = serde_json::from_str(r#"{
"street": "Article Circle Expressway 1",
"city": "North Pole",
"postcode": "99705",
"state": "Alaska"
}"#)?;
let inserted_address = insert_into(contacts)
.values((name.eq("Claus"), address.eq(&santas_address)))
.returning(address)
.get_result::<serde_json::Value>(connection)?;
assert_eq!(santas_address, inserted_address);
More in the docs:
https://docs.diesel.rs/master/diesel/sql\_types/struct.Jsonb.html
According to the maintainer:
I think the next step for json support in the SQLite backend is to add definitions for the built-in SQL functions to diesel. Especially adding the json and jsonb functions should make it much easier to actually use this work. If you are interested in working on that as well, just reach out and I will provide more details on how this should be done. That part should be much more straight forward than adding these impls, as we don't need to care about parsing complicated stuff.