Electron100 / butane

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

WIP: Auto-save Many new_values items #113

Closed jayvdb closed 2 months ago

jayvdb commented 1 year ago

Attempt at solving https://github.com/Electron100/butane/issues/109 It still has lots of todo's:

Electron100 commented 1 year ago

I like the goal, but I'm not wild about the clones (or of the fact that it's a breaking change by requiring the type be clonable), or of the fact that it tries to save again unconditionally even when it may not be necessary. I posted #116 for comparative discussion. It's much less ambitious in that it doesn't achieve the full goal of saving automatically, but it at least makes it harder to accidentally shoot oneself in the foot.

If we want to do automatic save, I'd lean more towards doing that save right away in the add method rather than cloning to do it later in the save. Of course that would require adding the connection as a parameter, which would be a breaking change too. As a side tangent, while I like a lot of the decisions in Rust, the biggest thing I miss compared to the languages I use in my day job (primarily Kotlin with smatterings of Java, C++, and C#) is method overloading. I slightly-grudgingly understand the reasoning for not supporting type-based overloading, but I do wish we could at least have overloading on arity.

jayvdb commented 8 months ago

fyi, now .saved is gone, I will re-work this PR to create a separate method to recursively/deeply save.

jayvdb commented 2 months ago

This wont be possible due to Many.add now checking that the added item is already saved.