-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
dsl::max
doesn't work with dsl::auto_type
#3745
Comments
@weiznich this might be an issue with the "type alias at the same path as function" approach (might require breaking change) so I think it's a blocker for the release. |
I think we can handle this without breaking change. We can just have a ”private" type dsl module in pub use diesel::dsl::*;
// overwrite the type provided by diesel::dsl wit the correct one
pub use diesel::expressions::helper_types::max;
|
if it did then custom functions couldn't be referred directly anymore. That's notably why it uses "always same path as function" by default (otherwise I guess it could just use diesel::helper_types). That would be a breaking change for this reason. I suspect |
So re-defining the dsl module in the exact same way as within Diesel in the local crate works. (I did not expect name resolving would work differently on external modules than on local modules...) Alternately, explicitly specifying diesel/diesel_tests/tests/select_by.rs Lines 161 to 162 in c99ebda
(which did need the second line to compile for the same reason) As far as I can tell that makes the best solution to keep both local type aliases generated by
|
Wait |
Ok so the issue comes from the fact that Re-defining in the local crate works because the module generated by |
The best compromise is probably to release a new diesel/diesel_derives/src/lib.rs Lines 1029 to 1054 in c99ebda
Any opinion with regards to choice between:
? EDIT: Ah but that also breaks diesel/diesel_tests/tests/select_by.rs Lines 161 to 162 in c99ebda
Well alternately that leaves us with the "duplicate everything to |
@weiznich I'd like an opinion on whether this particular breaking change could be considered a bug fix, vs the loss of ergonomics and duplicated types of pascal-casing |
To explore that option a bit more: We only talk about these 6 functions here, right? (If that includes diesel/diesel/src/expression/functions/helper_types.rs Lines 8 to 23 in 409585e
If that only affects that number of function I think it might be the easiest solution to:
|
The issue is that we want the types to all be in the same case so that
Although that is the official convention proposed by this doc, it's not the current convention within Diesel itself (and the user is invited to do it themselves for the particular case of |
I did not find the time today to look into this issue, hopefully I have capacity for that next week. I've started to play a bit around, but I did not come to a conclusion yet. As part of the playing around I've discovered that |
Cool, thanks. As far as I'm concerned I'd favor the compromise of considering the solution at #3745 (comment) as a bugfix of the types not being available in the |
I've continued to put together a list of all expressions that might occur. It still misses some items like free standing functions (which are the original problem reported by this issue.) See here for the result. Every commented out expression seems to be not supported right now. I think we want to classify each of the items and see what's the problem for each one and how we might solve it. Help for this classification would be greatly appreciated. |
that should be almost always backwards compatible because the module was only pub(crate) anyway. It is not strictly backwards compatible because diesel-rs#3745 (comment)
I've implemented the fix for Using that (and #3774) it seems that all the commented code still doesn't compile, so the issue is just missing type aliases for the corresponding expression methods (e.g. (All these examples seem to be expression methods though, not expression functions, which is why they don't seem to encounter the issue with functions described earlier) The only two particular cases that I see are:
because there seems to already be type aliases called resp. That being said I think if these require manual annotations for now: #[auto_type]
fn qf() -> _ {
let x: dsl::ConcatBinary<_, _> = a.concat(b);
some_expression_that_uses(x)
} that's probably fine given how uncommon they are. |
I've filled #3783 to address most of the broken cases in a hopefully not-breacking manner. This is an alternative approach to #3773 which does not require to update all code that already uses |
Setup
Versions
Feature Flags
Problem Description
FYI @Ten0 knows and says it's a blocker for the release of
auto_type
so he'll try to fix.When deriving on a struct
Selectable
with one field having aselect_expression
containingdsl::max
compilation breaks with error:What are you trying to accomplish?
Use
Selectable
deriveWhat is the expected output?
Code compiles
What is the actual output?
Compilation fails
Are you seeing any additional errors?
No
Steps to reproduce
Checklist
closed if this is not the case)
The text was updated successfully, but these errors were encountered: