Skip to content

Commit e997b1d

Browse files
committed
Cursor no longer indexable
1 parent 39acd5c commit e997b1d

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed

examples/test_examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ def test_transaction_commit(self):
157157
tx.commit()
158158
# end::transaction-commit[]
159159
result = session.run("MATCH (p:Person {name: 'Guinevere'}) RETURN count(p)")
160-
next(result)
161-
assert result["count(p)"] == 1
160+
record = next(result)
161+
assert record["count(p)"] == 1
162162
assert result.at_end
163163
session.close()
164164

@@ -171,8 +171,8 @@ def test_transaction_rollback(self):
171171
tx.rollback()
172172
# end::transaction-rollback[]
173173
result = session.run("MATCH (p:Person {name: 'Merlin'}) RETURN count(p)")
174-
next(result)
175-
assert result["count(p)"] == 0
174+
record = next(result)
175+
assert record["count(p)"] == 0
176176
assert result.at_end
177177
session.close()
178178

neo4j/v1/session.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,6 @@ def __next__(self):
185185
def __iter__(self):
186186
return self
187187

188-
def __getitem__(self, item):
189-
current = self._current
190-
if current is None:
191-
raise TypeError("No current record")
192-
return current[item]
193-
194188
def is_open(self):
195189
""" Return ``True`` if this cursor is still open, ``False`` otherwise.
196190
"""

test/test_session.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ def test_automatic_reset_after_failure(self):
341341
session.run("X").close()
342342
except CypherError:
343343
result = session.run("RETURN 1")
344-
next(result)
345-
assert result[0] == 1
344+
record = next(result)
345+
assert record[0] == 1
346346
else:
347347
assert False, "A Cypher error should have occurred"
348348

@@ -435,8 +435,8 @@ def test_can_commit_transaction(self):
435435

436436
# Create a node
437437
result = tx.run("CREATE (a) RETURN id(a)")
438-
next(result)
439-
node_id = result[0]
438+
record = next(result)
439+
node_id = record[0]
440440
assert isinstance(node_id, int)
441441

442442
# Update a property
@@ -448,18 +448,18 @@ def test_can_commit_transaction(self):
448448
# Check the property value
449449
result = session.run("MATCH (a) WHERE id(a) = {n} "
450450
"RETURN a.foo", {"n": node_id})
451-
next(result)
452-
foo = result[0]
453-
assert foo == "bar"
451+
record = next(result)
452+
value = record[0]
453+
assert value == "bar"
454454

455455
def test_can_rollback_transaction(self):
456456
with GraphDatabase.driver("bolt://localhost", auth=auth_token).session() as session:
457457
tx = session.begin_transaction()
458458

459459
# Create a node
460460
result = tx.run("CREATE (a) RETURN id(a)")
461-
next(result)
462-
node_id = result[0]
461+
record = next(result)
462+
node_id = record[0]
463463
assert isinstance(node_id, int)
464464

465465
# Update a property
@@ -478,8 +478,8 @@ def test_can_commit_transaction_using_with_block(self):
478478
with session.begin_transaction() as tx:
479479
# Create a node
480480
result = tx.run("CREATE (a) RETURN id(a)")
481-
next(result)
482-
node_id = result[0]
481+
record = next(result)
482+
node_id = record[0]
483483
assert isinstance(node_id, int)
484484

485485
# Update a property
@@ -491,17 +491,17 @@ def test_can_commit_transaction_using_with_block(self):
491491
# Check the property value
492492
result = session.run("MATCH (a) WHERE id(a) = {n} "
493493
"RETURN a.foo", {"n": node_id})
494-
next(result)
495-
foo = result[0]
496-
assert foo == "bar"
494+
record = next(result)
495+
value = record[0]
496+
assert value == "bar"
497497

498498
def test_can_rollback_transaction_using_with_block(self):
499499
with GraphDatabase.driver("bolt://localhost", auth=auth_token).session() as session:
500500
with session.begin_transaction() as tx:
501501
# Create a node
502502
result = tx.run("CREATE (a) RETURN id(a)")
503-
next(result)
504-
node_id = result[0]
503+
record = next(result)
504+
node_id = record[0]
505505
assert isinstance(node_id, int)
506506

507507
# Update a property

0 commit comments

Comments
 (0)