Skip to content

Use #[diesel::dsl::auto_type] in some places #8970

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

Merged
merged 1 commit into from
Jul 3, 2024

Conversation

weiznich
Copy link
Contributor

@weiznich weiznich commented Jul 1, 2024

This commit replaces some of the manual written type aliases by #[diesel::dsl::auto_type] which just generates the correct return type based on the function content. This hopefully removes some complexity from the database code.

The main motivation for this change is to update the diesel Composing Applications guide which is based on this code.

I'm not 100% happy with this as it's currently not possible to use #[auto_type] for all the the type defs due to the following reasons:

  • #[auto_type] by default generates a type def alongside the function that names the return type. This cannot easily be done here as associated types for non-trait impls are not stable yet. (That's the reason for the no_type_alias option)
  • This in turn requires that we specify the type in a few places so that the macro can pick up the correct type later

This commit replaces some of the manual written type aliases by
`#[diesel::dsl::auto_type]` which just generates the correct return type
based on the function content. This hopefully removes some complexity
from the database code.
Copy link

codecov bot commented Jul 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.99%. Comparing base (2a321ff) to head (dd6eb3a).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8970      +/-   ##
==========================================
- Coverage   89.00%   88.99%   -0.02%     
==========================================
  Files         277      277              
  Lines       27841    27845       +4     
==========================================
- Hits        24781    24780       -1     
- Misses       3060     3065       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Turbo87 Turbo87 added A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear labels Jul 3, 2024
@Turbo87 Turbo87 merged commit 2b544c1 into rust-lang:main Jul 3, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-backend ⚙️ C-internal 🔧 Category: Nonessential work that would make the codebase more consistent or clear
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants