1
1
from .node import Node
2
2
from .edge import Edge
3
3
from .path import Path
4
+ from .exceptions import VersionMismatchException
4
5
from prettytable import PrettyTable
5
6
from redis import ResponseError
6
7
14
15
INDICES_DELETED = "Indices deleted"
15
16
CACHED_EXECUTION = "Cached execution"
16
17
INTERNAL_EXECUTION_TIME = 'internal execution time'
17
- GRAPH_VERSION = 'Graph version'
18
18
19
19
STATS = [LABELS_ADDED , NODES_CREATED , PROPERTIES_SET , RELATIONSHIPS_CREATED ,
20
20
NODES_DELETED , RELATIONSHIPS_DELETED , INDICES_CREATED , INDICES_DELETED ,
21
- CACHED_EXECUTION , INTERNAL_EXECUTION_TIME , GRAPH_VERSION ]
21
+ CACHED_EXECUTION , INTERNAL_EXECUTION_TIME ]
22
22
23
23
class ResultSetColumnTypes (object ):
24
24
COLUMN_UNKNOWN = 0
@@ -45,24 +45,27 @@ def __init__(self, graph, response):
45
45
self .header = []
46
46
self .result_set = []
47
47
48
- # If we encountered a run-time error, the last response element will be an exception.
49
- if isinstance (response [- 1 ], ResponseError ):
50
- raise response [- 1 ]
48
+ # incase of an error an exception will be raised
49
+ self ._check_for_errors (response )
51
50
52
51
if len (response ) == 1 :
53
52
self .parse_statistics (response [0 ])
54
53
else :
55
- # start by parsing statistics, see if the reported graph version
56
- # matches the one we have
54
+ # start by parsing statistics, matches the one we have
57
55
self .parse_statistics (response [- 1 ]) # Last element.
56
+ self .parse_results (response )
58
57
59
- if (graph .version != self .graph_version ):
60
- # graph version miss-match, this is an indication that
61
- # the graph schema was modified, sync it.
62
- graph .version = self .graph_version
63
- graph ._refresh_schema ()
58
+ def _check_for_errors (self , response ):
59
+ if isinstance (response [0 ], ResponseError ):
60
+ error = response [0 ]
61
+ if str (error ) == "version mismatch" :
62
+ version = response [1 ]
63
+ error = VersionMismatchException (version )
64
+ raise error
64
65
65
- self .parse_results (response )
66
+ # If we encountered a run-time error, the last response element will be an exception.
67
+ if isinstance (response [- 1 ], ResponseError ):
68
+ raise response [- 1 ]
66
69
67
70
def parse_results (self , raw_result_set ):
68
71
self .header = self .parse_header (raw_result_set )
@@ -286,7 +289,3 @@ def cached_execution(self):
286
289
def run_time_ms (self ):
287
290
return self ._get_stat (INTERNAL_EXECUTION_TIME )
288
291
289
- @property
290
- def graph_version (self ):
291
- return self ._get_stat (GRAPH_VERSION )
292
-
0 commit comments