toasty_core/stmt/
expr_func.rs

1use super::{Expr, FuncCount, FuncLastInsertId};
2
3/// A function call expression.
4///
5/// Represents aggregate or scalar functions applied to expressions.
6///
7/// # Examples
8///
9/// ```text
10/// count(*)           // counts all rows
11/// count(field)       // counts non-null values
12/// last_insert_id()   // MySQL: get the last auto-increment ID
13/// ```
14#[derive(Clone, Debug, PartialEq)]
15pub enum ExprFunc {
16    /// The `count` aggregate function.
17    Count(FuncCount),
18
19    /// The `LAST_INSERT_ID()` function (MySQL-specific).
20    ///
21    /// Returns the first auto-increment ID that was generated for an INSERT statement.
22    /// When multiple rows are inserted, this returns the ID of the first row.
23    LastInsertId(FuncLastInsertId),
24}
25
26impl From<ExprFunc> for Expr {
27    fn from(value: ExprFunc) -> Self {
28        Self::Func(value)
29    }
30}