Commit b8abc02
fix(db): infer non-nullable return type from first arg in coalesce() (#1342)
* fix(db): infer type in coalesce() instead of returning BasicExpression<any>
Previously coalesce() always returned BasicExpression<any>, losing type
information. Now it uses a generic to infer the non-nullable union of all
argument types, matching the semantic of SQL COALESCE.
Fixes #1341
* fix(db): preserve null in coalesce() when no guaranteed non-null arg
- Use HasGuaranteedNonNull<T> helper to track whether any arg statically
cannot be null/undefined
- Return CoalesceArgTypes<T> | null unless a non-null arg guarantees it
- Update tests to use spread args (varargs) instead of array
- Update changeset description
Addresses samwillis review feedback and kevin-dp ExpressionLike concerns
* ci: apply automated fixes
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>1 parent c281b37 commit b8abc02
File tree
4 files changed
+47
-4
lines changed- .changeset
- packages/db
- src/query/builder
- tests/query/builder
4 files changed
+47
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
290 | 314 | | |
291 | 315 | | |
292 | 316 | | |
293 | | - | |
| 317 | + | |
294 | 318 | | |
295 | 319 | | |
296 | 320 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
152 | 164 | | |
153 | 165 | | |
154 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| |||
0 commit comments