Skip to content

Commit 9baa6db

Browse files
committed
Merge pull request #4351 from weiznich/fix/missing_type_def_for_count
Add a missing type def
1 parent 27bd72f commit 9baa6db

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

diesel/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ pub mod helper_types {
357357
use super::query_dsl::methods::*;
358358
use super::query_dsl::*;
359359
use super::query_source::{aliasing, joins};
360+
use crate::dsl::CountStar;
360361
use crate::query_builder::select_clause::SelectClause;
361362

362363
#[doc(inline)]
@@ -682,6 +683,9 @@ pub mod helper_types {
682683
/// [`DeleteStatement::returning`](crate::query_builder::DeleteStatement::returning)
683684
pub type Returning<Q, S> =
684685
<Q as crate::query_builder::returning_clause::ReturningClauseHelper<S>>::WithReturning;
686+
687+
#[doc(hidden)] // used for `QueryDsl::count`
688+
pub type Count<Q> = Select<Q, CountStar>;
685689
}
686690

687691
pub mod prelude {

diesel_derives/tests/auto_type.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,11 @@ fn delete_returning() -> _ {
385385
delete(users::table).returning(users::id)
386386
}
387387

388+
#[auto_type]
389+
fn count_query() -> _ {
390+
users::table.count()
391+
}
392+
388393
// #[auto_type]
389394
// fn test_sql_fragment() -> _ {
390395
// sql("foo")

0 commit comments

Comments
 (0)