MCPcopy Create free account
hub / github.com/TanStack/db / visitSelectValue

Function visitSelectValue

packages/db/src/query/compiler/index.ts:1613–1651  ·  view source on GitHub ↗
(
    value: any,
    path: Array<string>,
    guards: Array<ConditionalSelectGuard>,
  )

Source from the content-addressed store, hash-verified

1611 }
1612
1613 const visitSelectValue = (
1614 value: any,
1615 path: Array<string>,
1616 guards: Array<ConditionalSelectGuard>,
1617 ) => {
1618 if (value instanceof PropRef && pathStartsWith(targetPath, value.path)) {
1619 resultPaths.push({
1620 path: [...path, ...targetPath.slice(value.path.length)],
1621 guards,
1622 })
1623 return
1624 }
1625
1626 if (value instanceof ConditionalSelect) {
1627 const previousBranchGuards: Array<ConditionalSelectGuard> = []
1628 for (const branch of value.branches) {
1629 visitSelectValue(branch.value, path, [
1630 ...guards,
1631 ...previousBranchGuards,
1632 { condition: branch.condition, expected: true },
1633 ])
1634 previousBranchGuards.push({
1635 condition: branch.condition,
1636 expected: false,
1637 })
1638 }
1639 if (value.defaultValue !== undefined) {
1640 visitSelectValue(value.defaultValue, path, [
1641 ...guards,
1642 ...previousBranchGuards,
1643 ])
1644 }
1645 return
1646 }
1647
1648 if (isNestedSelectObject(value)) {
1649 visitSelectObject(value, path, guards)
1650 }
1651 }
1652
1653 visitSelectObject(select, [], [])
1654 return resultPaths

Callers 1

visitSelectObjectFunction · 0.85

Calls 3

pathStartsWithFunction · 0.85
visitSelectObjectFunction · 0.85
isNestedSelectObjectFunction · 0.70

Tested by

no test coverage detected