validate that shortestPaths is in a supported place
| 68 | |
| 69 | // validate that shortestPaths is in a supported place |
| 70 | static bool _ValidateShortestPaths |
| 71 | ( |
| 72 | const cypher_astnode_t *root // root to validate |
| 73 | ) { |
| 74 | ASSERT(root != NULL); |
| 75 | |
| 76 | cypher_astnode_type_t t = cypher_astnode_type(root); |
| 77 | // if we found allShortestPaths in invalid parent return true |
| 78 | if(t == CYPHER_AST_SHORTEST_PATH && |
| 79 | cypher_ast_shortest_path_is_single(root)) { |
| 80 | return false; |
| 81 | } |
| 82 | |
| 83 | // shortestPaths is invalid in the MATCH pattern |
| 84 | if(t == CYPHER_AST_MATCH) { |
| 85 | const cypher_astnode_t *pattern = cypher_ast_match_get_pattern(root); |
| 86 | return _ValidateShortestPaths(pattern); |
| 87 | } |
| 88 | |
| 89 | if(t == CYPHER_AST_WITH || t == CYPHER_AST_RETURN) { |
| 90 | return true; |
| 91 | } |
| 92 | |
| 93 | // recursively traverse all children |
| 94 | uint nchildren = cypher_astnode_nchildren(root); |
| 95 | for(uint i = 0; i < nchildren; i ++) { |
| 96 | const cypher_astnode_t *child = cypher_astnode_get_child(root, i); |
| 97 | if(!_ValidateShortestPaths(child)) { |
| 98 | return false; |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | return true; |
| 103 | } |
| 104 | |
| 105 | // introduce aliases of a WITH clause to the bound vars |
| 106 | // return true if no errors where encountered, false otherwise |
no outgoing calls
no test coverage detected