@@ -57,8 +57,10 @@ def __init__(self, graph, response):
57
57
self .parse_statistics (response [0 ])
58
58
else :
59
59
# start by parsing statistics, matches the one we have
60
- self .parse_statistics (response [- 1 ]) # Last element.
60
+ self .parse_statistics (response [2 ]) # Third element, after header and records .
61
61
self .parse_results (response )
62
+ if len (response ) == 4 :
63
+ self .parse_metadata (response [3 ])
62
64
63
65
def _check_for_errors (self , response ):
64
66
if isinstance (response [0 ], ResponseError ):
@@ -94,6 +96,36 @@ def parse_statistics(self, raw_statistics):
94
96
if v is not None :
95
97
self .statistics [s ] = v
96
98
99
+ def parse_metadata (self , raw_metadata ):
100
+ # Decode metadata:
101
+ # [
102
+ # ["version", VERSION],
103
+ # ["labels", [[VALUE_STRING, "label_1"] ... ]],
104
+ # ["relationship types ", [[VALUE_STRING, "reltype_1"] ... ]],
105
+ # ["property keys", [[VALUE_STRING, "prop_1"] ... ]]
106
+ # ]
107
+ version = raw_metadata [0 ][1 ]
108
+ raw_labels = raw_metadata [1 ][1 ]
109
+ raw_reltypes = raw_metadata [2 ][1 ]
110
+ raw_props = raw_metadata [3 ][1 ]
111
+
112
+ # Arrays to be passed into the internal graph structure.
113
+ labels = [None ] * len (raw_labels )
114
+ reltypes = [None ] * len (raw_reltypes )
115
+ properties = [None ] * len (raw_props )
116
+
117
+ for idx , label in enumerate (raw_labels ):
118
+ labels [idx ] = self .parse_scalar (label )
119
+
120
+ for idx , reltype in enumerate (raw_reltypes ):
121
+ reltypes [idx ] = self .parse_scalar (reltype )
122
+
123
+ for idx , prop in enumerate (raw_props ):
124
+ properties [idx ] = self .parse_scalar (prop )
125
+
126
+ # Update the graph's internal metadata.
127
+ self .graph .refresh_metadata (version , labels , reltypes , properties )
128
+
97
129
def parse_header (self , raw_result_set ):
98
130
# An array of column name/column type pairs.
99
131
header = raw_result_set [0 ]
0 commit comments