Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions tests/stub/iteration/scripts/v4x0/tx_pull_1_nested.script
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ A: HELLO {"{}": "*"}
C: BEGIN {}
S: SUCCESS {}
C: RUN "CYPHER" {} {}
PULL {"n": 1}
S: SUCCESS {"fields": ["x"], "qid": 1}
RECORD ["1_1"]
C: PULL {"n": 1, "[qid]": 1}
S: RECORD ["1_1"]
SUCCESS {"has_more": true}
C: RUN "CYPHER" {} {}
PULL {"n": 1}
S: SUCCESS {"fields": ["x"], "qid": 2}
RECORD ["2_1"]
C: PULL {"n": 1, "[qid]": 2}
S: RECORD ["2_1"]
SUCCESS {"has_more": true}
C: PULL {"n": 1, "qid": 2}
C: PULL {"n": 1, "[qid]": 2}
S: RECORD ["2_2"]
SUCCESS {}
C: PULL {"n": 1, "qid": 1}
S: RECORD ["1_2"]
SUCCESS {}
C: RUN "CYPHER" {} {}
PULL {"n": 1}
S: SUCCESS {"fields": ["x"], "qid": 3}
RECORD ["3_1"]
C: PULL {"n": 1, "[qid]": 3}
S: RECORD ["3_1"]
SUCCESS {}
C: COMMIT
S: SUCCESS {"bookmark": "bm"}
Expand Down
2 changes: 1 addition & 1 deletion tests/stub/iteration/scripts/v4x0/tx_pull_2.script
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ C: PULL {"n": 2, "[qid]": 7}
S: RECORD [1]
RECORD [2]
SUCCESS {"has_more": true}
C: PULL {"n": 2, "qid": 7}
C: PULL {"n": 2, "[qid]": 7}
S: RECORD [3]
SUCCESS {}
C: COMMIT
Expand Down
27 changes: 22 additions & 5 deletions tests/stub/optimizations/scripts/v4x3/all_default.script
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,21 @@ S: SUCCESS {"server": "Neo4j/4.3.0", "connection_id": "example-connection-id:1"}
C: BEGIN {}
S: SUCCESS {}
C: RUN "*" {} {}
S: SUCCESS {"fields": ["1"]}
S: SUCCESS {"fields": ["1"], "qid": 1}
{{
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
{{
C: PULL {"n": "*"}
S: RECORD [1]
----
# Drivers that pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
----
C: DISCARD {}
# Drivers that don't pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
S: SUCCESS {}
C: COMMIT
Expand All @@ -25,11 +34,19 @@ S: SUCCESS {"server": "Neo4j/4.3.0", "connection_id": "example-connection-id:1"}
{{
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
{{
C: PULL {"n": "*"}
S: RECORD [1]
----
# Drivers that pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
----
C: DISCARD {}
# Drivers that don't pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
S: RECORD [1]
SUCCESS {"type": "w", "bookmark": "bookmark:1"}
S: SUCCESS {"type": "w", "bookmark": "bookmark:1"}
}}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
!: BOLT 4.3

C: HELLO {"user_agent": "*", "scheme": "basic", "principal": "*", "credentials": "*"}
S: SUCCESS {"server": "Neo4j/4.3.0", "connection_id": "example-connection-id:1"}
*: RESET
C: BEGIN {}
S: SUCCESS {}
C: RUN "*" {} {}
S: SUCCESS {"fields": ["1"], "qid": 1}
{{
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
{{
C: PULL {"n": "*"}
S: RECORD [1]
----
# Drivers that pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
----
# Drivers that don't pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
S: SUCCESS {}
C: RUN "*" {} {}
S: SUCCESS {"fields": ["2"], "qid": 2}
{{
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
{{
C: PULL {"n": "*"}
S: RECORD [1]
----
# Drivers that pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
----
# Drivers that don't pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
S: SUCCESS {}
C: COMMIT
S: SUCCESS {"type": "w", "bookmark": "bookmark:1"}
*: RESET
?: GOODBYE
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
!: BOLT 4.3

C: HELLO {"user_agent": "*", "scheme": "basic", "principal": "*", "credentials": "*"}
S: SUCCESS {"server": "Neo4j/4.3.0", "connection_id": "example-connection-id:1"}
*: RESET
C: BEGIN {}
S: SUCCESS {}
C: RUN "*" {} {}
S: SUCCESS {"fields": ["1"], "qid": 1}
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
{?
# Eager drivers might pull a record in advance
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
?}
C: RUN "*" {} {}
S: SUCCESS {"fields": ["2"], "qid": 2}
{{
C: PULL {"n": "*"}
S: RECORD [1]
SUCCESS {"has_more": true}
{{
C: PULL {"n": "*"}
S: RECORD [1]
----
# Drivers that pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
----
# Drivers that don't pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*"}
}}
S: SUCCESS {}
{{
C: PULL {"n": "*", "qid": 1}
S: RECORD [1]
----
# Drivers that pipeline a PULL will takes this path in the discarding tests
C: DISCARD {"n": "*", "qid": 1}
}}
S: SUCCESS {}
C: COMMIT
S: SUCCESS {"type": "w", "bookmark": "bookmark:1"}
*: RESET
?: GOODBYE
77 changes: 77 additions & 0 deletions tests/stub/optimizations/test_optimizations.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,15 @@ def test():
res.consume()
else:
res.next()
res.next()
tx.commit()
else:
res = session.run("CYPHER")
if consume:
res.consume()
else:
res.next()
res.next()

session.close()
driver.close()
Expand All @@ -282,3 +284,78 @@ def test():
test()
self._server.reset()
self._router.reset()

@driver_feature(types.Feature.OPT_IMPLICIT_DEFAULT_ARGUMENTS)
def test_uses_implicit_default_arguments_multi_query(self):
def test():
self._server.start(path=self.script_path(
"v4x3", "all_default_multi_query.script"
))
auth = types.AuthorizationToken(scheme="basic", principal="neo4j",
credentials="pass")
driver = Driver(self._backend, "bolt://%s" % self._server.address,
auth)
session = driver.session("w") # write is default
tx = session.beginTransaction()
res = tx.run("CYPHER")
if consume1:
res.consume()
else:
res.next()
res.next()
res = tx.run("CYPHER")
if consume2:
res.consume()
else:
res.next()
res.next()
tx.commit()

session.close()
driver.close()
self._server.done()

for consume1 in (True, False):
for consume2 in (True, False):
with self.subTest(("discard1" if consume1 else "pull1")
+ ("_discard2" if consume2 else "_pull2")):
test()
self._server.reset()
self._router.reset()

@driver_feature(types.Feature.OPT_IMPLICIT_DEFAULT_ARGUMENTS)
def test_uses_implicit_default_arguments_multi_query_nested(self):
def test():
self._server.start(path=self.script_path(
"v4x3", "all_default_multi_query_nested.script"
))
auth = types.AuthorizationToken(scheme="basic", principal="neo4j",
credentials="pass")
driver = Driver(self._backend, "bolt://%s" % self._server.address,
auth)
session = driver.session("w") # write is default
tx = session.beginTransaction()
res1 = tx.run("CYPHER")
res1.next()
res2 = tx.run("CYPHER")
if consume2:
res2.consume()
else:
res2.next()
res2.next()
if consume1:
res1.consume()
else:
res1.next()
tx.commit()

session.close()
driver.close()
self._server.done()

for consume1 in (True, False):
for consume2 in (True, False):
with self.subTest(("discard1" if consume1 else "pull1")
+ ("_discard2" if consume2 else "_pull2")):
test()
self._server.reset()