MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _ValidateInlinedProperties

Function _ValidateInlinedProperties

src/ast/ast_validations.c:714–745  ·  view source on GitHub ↗

Validate the property maps used in node/edge patterns in MATCH, and CREATE clauses

Source from the content-addressed store, hash-verified

712
713// Validate the property maps used in node/edge patterns in MATCH, and CREATE clauses
714static 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
748static VISITOR_STRATEGY _Validate_rel_pattern

Callers 2

_Validate_rel_patternFunction · 0.85
_Validate_node_patternFunction · 0.85

Calls 4

ErrorCtx_SetErrorFunction · 0.85
AST_GetTypedNodesFunction · 0.85
array_lenFunction · 0.85
array_freeFunction · 0.85

Tested by

no test coverage detected