diesel/query_dsl/
single_value_dsl.rs1use super::methods::LimitDsl;
2use crate::dsl::Limit;
3use crate::expression::grouped::Grouped;
4use crate::expression::subselect::Subselect;
5use crate::query_builder::SelectQuery;
6use crate::sql_types::IntoNullable;
7
8pub trait SingleValueDsl {
16 type Output;
18
19 fn single_value(self) -> Self::Output;
21}
22
23impl<T> SingleValueDsl for T
24where
25 Self: SelectQuery + LimitDsl,
26 <Self as SelectQuery>::SqlType: IntoNullable,
27{
28 type Output =
29 Grouped<Subselect<Limit<Self>, <<Self as SelectQuery>::SqlType as IntoNullable>::Nullable>>;
30
31 fn single_value(self) -> Self::Output {
32 Grouped(Subselect::new(self.limit(1)))
33 }
34}