* Resolve a condition value - either return the literal value or resolve a reference from the path.
( path: TraversalPath<any, any, any>, value: ConditionValue, context?: QueryContext, )
| 1213 | * Resolve a condition value - either return the literal value or resolve a reference from the path. |
| 1214 | */ |
| 1215 | function resolveConditionValue( |
| 1216 | path: TraversalPath<any, any, any>, |
| 1217 | value: ConditionValue, |
| 1218 | context?: QueryContext, |
| 1219 | ): any { |
| 1220 | if (value === null || typeof value !== "object") { |
| 1221 | return value; |
| 1222 | } |
| 1223 | |
| 1224 | // Check if it's a reference object |
| 1225 | if ("type" in value) { |
| 1226 | if (value.type === "null") { |
| 1227 | // Explicit null literal |
| 1228 | return null; |
| 1229 | } else if (value.type === "variableRef") { |
| 1230 | // Resolve variable reference from path |
| 1231 | const variablePath = path.get(value.variable); |
| 1232 | if (!variablePath) { |
| 1233 | return undefined; |
| 1234 | } |
| 1235 | const element = variablePath.value; |
| 1236 | // Handle FOREACH and list comprehension element wrappers |
| 1237 | if ( |
| 1238 | element && |
| 1239 | typeof element === "object" && |
| 1240 | (element.label === "ForeachElement" || element.label === "ComprehensionElement") |
| 1241 | ) { |
| 1242 | return element.value; |
| 1243 | } |
| 1244 | return element; |
| 1245 | } else if (value.type === "pathRef") { |
| 1246 | // Resolve path reference from path - returns the full TraversalPath |
| 1247 | // This is used for path functions like nodes(p), relationships(p), length(p) |
| 1248 | const variablePath = path.get(value.variable); |
| 1249 | return variablePath; // Return the TraversalPath itself, not its value |
| 1250 | } else if (value.type === "propertyRef") { |
| 1251 | // Resolve property reference from path |
| 1252 | const variablePath = path.get(value.variable); |
| 1253 | if (!variablePath) { |
| 1254 | return undefined; |
| 1255 | } |
| 1256 | let element = variablePath.value; |
| 1257 | // Handle FOREACH and list comprehension element wrappers |
| 1258 | if ( |
| 1259 | element && |
| 1260 | typeof element === "object" && |
| 1261 | (element.label === "ForeachElement" || element.label === "ComprehensionElement") |
| 1262 | ) { |
| 1263 | element = element.value; |
| 1264 | } |
| 1265 | // Property access on null returns null |
| 1266 | if (element === null) { |
| 1267 | return null; |
| 1268 | } |
| 1269 | if (element instanceof Vertex || element instanceof Edge) { |
| 1270 | return element.get(value.property as never); |
| 1271 | } |
| 1272 | // Handle plain objects (maps) - access property directly |
no test coverage detected