Electron100 / butane

An ORM for Rust with a focus on simplicity and on writing Rust, not SQL
Apache License 2.0
91 stars 13 forks source link

JSON support #27

Closed jayvdb closed 1 year ago

jayvdb commented 1 year ago

Most databases support JSON natively, and if they dont butane can convert serde_json::Value to and from a Text type on the transparently.

jayvdb commented 1 year ago

@Electron100 , I have stubbed out an implementation for his at https://github.com/jayvdb/butane/tree/json . If this is roughly how you expect it would be done, I will continue with it as time allows.

Electron100 commented 1 year ago

Thanks! This looks great. Two minor suggestions

  1. This should probably be an optional feature similar to Chrono and Uuid support.
  2. The value in SqlValRef should be a reference
jayvdb commented 1 year ago

fwiw, diesel also doesnt automatically support JSON in the models - it only provides the backend fields able to be put into the schema.rs. Something like https://github.com/terry90/diesel_as_jsonb is needed to avoid lots of boilerplate code.

jayvdb commented 1 year ago

@Electron100 I think I have basic support for JSON working with both pg and sqlite at https://github.com/Electron100/butane/pull/38 , with some tests.