Skip to content

Commit

Permalink
Remove params annotations from 2.0 (#1200)
Browse files Browse the repository at this point in the history
* removed query parameters annotations (#1101)

* added missing params tests

Co-authored-by: Roi Lipman <swilly22@users.noreply.github.com>
  • Loading branch information
DvirDukhan and swilly22 committed Jul 7, 2020
1 parent d9ae26e commit b2a603b
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 118 deletions.
13 changes: 0 additions & 13 deletions src/ast/ast_annotations_ctx_collection.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
AST_AnnotationCtxCollection *AST_AnnotationCtxCollection_New() {
AST_AnnotationCtxCollection *anotCtxCollection = rm_malloc(sizeof(AST_AnnotationCtxCollection));
anotCtxCollection->name_ctx = NULL;
anotCtxCollection->params_ctx = NULL;
anotCtxCollection->named_paths_ctx = NULL;
anotCtxCollection->project_all_ctx = NULL;
return anotCtxCollection;
Expand All @@ -21,11 +20,6 @@ inline AnnotationCtx *AST_AnnotationCtxCollection_GetNameCtx(const AST_Annotatio
return anot_ctx_collection->name_ctx;
}

inline AnnotationCtx *AST_AnnotationCtxCollection_GetParamsCtx(const AST_AnnotationCtxCollection
*anot_ctx_collection) {
return anot_ctx_collection->params_ctx;
}

inline AnnotationCtx *AST_AnnotationCtxCollection_GetNamedPathsCtx(const AST_AnnotationCtxCollection
*anot_ctx_collection) {
return anot_ctx_collection->named_paths_ctx;
Expand All @@ -41,12 +35,6 @@ inline void AST_AnnotationCtxCollection_SetNameCtx(AST_AnnotationCtxCollection *
anot_ctx_collection->name_ctx = name_ctx;
}

inline void AST_AnnotationCtxCollection_SetParamsCtx(AST_AnnotationCtxCollection
*anot_ctx_collection,
AnnotationCtx *params_ctx) {
anot_ctx_collection->params_ctx = params_ctx;
}

inline void AST_AnnotationCtxCollection_SetNamedPathsCtx(AST_AnnotationCtxCollection
*anot_ctx_collection,
AnnotationCtx *named_paths_ctx) {
Expand All @@ -62,7 +50,6 @@ inline void AST_AnnotationCtxCollection_SetProjectAllCtx(AST_AnnotationCtxCollec
void AST_AnnotationCtxCollection_Free(AST_AnnotationCtxCollection *anotCtxCollection) {
if(anotCtxCollection) {
if(anotCtxCollection->name_ctx) cypher_ast_annotation_context_free(anotCtxCollection->name_ctx);
if(anotCtxCollection->params_ctx) cypher_ast_annotation_context_free(anotCtxCollection->params_ctx);
if(anotCtxCollection->named_paths_ctx) cypher_ast_annotation_context_free(
anotCtxCollection->named_paths_ctx);
if(anotCtxCollection->project_all_ctx) cypher_ast_annotation_context_free(
Expand Down
31 changes: 11 additions & 20 deletions src/ast/ast_annotations_ctx_collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,23 @@ typedef cypher_ast_annotation_context_t AnnotationCtx;
* specific AST nodes annotation use case. For each context there is a dedicated inlined
* getter and setter. */
typedef struct {
AnnotationCtx *name_ctx; // Annotation context for naming graph entities and ORDER items.
AnnotationCtx *params_ctx; // Annotation context for query parameters.
AnnotationCtx *name_ctx; // Annotation context for naming graph entities and ORDER items.
AnnotationCtx *project_all_ctx; // Context containing aliases for WITH/RETURN * projections.
AnnotationCtx *named_paths_ctx; // Annotation context for named paths projections.
} AST_AnnotationCtxCollection;

AST_AnnotationCtxCollection *AST_AnnotationCtxCollection_New();

AnnotationCtx *AST_AnnotationCtxCollection_GetNameCtx(const AST_AnnotationCtxCollection
*anot_ctx_collection);
AnnotationCtx *AST_AnnotationCtxCollection_GetParamsCtx(const AST_AnnotationCtxCollection
*anot_ctx_collection);
AnnotationCtx *AST_AnnotationCtxCollection_GetNamedPathsCtx(const AST_AnnotationCtxCollection
*anot_ctx_collection);
AnnotationCtx *AST_AnnotationCtxCollection_GetProjectAllCtx(const AST_AnnotationCtxCollection
*anot_ctx_collection);

void AST_AnnotationCtxCollection_SetNameCtx(AST_AnnotationCtxCollection *anot_ctx_collection,
AnnotationCtx *name_ctx);
void AST_AnnotationCtxCollection_SetParamsCtx(AST_AnnotationCtxCollection *anot_ctx_collection,
AnnotationCtx *params_ctx);
void AST_AnnotationCtxCollection_SetNamedPathsCtx(AST_AnnotationCtxCollection *anot_ctx_collection,
AnnotationCtx *named_paths_ctx);
void AST_AnnotationCtxCollection_SetProjectAllCtx(AST_AnnotationCtxCollection *anot_ctx_collection,
AnnotationCtx *project_all_ctx);
AnnotationCtx *AST_AnnotationCtxCollection_GetNameCtx(const AST_AnnotationCtxCollection *anot_ctx_collection);

void AST_AnnotationCtxCollection_Free(AST_AnnotationCtxCollection *anot_ctx_collection);
AnnotationCtx *AST_AnnotationCtxCollection_GetNamedPathsCtx(const AST_AnnotationCtxCollection *anot_ctx_collection);

AnnotationCtx *AST_AnnotationCtxCollection_GetProjectAllCtx(const AST_AnnotationCtxCollection *anot_ctx_collection);

void AST_AnnotationCtxCollection_SetNameCtx(AST_AnnotationCtxCollection *anot_ctx_collection, AnnotationCtx *name_ctx);

void AST_AnnotationCtxCollection_SetNamedPathsCtx(AST_AnnotationCtxCollection *anot_ctx_collection, AnnotationCtx *named_paths_ctx);

void AST_AnnotationCtxCollection_SetProjectAllCtx(AST_AnnotationCtxCollection *anot_ctx_collection, AnnotationCtx *project_all_ctx);

void AST_AnnotationCtxCollection_Free(AST_AnnotationCtxCollection *anot_ctx_collection);
2 changes: 0 additions & 2 deletions src/ast/ast_enrich.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

#include "enrichment/annotate_entities.h"
#include "enrichment/annotate_params.h"
#include "enrichment/annotate_project_all.h"
#include "enrichment/annotate_projected_named_paths.h"

Expand All @@ -20,6 +19,5 @@ void AST_Enrich(AST *ast) {
AST_AnnotateEntities(ast);
AST_AnnotateProjectAll(ast);
AST_AnnotateNamedPaths(ast);
AST_AnnotateParams(ast);
}

72 changes: 0 additions & 72 deletions src/ast/enrichment/annotate_params.c

This file was deleted.

11 changes: 0 additions & 11 deletions src/ast/enrichment/annotate_params.h

This file was deleted.

26 changes: 26 additions & 0 deletions tests/flow/test_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,29 @@ def test_parameterized_skip_limit(self):
except redis.exceptions.ResponseError as e:
pass

def test_missing_parameter(self):
# Make sure missing parameters are reported back as an error.
query = "RETURN $missing"
try:
redis_graph.query(query)
assert(False)
except:
# Expecting an error.
pass

query = "MATCH (a) WHERE a.v = $missing RETURN a"
try:
redis_graph.query(query)
assert(False)
except:
# Expecting an error.
pass

query = "MATCH (a) SET a.v = $missing RETURN a"
try:
redis_graph.query(query)
assert(False)
except:
# Expecting an error.
pass

0 comments on commit b2a603b

Please sign in to comment.