diff --git a/CHANGELOG.md b/CHANGELOG.md index 468e9d777..6313f8015 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,7 +78,8 @@ See also https://github.com/neo4j/neo4j-python-driver/wiki for a full changelog. - `ERROR_REWRITE_MAP` - `client_errors` - `transient_errors` - +- Raise `ConfigurationError` instead of ignoring the routing context (URI query parameters) when creating a direct + driver ("bolt[+s[sc]]://" scheme). ## Version 5.28 - Since the types of `Relationship`s are tied to the `Graph` object they belong to, fixing `pickle` support for graph types means that `Relationship`s with the same name will have a different type after `deepcopy`ing or pickling and unpickling them or their graph. diff --git a/src/neo4j/_async/driver.py b/src/neo4j/_async/driver.py index 2b3ea25c3..386f66207 100644 --- a/src/neo4j/_async/driver.py +++ b/src/neo4j/_async/driver.py @@ -277,18 +277,11 @@ def driver( assert driver_type in {DRIVER_BOLT, DRIVER_NEO4J} if driver_type == DRIVER_BOLT: if parse_routing_context(parsed.query): - deprecation_warn( - 'Creating a direct driver ("bolt://" scheme) with ' - "routing context (URI parameters) is deprecated. They " - "will be ignored. This will raise an error in a " - f'future release. Given URI "{uri}"', - stack_level=2, + raise ConfigurationError( + "Routing context (URI query parameters) are not " + "supported by direct drivers " + f'("bolt[+s[sc]]://" scheme). Given URI: {uri!r}.' ) - # TODO: 6.0 - raise instead of warning - # raise ValueError( - # 'Routing parameters are not supported with scheme ' - # '"bolt". Given URI "{}".'.format(uri) - # ) return cls.bolt_driver(parsed.netloc, **config) # else driver_type == DRIVER_NEO4J routing_context = parse_routing_context(parsed.query) diff --git a/src/neo4j/_sync/driver.py b/src/neo4j/_sync/driver.py index 2ed3584e6..f42531d01 100644 --- a/src/neo4j/_sync/driver.py +++ b/src/neo4j/_sync/driver.py @@ -276,18 +276,11 @@ def driver( assert driver_type in {DRIVER_BOLT, DRIVER_NEO4J} if driver_type == DRIVER_BOLT: if parse_routing_context(parsed.query): - deprecation_warn( - 'Creating a direct driver ("bolt://" scheme) with ' - "routing context (URI parameters) is deprecated. They " - "will be ignored. This will raise an error in a " - f'future release. Given URI "{uri}"', - stack_level=2, + raise ConfigurationError( + "Routing context (URI query parameters) are not " + "supported by direct drivers " + f'("bolt[+s[sc]]://" scheme). Given URI: {uri!r}.' ) - # TODO: 6.0 - raise instead of warning - # raise ValueError( - # 'Routing parameters are not supported with scheme ' - # '"bolt". Given URI "{}".'.format(uri) - # ) return cls.bolt_driver(parsed.netloc, **config) # else driver_type == DRIVER_NEO4J routing_context = parse_routing_context(parsed.query) diff --git a/tests/unit/async_/test_driver.py b/tests/unit/async_/test_driver.py index 4e49bf818..55d5ad3a6 100644 --- a/tests/unit/async_/test_driver.py +++ b/tests/unit/async_/test_driver.py @@ -98,12 +98,12 @@ async def test_direct_driver_constructor( ): uri = protocol + host + port + params if params: - with pytest.warns(DeprecationWarning, match="routing context"): - driver = AsyncGraphDatabase.driver(uri, auth=auth_token) + with pytest.raises(ConfigurationError, match="Routing context"): + AsyncGraphDatabase.driver(uri, auth=auth_token) else: driver = AsyncGraphDatabase.driver(uri, auth=auth_token) - assert isinstance(driver, AsyncBoltDriver) - await driver.close() + await driver.close() + assert isinstance(driver, AsyncBoltDriver) @pytest.mark.parametrize( diff --git a/tests/unit/sync/test_driver.py b/tests/unit/sync/test_driver.py index 5ba0acd3f..768dfeee2 100644 --- a/tests/unit/sync/test_driver.py +++ b/tests/unit/sync/test_driver.py @@ -97,12 +97,12 @@ def test_direct_driver_constructor( ): uri = protocol + host + port + params if params: - with pytest.warns(DeprecationWarning, match="routing context"): - driver = GraphDatabase.driver(uri, auth=auth_token) + with pytest.raises(ConfigurationError, match="Routing context"): + GraphDatabase.driver(uri, auth=auth_token) else: driver = GraphDatabase.driver(uri, auth=auth_token) - assert isinstance(driver, BoltDriver) - driver.close() + driver.close() + assert isinstance(driver, BoltDriver) @pytest.mark.parametrize(