Skip to content

Commit

Permalink
changed error msg, reused existing one
Browse files Browse the repository at this point in the history
  • Loading branch information
swilly22 committed Jun 4, 2024
1 parent c7c198a commit bb22b30
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
13 changes: 7 additions & 6 deletions src/ast/ast_validations.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,12 +740,13 @@ static VISITOR_STRATEGY _Validate_rel_pattern
enum cypher_rel_direction dir = cypher_ast_rel_pattern_get_direction(n);
const cypher_astnode_t *range = cypher_ast_rel_pattern_get_varlength(n);

// clause name used for error reporting
const char *clause_name = (vctx->clause == CYPHER_AST_CREATE) ?
"CREATE" :
"MERGE";

// extra validation when in a CREATE / MERGE clause
if(vctx->clause == CYPHER_AST_CREATE || vctx->clause == CYPHER_AST_MERGE) {
// clause name used for error reporting
const char *clause_name = (vctx->clause == CYPHER_AST_CREATE) ?
"CREATE" :
"MERGE";

// validate that each relation has exactly one type
if(reltype_count != 1) {
Expand Down Expand Up @@ -788,7 +789,7 @@ static VISITOR_STRATEGY _Validate_rel_pattern
const char *alias = cypher_ast_identifier_get_name(alias_node);
// edge can not be redeclared
if(_IdentifierAdd(vctx, alias, (void*)T_EDGE) == 0) {
ErrorCtx_SetError(EMSG_EDGE_REDECLARATION, alias);
ErrorCtx_SetError(EMSG_REDECLARE, "edge", alias, clause_name);
return VISITOR_BREAK;
}
}
Expand Down Expand Up @@ -1673,7 +1674,7 @@ static VISITOR_STRATEGY _Validate_CREATE_Clause

// fail on duplicate identifier
if(_IdentifierAdd(vctx, alias, (void*)t) == 0 && t == T_EDGE) {
ErrorCtx_SetError(EMSG_EDGE_REDECLARATION, alias);
ErrorCtx_SetError(EMSG_REDECLARE, "edge", alias, "CREATE");
res = VISITOR_BREAK;
break;
}
Expand Down
1 change: 0 additions & 1 deletion src/errors/error_msgs.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
#define EMSG_PROCEDURE_NOT_REGISTERED "Procedure `%s` is not registered"
#define EMSG_PROCEDURE_INVALID_ARGUMENTS "Procedure `%s` requires %d arguments, got %d"
#define EMSG_VAIABLE_ALREADY_DECLARED "Variable `%s` already declared"
#define EMSG_EDGE_REDECLARATION "Edge `%s` can only be declared once"
#define EMSG_PROCEDURE_INVALID_OUTPUT "Procedure `%s` does not yield output `%s`"
#define EMSG_CALLSUBQUERY_INVALID_REFERENCES "WITH imports in CALL {} must consist of only simple references to outside variables"
#define EMSG_VAIABLE_ALREADY_DECLARED_IN_OUTER_SCOPE "Variable `%s` already declared in outer scope"
Expand Down
2 changes: 1 addition & 1 deletion tests/flow/test_bound_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,5 +131,5 @@ def test07_bound_edges(self):
# should not reach this point
self.env.assertFalse(True)
except Exception as e:
self.env.assertIn("Edge `e` can only be declared once", str(e))
self.env.assertIn("The bound edge 'e' can't be redeclared in a MERGE clause", str(e))

4 changes: 2 additions & 2 deletions tests/flow/test_create_clause.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test02_edge_reuse(self):
# should not reach this point
self.env.assertTrue(False)
except Exception as e:
self.env.assertTrue("Edge `e` can only be declared once" in str(e))
self.env.assertTrue("The bound edge 'e' can't be redeclared in a CREATE clause" in str(e))

queries = ["MATCH ()-[e:R]->() CREATE ()-[e:R]->()",
"CREATE ()-[e:R]->() CREATE ()-[e:R]->()"]
Expand All @@ -67,5 +67,5 @@ def test02_edge_reuse(self):
# should not reach this point
self.env.assertTrue(False)
except Exception as e:
self.env.assertTrue("Edge `e` can only be declared once" in str(e))
self.env.assertTrue("The bound edge 'e' can't be redeclared in a CREATE clause" in str(e))

2 changes: 1 addition & 1 deletion tests/flow/test_graph_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def test09_create_use_alias_in_many_clauses(self):
self.graph.query(query)
self.env.assertTrue(False)
except redis.exceptions.ResponseError as e:
self.env.assertContains("Edge `r` can only be declared once", str(e))
self.env.assertContains("The bound edge 'r' can't be redeclared in a CREATE clause", str(e))

query = "MATCH (r) CREATE (r)"
try:
Expand Down
2 changes: 1 addition & 1 deletion tests/flow/test_null_handling.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test07_null_graph_entity_inputs(self):
# not expecting to reach this point
self.env.assertTrue(False)
except redis.exceptions.ResponseError as e:
self.env.assertContains("Edge `e` can only be declared once", str(e))
self.env.assertContains("The bound edge 'e' can't be redeclared in a MERGE clause", str(e))

# ValueHashJoin ops should not treat null values as equal.
def test08_null_value_hash_join(self):
Expand Down

0 comments on commit bb22b30

Please sign in to comment.