@quilla-be-kit/persistence 0.1.6 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -459,20 +459,22 @@ this.qb<OrderSummaryRow>()
|
|
|
459
459
|
.from('orders o')
|
|
460
460
|
.join('LEFT JOIN customers c ON c.id = o.customer_id')
|
|
461
461
|
.join('LEFT JOIN order_lines ol ON ol.order_id = o.id')
|
|
462
|
-
.select(['o.id', 'o.
|
|
463
|
-
.filters({ 'o.
|
|
462
|
+
.select(['o.id', 'o.created_at', 'c.name', 'ol.sku'])
|
|
463
|
+
.filters({ 'o.scope_id': scopeId })
|
|
464
464
|
.build();
|
|
465
465
|
```
|
|
466
466
|
|
|
467
467
|
**Column qualification.** When queries span multiple tables, qualify ambiguous column references in every builder call that touches column names — `.select()`, `.filters()`, `.where()`, `.groupBy()`, and `.orderBy()` all accept `'table.col'` expressions and pass them through without resolver lookup:
|
|
468
468
|
|
|
469
469
|
```ts
|
|
470
|
-
.select(['o.
|
|
470
|
+
.select(['o.created_at']) // table.col — passed through, no resolver
|
|
471
471
|
.select(['createdAt']) // bare key — resolved via ColumnResolver
|
|
472
472
|
.select(['o.*']) // wildcard — passed through
|
|
473
473
|
.select(['COUNT(ol.id) AS "lineCount"']) // pre-aliased expression — passed through
|
|
474
474
|
```
|
|
475
475
|
|
|
476
|
+
> **Qualified references are SQL space.** The builder holds one resolver — the aggregate's — so it can't sensibly keep mapping past the dot (a joined table may have its own naming or overrides). The rule is: bare `createdAt` is domain vocabulary and gets resolved; `o.createdAt` is SQL and emits `o.createdAt` verbatim, which Postgres will reject if the real column is `created_at`. Write `o.created_at` yourself once you've qualified. The asymmetry is silent at build time and surfaces only at query execution — qualify carefully.
|
|
477
|
+
|
|
476
478
|
`.from()` accepts an alias: `'orders o'` or `'orders AS o'`. Use an alias whenever you qualify columns so the alias propagates consistently through the rest of the query.
|
|
477
479
|
|
|
478
480
|
### Aggregations with GROUP BY
|
|
@@ -483,9 +485,9 @@ this.qb<OrderSummaryRow>()
|
|
|
483
485
|
this.qb<LineCountRow>()
|
|
484
486
|
.from('orders o')
|
|
485
487
|
.join('LEFT JOIN order_lines ol ON ol.order_id = o.id')
|
|
486
|
-
.select(['o.id', 'o.
|
|
487
|
-
.filters({ 'o.
|
|
488
|
-
.groupBy(['o.id', 'o.
|
|
488
|
+
.select(['o.id', 'o.created_at', 'COUNT(ol.id) AS "lineCount"'])
|
|
489
|
+
.filters({ 'o.scope_id': scopeId })
|
|
490
|
+
.groupBy(['o.id', 'o.created_at'])
|
|
489
491
|
.build();
|
|
490
492
|
```
|
|
491
493
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quilla-be-kit/persistence",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Persistence primitives: Database, DAOs with audit injection and optimistic locking, aggregate repositories with scope isolation, UnitOfWork with pluggable outbox.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Max Martinez",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"vitest": "^2.1.3",
|
|
73
73
|
"zod": "^4.0.0",
|
|
74
74
|
"@quilla-be-kit/errors": "^0.2.1",
|
|
75
|
-
"@quilla-be-kit/
|
|
76
|
-
"@quilla-be-kit/
|
|
75
|
+
"@quilla-be-kit/execution-context": "^0.2.2",
|
|
76
|
+
"@quilla-be-kit/ddd": "^0.2.1"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"build": "tsc -b",
|