Replies: 1 comment 4 replies
-
The first thing to make this proposal actionable is to check how that macro works and what does not work. After that this can be a starting point for a discussion about how the API could look like and how the corresponding implementation should be designed. (As the original author of this macro I can tell you that is basically a hack for using this macro in a certain context. That means that macro makes different choices that it would be sensible for something that is included in diesel itself. For example a similar macro in diesel should not implement
Diesel has a clearly defined public API + is following semantic version. We've put a lot of work in the past in not doing major version bumps with any release. Additionally the upcoming 2.0 release is expected to have only minor impact on crates actually using diesel. This means everything implemented in a third party crate is fine as long as it only uses the public API. In fact a third party crate is probably better maintainable because of this, then having the implementation in diesel itself.
At least for me this is a quite large downside. I'm currently more or less the only maintainer of diesel and I do only work sometimes in my free time on this project. Given this situation adding a large new API to diesel is something that I see critical, as long as it is possible to implement basically the same in a third party crate. I totally understand that you are not willing to use a unmaintained macro in your project, but adding the same macro to diesel itself, only shifts the maintenance burden to me and I'm more than busy with maintaining what's diesel today without further additions. This does not mean that I'm totally opposed in including something like that in diesel itself, but I would expect that someone that wants to have this in diesel spends the necessary work on designing , implementing, documenting + testing the corresponding API in such a way that it is in line with all the other parts in diesel. |
Beta Was this translation helpful? Give feedback.
-
As per recommendation in #815 I'm suggesting adding a separate macro for
SELECT ... FROM function
.I suggest that the macro
from_sql_function!
is moved almost as is (depending on what works and what doesn't) to the diesel package. One good change before it's moved (in my opinion) is to make it match the currentsql_function!
syntax.Suggested syntax would be:
Just to make sure it gets into the package I would suggest skipping the function meta for now and just add
fn
before the function name and otherwise use it as is, since that syntactically allows the addition of meta tags later. Apparently the existing from_sql_function is not general enough to be production worthy. I'm afraid I can't speak for what's there, what's missing and what's too specific, so I guess that would be part of this discussion.My use case would be a query such as
SELECT [...] FROM my_function(parameter) INNER JOIN [...] INNER JOIN [...]
.I'm not able to use big copy-pasted (and therefore unmaintained) macros in the project I work on, so having it shipped with the official diesel package would be an absolute game changer for me. Apart from my purely egoistic reasons, I think this ability is critical to database performance since the alternatives right now (as far as I can tell) are to lose type safety or to run multiple queries. I think it should be part of diesel because
sql_function!
is included and this is a very similar macro with a use case that does not overlap. I also think it should be included in the main package since Diesel is a complex system with many macros and types, and having it as part of the main package release test process makes it less likely to break.There are no downsides to adding this, as far as I can tell, besides the fact that this is now part of Diesel and may have to be maintained if the underlying type system is changed in the future.
Any thoughts on this suggestion?
Beta Was this translation helpful? Give feedback.
All reactions