Sign in

    jaredzhou/foxql/ast does not have a README file

    ToValue

    pub trait ToValue {
    fn to_value(Self) -> Value
    }

    Convert a MoonBit native type into a parameterised Value.
    impl ToValue for Bool
    impl ToValue for Int
    impl ToValue for Double
    impl ToValue for String

    Aggregation

    pub(all) enum Aggregation {
    Count(ColumnRef?)
    Sum(ColumnRef)
    Avg(ColumnRef)
    Min(ColumnRef)
    Max(ColumnRef)
    } derive(Eq,
    Debug
    )

    An aggregation function call.

    Aggregation::eq

    fn[T : ToValue] Aggregation::eq(self : Aggregation, value : T) -> Expr

    Aggregation::gt

    fn[T : ToValue] Aggregation::gt(self : Aggregation, value : T) -> Expr

    Aggregation::gte

    fn[T : ToValue] Aggregation::gte(self : Aggregation, value : T) -> Expr

    Aggregation::lt

    fn[T : ToValue] Aggregation::lt(self : Aggregation, value : T) -> Expr

    Aggregation::lte

    fn[T : ToValue] Aggregation::lte(self : Aggregation, value : T) -> Expr

    Aggregation::neq

    fn[T : ToValue] Aggregation::neq(self : Aggregation, value : T) -> Expr

    ColumnRef

    pub(all) struct ColumnRef {
    name : String
    table : String
    } derive(Eq,
    Debug
    )

    Identifies a column by (table, name).

    ColumnRef::eq

    fn ColumnRef::eq(self : ColumnRef, value : &ToValue) -> Expr

    Compare with a value (for dynamic ColumnRefs).

    ColumnRef::gt

    fn ColumnRef::gt(self : ColumnRef, value : &ToValue) -> Expr

    ColumnRef::gte

    fn ColumnRef::gte(self : ColumnRef, value : &ToValue) -> Expr

    ColumnRef::lt

    fn ColumnRef::lt(self : ColumnRef, value : &ToValue) -> Expr

    ColumnRef::lte

    fn ColumnRef::lte(self : ColumnRef, value : &ToValue) -> Expr

    ColumnRef::neq

    fn ColumnRef::neq(self : ColumnRef, value : &ToValue) -> Expr

    DeleteStmt

    pub(all) struct DeleteStmt {
    table : String
    where_clause : Expr
    returning : Array[ColumnRef]?
    } derive(Eq,
    Debug
    )

    A DELETE statement. where_clause is non-optional.

    Expr

    pub(all) enum Expr {
    Compare(ColumnRef, Operator, Value)
    CompareCols(ColumnRef, Operator, ColumnRef)
    And(Array[Expr])
    Or(Array[Expr])
    Not(Expr)
    InList(ColumnRef, Array[Value])
    InSelect(ColumnRef, SelectStmt)
    Between(ColumnRef, Value, Value)
    IsNull(ColumnRef)
    IsNotNull(ColumnRef)
    AggCompare(Aggregation, Operator, Value)
    CompareSelect(ColumnRef, Operator, SelectStmt)
    } derive(Eq,
    Debug
    )

    A WHERE clause expression — a tree of comparisons joined by AND / OR / NOT.

    Expr::and_

    fn Expr::and_(self : Expr, other : Expr) -> Expr

    Combine two expressions with AND. Flattens nested And for cleaner SQL.

    Expr::or_

    fn Expr::or_(self : Expr, other : Expr) -> Expr

    Combine two expressions with OR. Flattens nested Or for cleaner SQL.

    InsertStmt

    pub(all) struct InsertStmt {
    table : String
    columns : Array[ColumnRef]
    values : Array[Array[Value]]
    on_conflict : OnConflict?
    returning : Array[ColumnRef]?
    } derive(Eq,
    Debug
    )

    An INSERT statement (placeholder — wired in a later ticket).

    JoinClause

    pub(all) struct JoinClause {
    table : String
    on : Expr
    } derive(Eq,
    Debug
    )

    An INNER JOIN clause.

    OnConflict

    pub(all) enum OnConflict {
    DoNothing(String)
    DoUpdate(String, Array[SetClause])
    } derive(Eq,
    Debug
    )

    Operator

    pub(all) enum Operator {
    Eq
    Neq
    Gt
    Gte
    Lt
    Lte
    Like
    NotLike
    In
    Between
    IsNull
    IsNotNull
    } derive(Eq,
    Debug
    )

    Operator::to_sql_op

    fn Operator::to_sql_op(self : Operator) -> String

    Render the operator as its SQL keyword / symbol.

    OrderByClause

    pub(all) struct OrderByClause {
    column : ColumnRef
    direction : OrderDirection
    } derive(Eq,
    Debug
    )

    OrderDirection

    pub(all) enum OrderDirection {
    Asc
    Desc
    } derive(Eq,
    Debug
    )

    ORDER BY direction.

    SelectExpr

    pub(all) enum SelectExpr {
    Col(ColumnRef)
    Agg(Aggregation)
    } derive(Eq,
    Debug
    )

    An item in the SELECT list — either a column reference or an aggregate call.

    SelectStmt

    pub(all) struct SelectStmt {
    table : String
    columns : Array[SelectExpr]
    where_clause : Expr?
    joins : Array[JoinClause]
    group_by : Array[ColumnRef]
    having : Expr?
    order_by : Array[OrderByClause]
    limit : Int?
    offset : Int?
    distinct : Bool
    distinct_on : Array[ColumnRef]
    } derive(Eq,
    Debug
    )

    A SELECT statement.

    SetClause

    pub(all) struct SetClause {
    column : ColumnRef
    value : Value
    } derive(Eq,
    Debug
    )

    SqlType

    pub(all) enum SqlType {
    Integer
    BigInt
    Text
    Boolean
    DoublePrecision
    Bytea
    TimestampTz
    Numeric
    Jsonb
    } derive(Eq,
    Debug
    )

    PostgreSQL column types.

    UpdateStmt

    pub(all) struct UpdateStmt {
    table : String
    set_clauses : Array[SetClause]
    where_clause : Expr
    returning : Array[ColumnRef]?
    } derive(Eq,
    Debug
    )

    An UPDATE statement. where_clause is non-optional.

    Value

    pub(all) enum Value {
    Null
    Bool(Bool)
    Int(Int)
    Float(Double)
    String(String)
    } derive(Eq,
    Debug
    )

    A runtime parameterised value — each variant maps to a PG type.
    impl ToValue for Value

    not_

    fn not_(expr : Expr) -> Expr

    Wrap an expression with NOT.