@@ -48,11 +48,11 @@ def __init__(self, connection, on_error):
4848 connection raises of of the caught errors.
4949 :type on_error callable
5050 """
51- self ._connection = connection
52- self ._on_error = on_error
51+ self .connection = connection
52+ self .on_error = on_error
5353
5454 def __getattr__ (self , item ):
55- connection_attr = getattr (self ._connection , item )
55+ connection_attr = getattr (self .connection , item )
5656 if not callable (connection_attr ):
5757 return connection_attr
5858
@@ -61,7 +61,7 @@ def inner(*args, **kwargs):
6161 try :
6262 func (* args , ** kwargs )
6363 except (Neo4jError , ServiceUnavailable , SessionExpired ) as exc :
64- self ._on_error (exc )
64+ self .on_error (exc )
6565 raise
6666 return inner
6767
@@ -83,7 +83,7 @@ def __init__(self, connection, hydrant, fetch_size, on_closed,
8383 self ._record_buffer = deque ()
8484 self ._summary = None
8585 self ._bookmark = None
86- self ._qid = - 1
86+ self ._raw_qid = - 1
8787 self ._fetch_size = fetch_size
8888
8989 # states
@@ -96,6 +96,13 @@ def __init__(self, connection, hydrant, fetch_size, on_closed,
9696 # the result has been fully iterated or consumed
9797 self ._closed = False
9898
99+ @property
100+ def _qid (self ):
101+ if self ._raw_qid == self ._connection .connection .most_recent_qid :
102+ return - 1
103+ else :
104+ return self ._raw_qid
105+
99106 def _tx_ready_run (self , query , parameters , ** kwparameters ):
100107 # BEGIN+RUN does not carry any extra on the RUN message.
101108 # BEGIN {extra}
@@ -117,7 +124,10 @@ def _run(self, query, parameters, db, access_mode, bookmarks, **kwparameters):
117124
118125 def on_attached (metadata ):
119126 self ._metadata .update (metadata )
120- self ._qid = metadata .get ("qid" , - 1 ) # For auto-commit there is no qid and Bolt 3 do not support qid
127+ # For auto-commit there is no qid and Bolt 3 does not support qid
128+ self ._raw_qid = metadata .get ("qid" , - 1 )
129+ if self ._raw_qid != - 1 :
130+ self ._connection .connection .most_recent_qid = self ._raw_qid
121131 self ._keys = metadata .get ("fields" )
122132 self ._attached = True
123133
0 commit comments