-
I'm struggling to store some JSON in SQLite with Diesel. Such a common task, yet so hard for me to achieve in Diesel. I have this simple schema: diesel::table! {
apps (id) {
id -> BigInt,
name -> Text,
last_price -> Json,
}
} And an entity struct:
It probably fails because it cannot derive Queryable / Selectable for last_price properly, but I don't get how to fix it. By the way, I don't need filtering by this field or anything else, just store and retrieve. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Diesel 2.2.x doesn't contain support for this mapping yet. You can likely provide a new type wrapper to implement that mapping in your crate as custom type mapping. Checkout the FromSql and ToSql docs for that. The diesel master branch contains support for that mapping and for a lot of built-in json functions for SQLite. So the next feature release will provide support for that. |
Beta Was this translation helpful? Give feedback.
It's hard to answer what went wrong with implementing Altherr custom mapper without having the code you wrote.
As for the release: Given that this a free time project the best ETA I can give is: When it's done. You can certainly help making that happen faster by contributing, but otherwise there is specific timeline there.
For allowing any deserializable type there: That's unfortunately not possible as this generic impl would conflict with other existing impls. You can have that on case by case basis by implementing a custom deserialisation (diesel part, not serde part) for your type