SqlExpressionVisitor

Base interface designed to visit or modify SQL expression trees using visitor pattern.

This interface provides a general visit function to dispatch different type of expression nodes to their specific visit* functions. Custom expression types that are unknown to Ktorm will be dispatched to visitUnknown.

For each expression type, there is a corresponding visit* function in this interface; for SelectExpression, it's visitSelect; for TableExpression, it's visitTable; and so on. Those functions generally accept an expression instance of the specific type and dispatch the children nodes to their own visit* functions. Finally, after all children nodes are visited, the parent expression instance will be directly returned if no children are modified.

As SQL expressions are immutable, to modify an expression, we need to override a child visit* function, and return a new-created expression in it. Then its parent's visit* function will notice the change and create a new parent expression using the modified child node returned by us. As the process is recursive, the ancestor nodes also returns new-created instances. Finally, as a result of calling visit, a new expression tree will be returned with our modifications applied.

SqlFormatter is a typical example used to format expressions as executable SQL strings.

Inheritors

Functions

Link copied to clipboard

Dispatch different type of expression nodes to their specific visit* functions. Custom expression types that are unknown to Ktorm will be dispatched to visitUnknown.

Link copied to clipboard

Function that visits an AggregateExpression.

Link copied to clipboard

Function that visits an ArgumentExpression.

Link copied to clipboard

Function that visits a BetweenExpression.

Link copied to clipboard

Function that visits a BinaryExpression.

Link copied to clipboard

Function that visits a CaseWhenExpression.

Link copied to clipboard

Function that visits a CastingExpression.

Link copied to clipboard

Function that visits a ColumnExpression.

Link copied to clipboard
Link copied to clipboard

Function that visits a DeleteExpression.

Link copied to clipboard

Function that visits an ExistsExpression.

Link copied to clipboard
open fun <T : SqlExpression> visitExpressionList(original: List<T>, subVisitor: (T) -> T = { visit(it) as T }): List<T>

Helper function for visiting a list of expressions.

Link copied to clipboard

Function that visits a FunctionExpression.

Link copied to clipboard

Function that visits an InListExpression.

Link copied to clipboard

Function that visits an InsertExpression.

Link copied to clipboard

Function that visits a JoinExpression.

Link copied to clipboard

Function that visits an OrderByExpression.

Link copied to clipboard

Function that visits a QueryExpression.

Link copied to clipboard
Link copied to clipboard

Function that visits a general ScalarExpression, this function dispatches different type of scalar expressions to their specific visit* functions. Custom expression types that are unknown to Ktorm will be dispatched to visitUnknown

Link copied to clipboard

Function that visits a SelectExpression.

Link copied to clipboard

Function that visits a TableExpression.

Link copied to clipboard

Function that visits an UnaryExpression.

Link copied to clipboard

Function that visits an UnionExpression.

Link copied to clipboard

Function that visits an unknown expression.

Link copied to clipboard

Function that visits an UpdateExpression.

Link copied to clipboard

Helper function for visiting when clauses of CaseWhenExpression.

Link copied to clipboard