MCPcopy Create free account
hub / github.com/effect-app/libs / getSelectExpr

Function getSelectExpr

packages/infra/src/Store/SQL/query.ts:530–551  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

528 : false
529
530 const getSelectExpr = (): string => {
531 if (!select) return "id, _etag, data"
532 const fields = select.map((s) => {
533 if (typeof s === "string") {
534 if (s === idKey || s === "id") return `id`
535 if (s === "_etag") return `_etag`
536 return `${dialect.jsonExtractJson(s)} AS "${s}"`
537 }
538 if ("computed" in s) {
539 return computedSelectExpr(s.key, s.computed)
540 }
541 if ("aggregate" in s) {
542 return aggregateSelectExpr(s.key, s.aggregate)
543 }
544 if ("path" in s) {
545 // Group-by fields: extract as scalar (not JSON-encoded) so grouping works and values compare as plain strings/numbers
546 return `${fieldExpr(dottedToJsonPath(s.path))} AS "${s.key}"`
547 }
548 return `${dialect.jsonExtractJson(s.key)} AS "${s.key}"`
549 })
550 return fields.join(", ")
551 }
552
553 // Order matters: projection params must be emitted BEFORE user-filter
554 // params so positional `?` placeholders in SQLite match `params[]` order.

Callers 1

buildWhereSQLQueryFunction · 0.85

Calls 6

fieldExprFunction · 0.85
dottedToJsonPathFunction · 0.85
joinMethod · 0.80
computedSelectExprFunction · 0.70
aggregateSelectExprFunction · 0.70
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…