LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.31k stars 883 forks source link

Upgrade to diesel 2.0.0 #2234

Closed dessalines closed 2 years ago

dessalines commented 2 years ago

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

chusteven commented 2 years ago

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 :)

Nutomic commented 2 years ago

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.

dessalines commented 2 years ago

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 commented 2 years ago

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

PorkrollPosadist commented 2 years ago

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?

dessalines commented 2 years ago

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.