( path: TraversalPath<any, any, any>, condition: BinaryCondition, context?: QueryContext, )
| 2160 | } |
| 2161 | |
| 2162 | function evaluateBinaryCondition( |
| 2163 | path: TraversalPath<any, any, any>, |
| 2164 | condition: BinaryCondition, |
| 2165 | context?: QueryContext, |
| 2166 | ): boolean { |
| 2167 | const [operator, key, conditionValue] = condition; |
| 2168 | const element = path.value; |
| 2169 | if (!(element instanceof Vertex || element instanceof Edge)) { |
| 2170 | return false; |
| 2171 | } |
| 2172 | |
| 2173 | // Resolve the condition value (handles variable/property references) |
| 2174 | const value = resolveConditionValue(path, conditionValue, context); |
| 2175 | |
| 2176 | const actual = key === "@id" ? element.id : key === "@label" ? element.label : element.get(key); |
| 2177 | switch (operator) { |
| 2178 | case "=": { |
| 2179 | if (value == null) { |
| 2180 | return actual == null; |
| 2181 | } |
| 2182 | if (actual == null) { |
| 2183 | return false; |
| 2184 | } |
| 2185 | if (typeof actual === "object" && typeof value === "string") { |
| 2186 | return String(actual) === value; |
| 2187 | } |
| 2188 | if (typeof actual !== typeof value) { |
| 2189 | return false; |
| 2190 | } |
| 2191 | if (typeof value === "object") { |
| 2192 | return compare(actual, value) === 0; |
| 2193 | } |
| 2194 | return actual === value; |
| 2195 | } |
| 2196 | case "!=": { |
| 2197 | if (value == null) { |
| 2198 | return actual !== null; |
| 2199 | } |
| 2200 | if (actual == null) { |
| 2201 | return true; |
| 2202 | } |
| 2203 | if (typeof actual === "object" && typeof value === "string") { |
| 2204 | return String(actual) !== value; |
| 2205 | } |
| 2206 | if (typeof actual !== typeof value) { |
| 2207 | return true; |
| 2208 | } |
| 2209 | if (typeof value === "object") { |
| 2210 | return compare(actual, value) !== 0; |
| 2211 | } |
| 2212 | return actual !== value; |
| 2213 | } |
| 2214 | case "<": |
| 2215 | return actual < value; |
| 2216 | case "<=": |
| 2217 | return actual <= value; |
| 2218 | case ">": |
| 2219 | return actual > value; |
no test coverage detected