---
source: diesel_derives/src/tests/mod.rs
expression: out
info:
input: "sql_function! {\n fn lower(input : Text) -> Text;\n}\n"
---
#[allow(non_camel_case_types)]
pub fn lower<input>(input: input) -> lower::HelperType<input>
where
input: diesel::expression::AsExpression<Text>,
{
lower::lower {
input: input.as_expression(),
}
}
#[doc(hidden)]
#[allow(non_camel_case_types, non_snake_case, unused_imports)]
pub(crate) mod lower {
use diesel::{self, QueryResult};
use diesel::expression::{
AsExpression, Expression, SelectableExpression, AppearsOnTable, ValidGrouping,
};
use diesel::query_builder::{QueryFragment, AstPass};
use diesel::sql_types::*;
use diesel::internal::sql_functions::*;
use super::*;
#[derive(Debug, Clone, Copy, diesel::query_builder::QueryId)]
#[derive(diesel::sql_types::DieselNumericOps)]
pub struct lower<input> {
pub(super) input: input,
}
///The return type of [`lower()`](fn@lower)
pub type HelperType<input> = lower<<input as AsExpression<Text>>::Expression>;
impl<input> Expression for lower<input>
where
(input): Expression,
{
type SqlType = Text;
}
impl<input, __DieselInternal> SelectableExpression<__DieselInternal> for lower<input>
where
input: SelectableExpression<__DieselInternal>,
Self: AppearsOnTable<__DieselInternal>,
{}
impl<input, __DieselInternal> AppearsOnTable<__DieselInternal> for lower<input>
where
input: AppearsOnTable<__DieselInternal>,
Self: Expression,
{}
impl<input, __DieselInternal> FunctionFragment<__DieselInternal> for lower<input>
where
__DieselInternal: diesel::backend::Backend,
input: QueryFragment<__DieselInternal>,
{
const FUNCTION_NAME: &'static str = "lower";
#[allow(unused_assignments)]
fn walk_arguments<'__b>(
&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>,
) -> QueryResult<()> {
let mut needs_comma = false;
if !self.input.is_noop(out.backend())? {
if needs_comma {
out.push_sql(", ");
}
self.input.walk_ast(out.reborrow())?;
needs_comma = true;
}
Ok(())
}
}
impl<input, __DieselInternal> QueryFragment<__DieselInternal> for lower<input>
where
__DieselInternal: diesel::backend::Backend,
input: QueryFragment<__DieselInternal>,
{
fn walk_ast<'__b>(
&'__b self,
mut out: AstPass<'_, '__b, __DieselInternal>,
) -> QueryResult<()> {
out.push_sql(<Self as FunctionFragment<__DieselInternal>>::FUNCTION_NAME);
out.push_sql("(");
self.walk_arguments(out.reborrow())?;
out.push_sql(")");
Ok(())
}
}
#[derive(ValidGrouping)]
pub struct __Derived<input>(input);
impl<input, __DieselInternal> ValidGrouping<__DieselInternal> for lower<input>
where
__Derived<input>: ValidGrouping<__DieselInternal>,
{
type IsAggregate = <__Derived<
input,
> as ValidGrouping<__DieselInternal>>::IsAggregate;
}
}