use super::Expression;
use backend::Backend;
use query_builder::*;
use result::QueryResult;
use sql_types::BigInt;
sql_function! {
#[aggregate]
fn count<T>(expr: T) -> BigInt;
}
pub fn count_star() -> CountStar {
CountStar
}
#[derive(Debug, Clone, Copy, QueryId, DieselNumericOps)]
#[doc(hidden)]
pub struct CountStar;
impl Expression for CountStar {
type SqlType = BigInt;
}
impl<DB: Backend> QueryFragment<DB> for CountStar {
fn walk_ast(&self, mut out: AstPass<DB>) -> QueryResult<()> {
out.push_sql("COUNT(*)");
Ok(())
}
}
impl_selectable_expression!(CountStar);