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

Function areExpressionsEqual

packages/db/src/query/predicate-utils.ts:1049–1077  ·  view source on GitHub ↗
(a: BasicExpression, b: BasicExpression)

Source from the content-addressed store, hash-verified

1047}
1048
1049function areExpressionsEqual(a: BasicExpression, b: BasicExpression): boolean {
1050 if (a.type !== b.type) {
1051 return false
1052 }
1053
1054 if (a.type === `val` && b.type === `val`) {
1055 return areValuesEqual(a.value, b.value)
1056 }
1057
1058 if (a.type === `ref` && b.type === `ref`) {
1059 return areRefsEqual(a, b)
1060 }
1061
1062 if (a.type === `func` && b.type === `func`) {
1063 const aFunc = a
1064 const bFunc = b
1065 if (aFunc.name !== bFunc.name) {
1066 return false
1067 }
1068 if (aFunc.args.length !== bFunc.args.length) {
1069 return false
1070 }
1071 return aFunc.args.every((arg, i) =>
1072 areExpressionsEqual(arg, bFunc.args[i]!),
1073 )
1074 }
1075
1076 return false
1077}
1078
1079function areValuesEqual(a: any, b: any): boolean {
1080 // Simple equality check - could be enhanced for deep object comparison

Callers 5

isWhereSubsetInternalFunction · 0.85
isOrderBySubsetFunction · 0.85
areWhereClausesEqualFunction · 0.85
findCommonConditionsFunction · 0.85
removeConditionsFunction · 0.85

Calls 2

areRefsEqualFunction · 0.85
areValuesEqualFunction · 0.70

Tested by

no test coverage detected