Skip to content

Commit 6ef6f63

Browse files
docs: document immediate value behavior in case() then/else (#1753)
Co-authored-by: Igal Klebanov <[email protected]>
1 parent 2fb071b commit 6ef6f63

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎src/query-builder/case-builder.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ export class CaseThenBuilder<DB, TB extends keyof DB, W, O> {
7575
*
7676
* A `then` call can be followed by {@link Whenable.when}, {@link CaseWhenBuilder.else},
7777
* {@link CaseWhenBuilder.end} or {@link CaseWhenBuilder.endCase} call.
78+
*
79+
* **Note:** Numbers, booleans, and `null` values are inlined directly into the
80+
* SQL query string (e.g. `then 1`, `then true`, `then null`) instead of being
81+
* added as parameterized values (e.g. `then $1`). This allows the database
82+
* engine to correctly infer the data type of the `case` expression result.
83+
* Without this behavior, all results would be returned as strings.
84+
*
85+
* String values are always parameterized as usual.
7886
*/
7987
then<E extends Expression<unknown>>(
8088
expression: E,
@@ -137,6 +145,14 @@ export class CaseWhenBuilder<DB, TB extends keyof DB, W, O>
137145
* Adds an `else` clause to the `case` statement.
138146
*
139147
* An `else` call must be followed by an {@link Endable.end} or {@link Endable.endCase} call.
148+
*
149+
* **Note:** Numbers, booleans, and `null` values are inlined directly into the
150+
* SQL query string (e.g. `else 0`, `else false`, `else null`) instead of being
151+
* added as parameterized values (e.g. `else $1`). This allows the database
152+
* engine to correctly infer the data type of the `case` expression result.
153+
* Without this behavior, all results would be returned as strings.
154+
*
155+
* String values are always parameterized as usual.
140156
*/
141157
else<E extends Expression<unknown>>(
142158
expression: E,

0 commit comments

Comments
 (0)