Clause
A sealed class that provides a domain-specific language (DSL) for constructing SQL clauses, primarily used in WHERE and HAVING conditions. It offers a type-safe and fluent way to build complex logical expressions.
This class and its extension functions allow for creating various SQL expressions, including:
Comparison operators: EQ, NOT_EQ, LT, LTE, GT, GTE, IS, IS_NOT.
Range checks: BETWEEN, NOT_BETWEEN.
Existence checks: EXISTS, NOT_EXISTS.
Logical operators: Expression.AND, Expression.OR, NOT.
The Clause is designed to be used within the context of a statement builder (e.g., SelectStatement, UpdateStatement). It generates Expression objects that are internally translated into a SQL query string with appropriate placeholders.
Example usage in a WHERE block:
select(Employees.employeeId, Employees.firstName)
.from(Employees)
.where {
(Employees.age GTE 18) AND (Employees.firstName LIKE "J%")
}.execute()The methods are defined as extensions on KQLiteColumn or as standalone functions within the scope of a lambda that has a Clause as its receiver.
Author
MOHAMMAD AZIM ANSARI
See also
Functions
Creates a BETWEEN expression using a Kotlin ClosedRange (e.g., 1..10).
Creates a BETWEEN expression to check if a column's value is within the range defined by two other columns.
Creates a BETWEEN expression to check if the column's value is within a specified range (inclusive).
Creates an equality comparison expression (=) between a column and a subquery.
Creates an equality comparison expression (= or IS).
Creates an equality comparison expression (=) between two columns.
Creates an EXISTS expression to check for the existence of rows in a subquery.
Creates a GLOB pattern-matching expression, which is similar to LIKE but uses Unix-style wildcards.
Creates an IN expression to check if the column's value is present in the result set of a subquery.
Creates an IN expression to check if the column's value is present in a given list of values.
Creates a LIKE pattern-matching expression.
Creates a LIKE pattern-matching expression with an optional ESCAPE character.
Creates a logical NOT expression.
Creates a logical NOT expression for a subquery.
Creates a non-equality comparison expression (!= or IS NOT).
Creates a regular expression match expression (REGEXP).