-
-
Notifications
You must be signed in to change notification settings - Fork 883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use same table join code for both read and list functions #3663
Conversation
Nice, this will be great to have. |
This reverts commit 69afed0.
PostId, | ||
Option<PersonId>, | ||
Option<bool>, | ||
)| async move { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rustfmt issue: rust-lang/style-team#138
crates/db_schema/src/aliases.rs
Outdated
@@ -0,0 +1,3 @@ | |||
use crate::schema::person; | |||
|
|||
diesel::alias!(person as person1: Person1, person as person2: Person2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a separate file, you should be able to put the cfg attribute directly on the macro. Or otherwise put a mod {}
declaration in lib.rs
This is now ready to merge if I didn't mess up anything |
The build time of lemmy_db_views when re-running the first cargo command in fix-clippy changed from 208.4s to 65.6s |
Fails to compile:
|
} | ||
|
||
// `()` is used to prevent type inference error | ||
impl Queries<(), ()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really do wish there was a better way to handle this, but oh well. Seems like such a common case, but because our type is so complicated, its near impossible to reverse.
We'll still merge, but if you get some time, ask @weiznich on matrix or here if there really is no better alternative for what we need.
It now compiles |
Thanks! |
This will fix #2763 and might reduce compile time (#3610).
It works by doing the table joins in a closure so that the return type can be inferred. The closure is inside of a function that returns 2 closures for read and list, which both capture and call the closure that has the join logic.