README

jaredzhou/foxql/ast does not have a README file

#
Aggregation

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

#
ColumnRef

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

Identifies a column by (table, name).

#
ColumnRef::eq

Compare with a value (for dynamic ColumnRefs).

#
ColumnRef::gt

#
ColumnRef::gte

#
ColumnRef::lt

#
ColumnRef::lte

#
ColumnRef::neq

#
DeleteStmt

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

A DELETE statement. where_clause is non-optional.

#
Expr

A WHERE clause expression — a tree of comparisons joined by AND / OR / NOT. Values are stored as &@moonpg.ToValue trait objects, allowing any moonpg-compatible type to be bound as a parameter without going through a foxql Value enum.

#
Expr::and_

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

Combine two expressions with AND. Flattens nested And for cleaner SQL. Empty is the identity: Empty.and_(x)x, x.and_(Empty)x.

#
Expr::or_

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

Combine two expressions with OR. Flattens nested Or for cleaner SQL. Empty is the identity: Empty.or_(x)x, x.or_(Empty)x.

#
InsertStmt

pub(all) struct InsertStmt {
table : String
columns : Array[ColumnRef]
values : Array[Array[&
ToValue
]]
on_conflict : OnConflict?
returning : Array[ColumnRef]?
}

An INSERT statement.

#
JoinClause

pub(all) struct JoinClause {
table : String
on : Expr
}

An INNER JOIN clause.

#
OnConflict

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

#
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]
}

A SELECT statement.

#
SetClause

pub(all) struct SetClause {
column : ColumnRef
value : &
ToValue

}

#
UpdateStmt

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

An UPDATE statement. where_clause is non-optional.

#
empty

fn empty() -> Expr

The empty filter — identity element for AND/OR. Use as a starting point when building filters from many optional conditions.

#
not_

fn not_(expr : Expr) -> Expr

Wrap an expression with NOT. not_(Empty)Empty.