grafbase_sql_ast/ast/function/
concat.rs

1use super::Function;
2use crate::ast::{Expression, FunctionType};
3
4/// A representation of the `Concat` function in the database.
5#[derive(Debug, Clone, PartialEq)]
6pub struct Concat<'a> {
7    pub(crate) exprs: Vec<Expression<'a>>,
8}
9
10/// Concat several expressions.
11pub fn concat<'a, T>(exprs: Vec<T>) -> Function<'a>
12where
13    T: Into<Expression<'a>>,
14{
15    let fun = Concat {
16        exprs: exprs.into_iter().map(Into::into).collect(),
17    };
18
19    fun.into()
20}
21
22impl<'a> From<Concat<'a>> for Function<'a> {
23    fn from(value: Concat<'a>) -> Self {
24        Self {
25            typ_: FunctionType::Concat(value),
26            alias: None,
27        }
28    }
29}