Skip to content

Commit

Permalink
docs: Edit KDocs for Op.TRUE/FALSE to clarify purpose (#1957)
Browse files Browse the repository at this point in the history
Current KDocs are potentially misleading in that it seems like the operator
could be used both as a standalone value and on the right-hand side of a
comparison operator. For most databases, this works, but will lead to a syntax
error in SQL Server and Oracle.

The new KDocs clarify that they represent operators that always evaluate to a
boolean value, so using them on the right-hand side is not the intention.
  • Loading branch information
bog-walk authored Jan 3, 2024
1 parent 330eadf commit 8c247e1
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Op.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ abstract class Op<T> : Expression<T>() {

internal interface OpBoolean

/** Boolean operator corresponding to the SQL value `TRUE` */
/**
* Boolean operator that always evaluates to the SQL value `TRUE`.
*
* **Note** Some databases, like SQL Server and Oracle, do not support conditions like `WHERE 1` or `WHERE TRUE`.
* When using these databases, this operator will instead produce the condition `1 = 1`.
*/
object TRUE : Op<Boolean>(), OpBoolean {
override fun toQueryBuilder(queryBuilder: QueryBuilder): Unit = queryBuilder {
when {
Expand All @@ -32,7 +37,12 @@ abstract class Op<T> : Expression<T>() {
}
}

/** Boolean operator corresponding to the SQL value `FALSE` */
/**
* Boolean operator that always evaluates to the SQL value `FALSE`.
*
* **Note** Some databases, like SQL Server and Oracle, do not support conditions like `WHERE 0` or `WHERE FALSE`.
* When using these databases, this operator will instead produce the condition `1 = 0`.
*/
object FALSE : Op<Boolean>(), OpBoolean {
override fun toQueryBuilder(queryBuilder: QueryBuilder): Unit = queryBuilder {
when {
Expand Down

0 comments on commit 8c247e1

Please sign in to comment.