Fix support of sql functions with #[auto_type]#3773
Fix support of sql functions with #[auto_type]#3773Ten0 wants to merge 7 commits intodiesel-rs:masterfrom
#[auto_type]#3773Conversation
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)
…ype_max Conflicts: diesel_compile_tests/tests/fail/right_side_of_left_join_requires_nullable.stderr
so that users have the flexibility of exporting the helper type without exporting the function if they want
|
I had finally some time to look at this again and try some other things I had in mind. One of the ideas was to basically migrate all of the breaking changes by just using associated types/functions on the type def instead of having a module. Unfortunately that does not work as for the associated types we run into rust-lang/rust#8995. Although it should work for the That written: I agree with you that changing the generated is fundamentally the right approach and it seems like we cannot avoid the breaking change. Therefore I would propose the following way forward:
|
Love that name! 😃
Not sure what struct you're thinking of - they are mostly all generic, but that function shouldn't be, no? |
I'm thinking about the struct generated by the macro. As the functions don't care about the generic parameter we can just use a fixed type in place of it. So essentially we would have a |
Somewhat raw thoughts: I'm not sure that works through the type alias that remaps the type arguments through an AsExpression... Not completely sure though. |
|
You are right, that sadly also doesn't work: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d1a03dc070d8e6595c52b6255f4911b5 The other alternative that might work to hide the although that likely requires again that the user specify a type for the generic argument there :( So that is also not great … |
|
TBH I think I am reasonably happy with the extra module. It's not particularly elegant but I feel like it's probably the most programmatically appropriate representation, and we don't necessarily need to make it more private than it used to be - but I have no strong conviction on this. |
|
My reasoning for not wanting to expose that module (again) is that it would prevent breaking anything again due to that module. But given that I do not see a good way to make this happen it's likely the best to expose that module anyway. Maybe we can change the name to With these two names changed (module + macro) I'm fine with this change. I will update my other PR to pull in these changes so that we get all the fixes in the end. |
I'm not super fond of that name either but |
|
|
|
closing in favor of #3783 |
Fixes #3745
The proposed implementation is not strictly backwards-compatible in that it breaks code like this:
diesel/diesel_tests/tests/select_by.rs
Lines 161 to 162 in c99ebda
where with
dsl::maxnow importing the type alias as well anddiesel::helper_types::maxalso importing that type alias, rust would say there is a conflict between the two.(Note that this resolves an inconsistency though: in the current version of Diesel some type aliases are directly provided by dsl, and for some you have to go through HelperTypes.)