lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Upgrade to diesel 2.0.0

Open dessalines opened this issue 2 years ago • 6 comments

This adds table aliasing, which is something we've had to do workarounds for.

https://github.com/diesel-rs/diesel/releases/tag/v2.0.0-rc0

dessalines avatar Apr 22 '22 20:04 dessalines

Hello! I was originally hoping to tackle some of this but all I've gotten to so far is just bumping the version numbers in all the various Cargo.toml files; but not it doesn't compile past the db_schema sub-crate (is that what you call it?) with this output 😅 https://gist.github.com/chusteven/62baff5a33d95cbf2226961fdb8b496e

Wondering if this issue can perhaps be broken out into smaller tasks? Of course I don't want to add overhead just for issue tracking -- but I have been more interested in diesel itself and thought this would be a fun way to explore the internals more :)

chusteven avatar May 10 '22 20:05 chusteven

You would have to go through those errors and fix them manually one by one. Or figure out a way to automate it. Not a very fun job. Best open a pull request with your changes, then we can view/comment/fork.

Btw, those are normal crates which are part of a workspace.

Nutomic avatar May 10 '22 21:05 Nutomic

Oh damn that is a lot, I see some of them are duped tho. Looks like diesel newtypes also needs to be updated for diesel 2.0.

dessalines avatar May 11 '22 15:05 dessalines

Diesel 2.0.0 has been released, so I'll try to work on this soon.

dessalines avatar Aug 29 '22 18:08 dessalines

It's my rough understanding that PostgreSQL views are used extensively throughout Lemmy as a workaround for the table aliasing limitation in Diesel which has finally been resolved in 2.0. I was wondering, regarding the scope of this issue, or the trajectory of the project more generally, if the plan is to try to roll back the usage of many of these views, particularly in cases where they appear to be near/exact replicas of their corresponding tables?

PorkrollPosadist avatar Sep 11 '22 19:09 PorkrollPosadist

We haven't used postgres views for a long time, we long ago migrated them to diesel views / joins. The one exception is the alias views for person and comment (IE create view person_alias_1 as select * from person;), because diesel 1.0 didn't allow self-joins or joining to the same table twice.

With diesel 2.0, we should be able to delete these alias views.

dessalines avatar Sep 13 '22 20:09 dessalines