Skip to content

Commit

Permalink
Add a missing type def
Browse files Browse the repository at this point in the history
This commit adds a missing type-def that allows now to use
`table.count()` with `#[auto_type]`
  • Loading branch information
weiznich committed Nov 19, 2024
1 parent 5a2940e commit 665e9b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions diesel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ pub mod helper_types {
use super::query_dsl::methods::*;
use super::query_dsl::*;
use super::query_source::{aliasing, joins};
use crate::dsl::CountStar;
use crate::query_builder::select_clause::SelectClause;

#[doc(inline)]
Expand Down Expand Up @@ -699,6 +700,9 @@ pub mod helper_types {
/// [`DeleteStatement::returning`](crate::query_builder::DeleteStatement::returning)
pub type Returning<Q, S> =
<Q as crate::query_builder::returning_clause::ReturningClauseHelper<S>>::WithReturning;

#[doc(hidden)] // used for `QueryDsl::count`
pub type Count<Q> = Select<Q, CountStar>;
}

pub mod prelude {
Expand Down
5 changes: 5 additions & 0 deletions diesel_derives/tests/auto_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,11 @@ fn update_and_binary_operator_and_block() -> _ {
}))
}

#[auto_type]
fn count_query() -> _ {
users::table.count()
}

// #[auto_type]
// fn test_sql_fragment() -> _ {
// sql("foo")
Expand Down

0 comments on commit 665e9b8

Please sign in to comment.