1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use super::Function;
use crate::ast::{Expression, FunctionType};

/// A representation of the `Concat` function in the database.
#[derive(Debug, Clone, PartialEq)]
pub struct Concat<'a> {
    pub(crate) exprs: Vec<Expression<'a>>,
}

/// Concat several expressions.
pub fn concat<'a, T>(exprs: Vec<T>) -> Function<'a>
where
    T: Into<Expression<'a>>,
{
    let fun = Concat {
        exprs: exprs.into_iter().map(Into::into).collect(),
    };

    fun.into()
}

impl<'a> From<Concat<'a>> for Function<'a> {
    fn from(value: Concat<'a>) -> Self {
        Self {
            typ_: FunctionType::Concat(value),
            alias: None,
        }
    }
}