Skip to content
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

Allow custom backends to overwrite QueryFragment impls for SelectStatement and BoxedSelectStatement #3257

Conversation

weiznich
Copy link
Member

This commit introduces the necessary associated type to SqlDialect so
that custom backends can provide custom QueryFragment implementations
for SelectStatement and BoxedSelectStatement. This is required as
some database systems require a different order of clauses there. (The
firebird backend is using a custom fork for this currently).
All existing backends in diesel will just use the existing
implementations.
In addition this commit extends the __diesel_public_if macro to
conditionally make struct fields public as well. As it's not possible to
apply proc-macro attributes directly to struct fields, this is solved by
having an explicit list of "public" fields in the macro call on the
struct itself. Such structs are also marked as #[non_exhaustive] so
that we can add additional fields later on.

See fernandobatels/rsfbclient#127 for a possible use case

@weiznich weiznich requested a review from a team July 29, 2022 13:28
@weiznich weiznich force-pushed the make_selectstatement_query_fragment_impl_customizable branch from 76da616 to b577db0 Compare July 29, 2022 13:42
…tatement` and `BoxedSelectStatement`

This commit introduces the necessary associated type to `SqlDialect` so
that custom backends can provide custom `QueryFragment` implementations
for `SelectStatement` and `BoxedSelectStatement`. This is required as
some database systems require a different order of clauses there. (The
`firebird` backend is using a custom fork for this currently).
All existing backends in diesel will just use the existing
implementations.
In addition this commit extends the `__diesel_public_if` macro to
conditionally make struct fields public as well. As it's not possible to
apply proc-macro attributes directly to struct fields, this is solved by
having an explicit list of "public" fields in the macro call on the
struct itself. Such structs are also marked as `#[non_exhaustive]` so
that we can add additional fields later on.
@weiznich weiznich force-pushed the make_selectstatement_query_fragment_impl_customizable branch from b577db0 to d756d63 Compare July 30, 2022 08:51
@weiznich weiznich requested review from a team and removed request for a team August 15, 2022 15:13
@weiznich
Copy link
Member Author

Nightly builds fail due to rust-lang/rust#100620

@weiznich weiznich merged commit fb6e095 into diesel-rs:master Aug 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant