ConditionalExpression

A composable, parameterized boolean expression used by WHERE / HAVING / ON clauses.

Internally it is a thin wrapper around an immutable SqlNode tree (see com.zxhhyj.storm.sql). The infix operators (eq, and, or, not, gt, like, in, …) build new trees; the actual SQL text and bound arguments are produced on demand by buildFragment (which runs the tree through the Normalizer first, then the Renderer).

Why a tree of nodes instead of a flat list of SqlFragments? See the "AST 是什么" discussion — the tree lets us

  • emit parens correctly (e.g. (a OR b) AND c instead of relying on SQL precedence),

  • fix the NOT a > 5 misparse by always wrapping a NOT's operand,

  • rewrite dialect quirks in one place (eq nullIS NULL, IN ()0) instead of special-casing each call site.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Combines with other using AND.

Link copied to clipboard
fun build(): String

Returns the assembled SQL as a single string, with values inlined.

Link copied to clipboard

Negates the expression by wrapping it in NOT (operand is auto-parenthesized).

Link copied to clipboard

Combines with other using OR.