Skip to content

Commit f4599fd

Browse files
committed
Deprecate bolt URI with routing context
Amend neo4j#645 to emit a deprecation warning instead of raising. Starting with 6.0 this will be turned into an error.
1 parent 342a9f5 commit f4599fd

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
Use `hour_minute_second_nanosecond` instead.
5050
- The property `second` returns an `int` instead of a `float`.
5151
Use `nanosecond` to get the sub-second information.
52-
- Creation of a driver with `bolt[+s[sc]]://` scheme now raises an error if the
53-
URI contains a query part (a routing context). Previously, the routing context
54-
was silently ignored.
52+
- Creation of a driver with `bolt[+s[sc]]://` scheme has been deprecated and
53+
will raise an error in the Future. The routing context was and will be
54+
silently ignored until then.
5555
- `Result.single` now raises `ResultNotSingleError` if not exactly one result is
5656
available.
5757
- Bookmarks

neo4j/_async/driver.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,17 @@ def driver(cls, uri, *, auth=None, **config):
9494

9595
if driver_type == DRIVER_BOLT:
9696
if parse_routing_context(parsed.query):
97-
raise ValueError(
98-
'Routing parameters are not supported with scheme "bolt". '
99-
'Given URI "{}".'.format(uri)
97+
deprecation_warn(
98+
"Creating a direct driver (`bolt://` scheme) with routing "
99+
"context (URI parameters) is deprecated. They will be "
100+
"ignored. This will raise an error in a future release. "
101+
'Given URI "{}"'.format(uri)
100102
)
103+
# TODO: 6.0 - raise instead of warning
104+
# raise ValueError(
105+
# 'Routing parameters are not supported with scheme '
106+
# '"bolt". Given URI "{}".'.format(uri)
107+
# )
101108
return cls.bolt_driver(parsed.netloc, auth=auth, **config)
102109
elif driver_type == DRIVER_NEO4j:
103110
routing_context = parse_routing_context(parsed.query)

neo4j/_sync/driver.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,17 @@ def driver(cls, uri, *, auth=None, **config):
9494

9595
if driver_type == DRIVER_BOLT:
9696
if parse_routing_context(parsed.query):
97-
raise ValueError(
98-
'Routing parameters are not supported with scheme "bolt". '
99-
'Given URI "{}".'.format(uri)
97+
deprecation_warn(
98+
"Creating a direct driver (`bolt://` scheme) with routing "
99+
"context (URI parameters) is deprecated. They will be "
100+
"ignored. This will raise an error in a future release. "
101+
'Given URI "{}"'.format(uri)
100102
)
103+
# TODO: 6.0 - raise instead of warning
104+
# raise ValueError(
105+
# 'Routing parameters are not supported with scheme '
106+
# '"bolt". Given URI "{}".'.format(uri)
107+
# )
101108
return cls.bolt_driver(parsed.netloc, auth=auth, **config)
102109
elif driver_type == DRIVER_NEO4j:
103110
routing_context = parse_routing_context(parsed.query)

0 commit comments

Comments
 (0)