@effect-app/infra 4.0.0-beta.217 → 4.0.0-beta.218
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/CHANGELOG.md +16 -0
- package/dist/Model/query/dsl.d.ts +9 -1
- package/dist/Model/query/dsl.d.ts.map +1 -1
- package/dist/Model/query/dsl.js +29 -1
- package/dist/Model/query/new-kid-interpreter.d.ts +7 -1
- package/dist/Model/query/new-kid-interpreter.d.ts.map +1 -1
- package/dist/Model/query/new-kid-interpreter.js +12 -1
- package/dist/Store/Cosmos/query.d.ts +1 -1
- package/dist/Store/Cosmos/query.d.ts.map +1 -1
- package/dist/Store/Cosmos/query.js +13 -1
- package/dist/Store/Memory.d.ts +1 -1
- package/dist/Store/Memory.d.ts.map +1 -1
- package/dist/Store/Memory.js +21 -1
- package/dist/Store/SQL/query.d.ts +1 -1
- package/dist/Store/SQL/query.d.ts.map +1 -1
- package/dist/Store/SQL/query.js +18 -1
- package/package.json +2 -2
- package/src/Model/query/dsl.ts +40 -0
- package/src/Model/query/new-kid-interpreter.ts +18 -0
- package/src/Store/Cosmos/query.ts +12 -0
- package/src/Store/Memory.ts +18 -0
- package/src/Store/SQL/query.ts +17 -0
package/src/Store/Memory.ts
CHANGED
|
@@ -48,6 +48,8 @@ const emptyValueFor = (tag: ComputedProjectionIrExpression["_tag"]) => {
|
|
|
48
48
|
return true
|
|
49
49
|
case "relation-collect":
|
|
50
50
|
return [] as unknown[]
|
|
51
|
+
case "relation-collect-fields":
|
|
52
|
+
return [] as unknown[]
|
|
51
53
|
default:
|
|
52
54
|
return assertUnreachable(tag)
|
|
53
55
|
}
|
|
@@ -136,6 +138,22 @@ const computeProjectionValue = (
|
|
|
136
138
|
}
|
|
137
139
|
return out
|
|
138
140
|
}
|
|
141
|
+
case "relation-collect-fields": {
|
|
142
|
+
const out: unknown[] = []
|
|
143
|
+
const seen = computed.distinct ? new Set<unknown>() : undefined
|
|
144
|
+
for (const value of relation) {
|
|
145
|
+
if (!matches(value)) continue
|
|
146
|
+
for (const field of computed.fields) {
|
|
147
|
+
const v = get(value, field)
|
|
148
|
+
if (seen) {
|
|
149
|
+
if (seen.has(v)) continue
|
|
150
|
+
seen.add(v)
|
|
151
|
+
}
|
|
152
|
+
out.push(v)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return out
|
|
156
|
+
}
|
|
139
157
|
default:
|
|
140
158
|
return assertUnreachable(computed)
|
|
141
159
|
}
|
package/src/Store/SQL/query.ts
CHANGED
|
@@ -469,6 +469,23 @@ export function buildWhereSQLQuery(
|
|
|
469
469
|
const aggArg = computed.distinct ? `DISTINCT ${fieldExtract}` : fieldExtract
|
|
470
470
|
return `(SELECT COALESCE(jsonb_agg(${aggArg}), '[]'::jsonb) FROM ${relationFrom}${whereClause()}) AS "${key}"`
|
|
471
471
|
}
|
|
472
|
+
case "relation-collect-fields": {
|
|
473
|
+
const branches = computed.fields.map((field) => {
|
|
474
|
+
const fieldExtract = dialect.jsonExtractElement(relationAlias, field)
|
|
475
|
+
return `SELECT ${fieldExtract} AS __v FROM ${relationFrom}${whereClause()}`
|
|
476
|
+
})
|
|
477
|
+
const unionQuery = branches.join(" UNION ALL ")
|
|
478
|
+
if (dialect.jsonColumnType === "JSON") {
|
|
479
|
+
if (computed.distinct) {
|
|
480
|
+
return `(SELECT COALESCE(json_group_array(__v), json_array()) FROM (SELECT DISTINCT __v FROM (${unionQuery}))) AS "${key}"`
|
|
481
|
+
}
|
|
482
|
+
return `(SELECT COALESCE(json_group_array(__v), json_array()) FROM (${unionQuery})) AS "${key}"`
|
|
483
|
+
}
|
|
484
|
+
if (computed.distinct) {
|
|
485
|
+
return `(SELECT COALESCE(jsonb_agg(__v), '[]'::jsonb) FROM (SELECT DISTINCT __v FROM (${unionQuery}) inner_q) outer_q) AS "${key}"`
|
|
486
|
+
}
|
|
487
|
+
return `(SELECT COALESCE(jsonb_agg(__v), '[]'::jsonb) FROM (${unionQuery}) t) AS "${key}"`
|
|
488
|
+
}
|
|
472
489
|
default:
|
|
473
490
|
return assertUnreachable(computed)
|
|
474
491
|
}
|