diff options
| author | LV-426 <lv-426@taproot.org.il> | 2015-03-23 15:56:35 +0200 |
|---|---|---|
| committer | LV-426 <lv-426@taproot.org.il> | 2015-04-01 22:20:31 +0300 |
| commit | 079c0740ead4df35c96de63896f56299a253a3bf (patch) | |
| tree | 8e9c698d1b3c3788e9745d19657dd79f8b7e1c3a /src | |
| parent | ad78f113e8879863f406d3a3c9fa9da9bdc9c8be (diff) | |
Query_Struct_Type - could probably use some cleanup
Diffstat (limited to 'src')
| -rw-r--r-- | src/server/neo4j_cypher.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/server/neo4j_cypher.py b/src/server/neo4j_cypher.py index 9c9e919b..579385da 100644 --- a/src/server/neo4j_cypher.py +++ b/src/server/neo4j_cypher.py @@ -33,7 +33,7 @@ class Query_Struct_Type(Enum): rw = 4 def __add__(self, other): - if self == other or self == pt_root.Query_Struct_Type.rw: + if self == other or self == Query_Struct_Type.rw: return self if self == Query_Struct_Type.unkown: return other @@ -49,6 +49,13 @@ class Query_Struct_Type(Enum): if self == Query_Struct_Type.rw: return 'rw' assert False + def __eq__(self, other): # allow comparing against r/w/rw strings + if other in ['r', 'w', 'rw']: + if self == Query_Struct_Type.r and other == 'r': return True + if self == Query_Struct_Type.w and other == 'w': return True + if self == Query_Struct_Type.rw and other == 'rw': return True + if not isinstance(other, Query_Struct_Type): return False + return super(Query_Struct_Type, self).__eq__(other) class Query_Transformation(object): @@ -181,8 +188,18 @@ class DB_Query(object): """ calc query_structure_type: read|write|read-write """ + r = False + w = False + for kw, _clause_set in self.pt_root.index__kw_to_clause_set().items(): + if kw in neo4j_cypher_parser.tok_set__kw__write: + w = True if kw == 'match': + r = True + if r and w: return Query_Struct_Type.rw + if r and not w: return Query_Struct_Type.r + if w and not r: return Query_Struct_Type.w + return Query_Struct_Type.unkown def str__cypher_query(self): return self.pt_root.str__cypher_query() |
