Validate the property maps used in node/edge patterns in MATCH, and CREATE clauses
| 712 | |
| 713 | // Validate the property maps used in node/edge patterns in MATCH, and CREATE clauses |
| 714 | static AST_Validation _ValidateInlinedProperties |
| 715 | ( |
| 716 | const cypher_astnode_t *props // ast-node representing the map |
| 717 | ) { |
| 718 | if(props == NULL) { |
| 719 | return AST_VALID; |
| 720 | } |
| 721 | |
| 722 | // Emit an error if the properties are not presented as a map, as in: |
| 723 | // MATCH (p {invalid_property_construction}) RETURN p |
| 724 | if(cypher_astnode_type(props) != CYPHER_AST_MAP) { |
| 725 | ErrorCtx_SetError("Encountered unhandled type in inlined properties."); |
| 726 | return AST_INVALID; |
| 727 | } |
| 728 | |
| 729 | // traverse map entries |
| 730 | uint prop_count = cypher_ast_map_nentries(props); |
| 731 | for(uint i = 0; i < prop_count; i++) { |
| 732 | const cypher_astnode_t *prop_val = cypher_ast_map_get_value(props, i); |
| 733 | const cypher_astnode_t **patterns = AST_GetTypedNodes(prop_val, CYPHER_AST_PATTERN_PATH); |
| 734 | uint patterns_count = array_len(patterns); |
| 735 | array_free(patterns); |
| 736 | if(patterns_count > 0) { |
| 737 | // Encountered query of the form: |
| 738 | // MATCH (a {prop: ()-[]->()}) RETURN a |
| 739 | ErrorCtx_SetError("Encountered unhandled type in inlined properties."); |
| 740 | return AST_INVALID; |
| 741 | } |
| 742 | } |
| 743 | |
| 744 | return AST_VALID; |
| 745 | } |
| 746 | |
| 747 | // validate a relation-pattern |
| 748 | static VISITOR_STRATEGY _Validate_rel_pattern |
no test coverage detected