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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog.
- `connection_acquisition_timeout` configuration option
- `ValueError` on invalid values (instead of `ClientError`)
- Consistently restrict the value to be strictly positive
- `TypeError` instead of `ValueError` when passing a `Query` object to `Transaction.run`.
- `TransactionError` (subclass of `DriverError`) instead of `ClientError` (subclass of `Neo4jError`) when calling
`session.run()` while an explicit transaction is active on that session.
- This improves the differentiation between `DriverError` for client-side errors and `Neo4jError` for server-side
Expand Down
3 changes: 1 addition & 2 deletions src/neo4j/_async/work/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ async def run(
:returns: a new :class:`neo4j.AsyncResult` object
"""
if isinstance(query, Query):
# TODO: 6.0 - make this a TypeError and remove lint exception
raise ValueError("Query object is only supported for session.run") # noqa: TRY004
raise TypeError("Query object is only supported for session.run")

if self._closed_flag:
raise TransactionError(self, "Transaction closed")
Expand Down
3 changes: 1 addition & 2 deletions src/neo4j/_sync/work/transaction.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/unit/async_/work/test_transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def test_transaction_run_takes_no_query_object(async_fake_connection):
tx = AsyncTransaction(
async_fake_connection, 2, None, on_closed, on_error, on_cancel, None
)
with pytest.raises(ValueError):
with pytest.raises(TypeError):
await tx.run(Query("RETURN 1"))


Expand Down
2 changes: 1 addition & 1 deletion tests/unit/sync/work/test_transaction.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.