MCPcopy Index your code
hub / github.com/TanStack/db / compileGroupedConditionalSelect

Function compileGroupedConditionalSelect

packages/db/src/query/compiler/group-by.ts:917–938  ·  view source on GitHub ↗
(
  conditional: ConditionalSelect,
)

Source from the content-addressed store, hash-verified

915}
916
917function compileGroupedConditionalSelect(
918 conditional: ConditionalSelect,
919): (row: NamespacedRow) => any {
920 const branches = conditional.branches.map((branch) => ({
921 condition: compileExpression(branch.condition),
922 value: compileGroupedSelectValue(branch.value),
923 }))
924 const defaultValue =
925 conditional.defaultValue === undefined
926 ? undefined
927 : compileGroupedSelectValue(conditional.defaultValue)
928
929 return (row) => {
930 for (const branch of branches) {
931 if (isCaseWhenConditionTrue(branch.condition(row))) {
932 return branch.value(row)
933 }
934 }
935
936 return defaultValue !== undefined ? defaultValue(row) : null
937 }
938}
939
940function isNestedSelectObject(value: unknown): value is Select {
941 return (

Callers 1

Calls 4

isCaseWhenConditionTrueFunction · 0.85
compileExpressionFunction · 0.70
mapMethod · 0.45

Tested by

no test coverage detected