Electron100 / butane

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

Stable ordering for Many.load #122

Closed jayvdb closed 1 year ago

jayvdb commented 1 year ago

The Iterator returned by Many.load doesn't have any default sorting.

It would make sense to use the primary key as the default sorting for the database query, however there is also the aspect that .load also includes .new_values, which would need to be manually sorted into the db values.

Also I suspect there is a problem with .load() that it doesnt check/flush .removed_values before reading from the database.

jayvdb commented 1 year ago

Or perhaps we should have a Many.query() -> Query that creates a Query object pre-filtered to the Many's objects, so then sorting can be specified before the query is executed.

Electron100 commented 1 year ago

I like that second idea. I don't see any reason that the output of Many.load needs to always be sorted, but I agree that the ability to sort it would be valuable.