Commit b8312bc
feat: support aggregates in subqueries (#1298)
* feat: add toArray() for includes subqueries
toArray() wraps an includes subquery so the parent row contains
Array<T> instead of Collection<T>. When children change, the parent
row is re-emitted with a fresh array snapshot.
- Add ToArrayWrapper class and toArray() function
- Add materializeAsArray flag to IncludesSubquery IR node
- Detect ToArrayWrapper in builder, pass flag through compiler
- Re-emit parent rows on child changes for toArray entries
- Add SelectValue type support for ToArrayWrapper
- Add tests for basic toArray, reactivity, ordering, and limits
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Removed obsolete test
* Tests for changes to deeply nested queries
* Add type-level tests for toArray() includes subqueries
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Add change propagation tests for includes subqueries
Test the reactive model difference between Collection and toArray includes:
- Collection includes: child change does NOT re-emit the parent row
(the child Collection updates in place)
- toArray includes: child change DOES re-emit the parent row
(the parent row is re-emitted with the updated array snapshot)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Test aggregates inside subqueries
* Take into account correlation key when aggregating in subqueries
* changeset
* ci: apply automated fixes
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>1 parent 2271ca1 commit b8312bc
File tree
4 files changed
+1162
-30
lines changed- .changeset
- packages/db
- src/query/compiler
- tests/query
4 files changed
+1162
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
| |||
110 | 111 | | |
111 | 112 | | |
112 | 113 | | |
113 | | - | |
114 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
115 | 123 | | |
116 | 124 | | |
117 | 125 | | |
| |||
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
150 | 168 | | |
151 | 169 | | |
152 | 170 | | |
| |||
196 | 214 | | |
197 | 215 | | |
198 | 216 | | |
199 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
200 | 220 | | |
201 | 221 | | |
202 | 222 | | |
| |||
214 | 234 | | |
215 | 235 | | |
216 | 236 | | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
217 | 241 | | |
218 | 242 | | |
219 | 243 | | |
| |||
278 | 302 | | |
279 | 303 | | |
280 | 304 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
291 | 314 | | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
298 | | - | |
299 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
300 | 331 | | |
301 | 332 | | |
302 | 333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
529 | 529 | | |
530 | 530 | | |
531 | 531 | | |
532 | | - | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
533 | 536 | | |
534 | 537 | | |
535 | 538 | | |
536 | 539 | | |
537 | 540 | | |
538 | 541 | | |
539 | 542 | | |
| 543 | + | |
540 | 544 | | |
541 | 545 | | |
542 | 546 | | |
| |||
551 | 555 | | |
552 | 556 | | |
553 | 557 | | |
| 558 | + | |
554 | 559 | | |
555 | 560 | | |
556 | 561 | | |
| |||
0 commit comments