-
Notifications
You must be signed in to change notification settings - Fork 204
5.x Changelog
🔧 Fixes
- Fix metadata, e.g.,
__qualname__, of internally forwarded methods ofTransactionandAsyncTransaction(#1017).
📚 Docs
- Fix broken cross references in the API docs (#1021).
- Advertise Rust extensions in the README for a performance improvement (#1023).
See also https://github.com/neo4j-drivers/neo4j-python-driver-rust-ext.
🔧 Fixes
- Fix
from neo4j import *statement (#1009).
📚 Docs
- Improve API documentation of result streams (#1010).
⭐ New Features
- New driver config option
liveness_check_timeout(#992). - Enable/fix (deep)copying and pickling support for custom temporal and spatial types (#1002).
Thanks to @Sopalinge for this contribution.
👏 Improvements
- Implemented a hierarchical logger structure to improve log source identification and traceability (#997).
Thanks to @OliverFarren for this contribution.
Introduced child loggers:-
neo4j.io: For socket and bolt protocol related logging. -
neo4j.pool: For logs pertaining to connection pooling and routing. -
neo4j.auth_management: For logging inside the providedAuthManagerimplementations.
-
🔧 Fixes
- Fix exporting
Durations withResult.dataresulting inTypeError: unsupported operand type(s) for *: 'int' and 'map'(#1000).
Also: 1000th PR 🎂 - Also cover
Session.last_bookmarkswith the optional concurrency misuse checks introduced in version 5.15.0 (#1004). - Harden the driver against unexpected server responses following
RESET(#1006).
Under certain circumstances, can the server respond withFAILUREand evenIGNOREDwhen the driver attempts toRESETa failed connection. It's arguable whether it should, but the driver needs to handle to it, let alone to be compatible with older server versions. The driver did not handle this situation gracefully and could even get stuck in an infinite loop. Instead, it will now close such connections and raise the original error the connection failed with.
📚 Docs
- Fix signature of
Driver.execute_query(#998). - Fix wrong
awaitin async API docs (#1003). - Fix wrong minimum required server version for some notification filters (#1007).
⭐ New Features
-
Driver.execute_querynow accepts aQueryobject to specify transaction config like metadata and transaction timeout (#991). - For local development, run your application with
python -X dev ...or set the environment variablePYTHONNEO4JDEBUGto anything non-empty to get additional concurrency misuse checks. Some driver primitives (e.g., sessions) are not safe to be used concurrently. By default, using them concurrently will lead to hard to debug errors. This feature helps to identify such code paths. Note that detection is still inherently racy, hence not guaranteed to always work (#989, 995).
👏 Improvements
- Materialize experimental Rust extension in bolt-agent and user-agent string (#993).
🔧 Fixes
- Fix trying to await socket closure on async cancellation during initial connection (#987).
🧹Clean-up
⚠️ Deprecated passing multiple targets to the undocumented methodGraphDatabase.neo4j_driver(#986).
🌱 Groundwork
- Prepare the driver to pick up Rust extensions for a better performing PackStream implementation (#979).
This change is 100% transparent and doesn't affect the operation of the driver unless the user takes extra steps to install Rust extensions separately.
⭐ New Features
🔧 Fixes
- Properly propagate errors across results within a transaction (#973).
If any record stream fails, the transaction as a whole, including all other results, cannot be recovered. A new errorResultFailedErroris introduced to signal this condition.
📚 Docs
- Migrated API Docs layout to corporate design (#968).
🌳 Maturing
- Stabilize the re-authentication feature from preview (#977).
⭐ New Features
- Support for bolt protocol 5.4 (#965).
Starting with Bolt 5.4, the driver will, by default, send anonymous API usage statistics to the server if requested. Please see the linked pull request for more details like how to opt-out.
🔧 Fixes
- Fix suppression of warnings inside the driver. This is now concurrency-safe (#961).
⚠️ Usingneo4j.Driver/neo4j.AsyncDriverobjects after calling.close()on them, except for calling.close()again, is deprecated and will throw an Exception in a future version (#962, #964).
📚 Docs
- Improve typing information in the API docs (#963).
- Improve API docs around transaction timeouts (#966, #970).
🌳 Maturing
- The driver configuration option
keep_aliveto control the TCP keep alive option on the sockets is no longer marked experimental (#967).
👏 Improvements
-
driver.execute_queryis now more efficient by saving a round trip (#956). ⚠️ Changes were made to the re-auth feature in preview (#957, (8b35bd86)):- Removed
TokenExpiredRetryableexception.
Even though it wasn't marked preview, it was introduced with and only used for re-auth. It no longer serves any purpose. - The
AuthManagerandAsyncAuthManagerabstract classes were changed.
The methodon_auth_expired(self, auth: _TAuth) -> Nonewas removed in favor ofhandle_security_exception(self, auth: _TAuth, error: Neo4jError) -> bool.
See the API docs for more details. - The factories in
AsyncAuthManagersandAuthManagerswere changed.-
expiration_basedwas renamed tobearer. -
basicwas added to cater for password rotation.
-
- Removed
🔧 Fixes
- Fix potential datarace when handling routing tables (#952).
- Fix pool closing connections too aggressively. In autonomous clustering scenarios where a given database might not be present on all cluster members, the driver could've closed all connections to such members even if they were still useful for other databases (#955).
- Fix driver dropping write servers from the routing table too aggressively (#959).
🔧 Fixes
- Fix handling of sub-ms transaction timeouts (#940).
- Due to the timeout being
floatrounding issues were possible (e.g.,256.4 swould be turned into256399 ms). -
0.001 s > timeout > 0was rounded down to0 mswhich is a special value for no timeout at all. This is very likely not what the user intended.
- Due to the timeout being
- Avoid lazy imports to reduce chances of errors during interpreter shutdown (#942).
- Avoid swallowing errors coming from
asyncio.Lock.acquire(#944). - Fix
neo4j.debug.watch()not handling logging levels correctly when being called multiple times (#946).
📚 Docs
- Improve API docs around
ExpiringAuth(#934). - Remove old migration information, fix and update links, update getting started example to use the new and shorter
driver.execute_queryAPI introduced in 5.5.0 and stabilized in 5.8.0 (#929). - Small formatting fixed (#938).
- Fix wrongly documented type of
query_parameter ofdriver.execute_query(#939).
⭐ New Features
- Support for bolt protocol 5.3 which adds
bolt_agentmetadata so that the server knows which driver is connecting (#910). ⚠️ neo4j.auth_management.ExpiringAuthused for auth rotation (re-auth, preview feature) now expects an absolute expiration time. A convenience method to create it with a relative expiration time added (#928).
The attributeexpires_inwas replaced byexpires_at, which now expects a unix timestamp.
You can useExpiringAuth(some_auth).expires_in(123)instead if you rely on relative expiration.
📚 Docs
- Mention performance impact of notification filtering (#931).
🧹Clean-up
- Align spacing of log message (#926).
🔧 Fixes
- Make
neo4j.auth_management.ExpiringAuth(in preview) a class instead of a function caused by an incorrect preview decorator (#927).
📚 Docs
- Fix broken formatting and missing parts caused by an incorrect preview decorator (#927).
- Fix broken cross references in the API docs that were missed when renaming experimental APIs in #911 (#927).
⭐ New Features
- Re-authentication (in preview) (#890).
Allows for handling expiring authentication (backwards compatible) as well as session scoped authentication (requires neo4j server version 5.5+).
We are actively looking for feedback: https://github.com/neo4j/neo4j-python-driver/discussions/921
👏 Improvements
- Implement serialization of temporal types with python's standard
datetime.timezone(fixed utc-offset timezones) astzinfo(#914). - The above change enables
panadas2 support (#914).
📚 Docs
🌳 Maturing
- Bookmark managers (
BookmarkManagerclass,bookmark_managerconfig options,Driver.bookmark_manager()factory method) (#911). -
Driver.execute_queryAPI with some minor changes (#911):⚠️ Renameneo4j.RoutingControl.WRITERStoneo4j.RoutingControl.WRITEand...READERSto...READ⚠️ Renamedriver.query_bookmark_manager()todriver.execute_query_bookmark_manager().- The query argument is now typed
LiteralStringinstead ofstrto help mitigate accidental Cypher injections. There are rare use-cases where a computed string is necessary. Please use# type: ignore, ortyping.castto suppress the type checking in those cases (#923).
⭐ New Features
- Notification filtering API (#847).
This introduces two new optionsnotifications_min_severityandnotifications_disabled_categoriesto the driver and session config. Both require neo4j server version 5.7+.
🔧 Fixes
- Fix application protocol (bolt) handshake not having a timeout (#905).
🧹Clean-up
⚠️ Importingneo4j.workand its submodules has been deprecated. Everything should be imported directly fromneo4jinstead.
📚 Docs
⭐ New Features
- Experimental
Driver.execute_queryAPI (#833).
We are actively looking for feedback: https://github.com/neo4j/neo4j-python-driver/discussions/896
⭐ New Features
- Supporting more types as query parameters (e.g.,
tuple, some pandas and numpy types, see also API docs) (#881).
🔧 Fixes
- Fix not handling async cancellation during
Driver.closeproperly (#881).
👏 Improvements
- Update custom async synchronization primitives to be based on Python 3.11's implementation. This will, among other things, avoid hard to debug errors later in the program when accidentally creating the driver while no event loop is (see #868) (#879).
- More server errors will be surfaced directly on failed routing discovery. Those used to be masked as
ServiceUnavailableerrors hiding driver misconfiguration as the real cause (#870). Specifically:-
Neo.ClientError.Statement.TypeError, e.g., when trying to impersonate an integer or any type other thanNoneorstr. -
Neo.ClientError.Statement.ArgumentError, e.g., when trying to impersonate without the required permissions. -
Neo.ClientError.Request.Invalid, e.g., when trying to select an integer database or any type other thanNoneorstr.
-
📚 Docs
🧹Clean-up
⚠️ Undocumented helper methodsNeo4jError.is_fatal_during_discoveryandNeo4jError.invalidates_all_connectionshave been deprecated and will be removed without replacement in version 6.0 (#870).
⭐ New Features
- Add Support for Python 3.11 (#861).
🔧 Fixes
⚠️ The experimentalBookmarkManagerAPI received a necessary change that simplifies it and makes it work correctly (#859).
It will no longer track bookmarks per database. This effectively changes the signature of almost all bookmark manager related methods:-
neo4j.BookmarkMangerandneo4j.AsyncBookmarkMangerabstract base classes:-
update_bookmarkshas no longer adatabaseargument. -
get_bookmarkshas no longer adatabaseargument. - The
get_all_bookmarksmethod was removed. - The
forgetmethod was removed.
-
-
neo4j.GraphDatabase.bookmark_managerandneo4j.AsyncGraphDatabase.bookmark_managerfactory methods:-
initial_bookmarksis no longer a mapping from database name to bookmarks but plain bookmarks. -
bookmarks_supplierno longer receives the database name as an argument. -
bookmarks_consumerno longer receives the database name as an argument.
-
-
👏 Improvements
- Modernize packaging to use
pyproject.toml, fixing deprecation warningDEPRECATION: neo4j is being installed using the legacy 'setup.py install' method[...]when installed withpip(#867). - Improve exception context for some exceptions (#860).
- Query strings are now typed
LiteralStringinstead ofstrto help mitigate accidental Cypher injections. There are rare use-cases where a computed string is necessary. Please use# type: ignore, ortyping.castto suppress the type checking in those cases (#861).
🧹Clean-up
⚠️ Deprecated package-aliasneo4j-driver. It will stop receiving updates starting with6.0.0. Please installneo4jinstead (#867).- Removed testing code (
testkitbackend) from distributed package (#855 thanks to @thesamesam, #867).
📚 Docs
- Expand API docs to fully state the implications of not specifying a
databaseparameters when creating a session(#865). - Multiple small improvements throughout the API docs (#858).
🔧 Fixes
- Data race in the routing driver that could lead to a
KeyError(#852). - Package
py.typedmarker file so that mypy and other type checkers consider the type annotations that were added to the driver in5.0(#856).
👏 Improvements
- Major improvements of the driver's debug logging (#849).
- Implemented
__format__for temporal types enabling expressions likef"{neo4j.time.Time(12, 34, 56, 789123001):%H:%M:%S.%f}"(#853). - Made the driver compatible with
mypyversion0.990(#854).
📚 Docs
🔧 Fixes
- Fix missing rewrite of driver internal error
neo4j._exceptions.SocketDeadlineExceeded: timed out(#842).
👏 Improvements
- Keyword parameters of
Session.runandTransaction.runare no longer restricted by parameters used in driver internal functions further down the stack (#835).
📚 Docs
- Editorial changes (#844 and 839).
- Remove documentation of driver configuration options (
session_connection_timeoutandupdate_routing_table_timeout) that were already removed in5.0.0(#838). - Clarification of the
timeoutparameter tounit_of_work(#827). - Clarify precedence of
parametersand keyword parameters ofSession.runandTransaction.run(#835).
🔧 Fixes
- Fix optional dependencies (pandas) in packaging (#808).
- [Python 3.10+] Fix deprecation warnings from using deprecated SSL options (#809).
📚 Docs
- Fixed many mistakes in the docs (API docs and docstrings) (#807 thanks to @112358fn, 30ccd1ca, #815, #818, #819, #821, #821, #822, #823).
🔧 Fixes
- Fix connection pool clogging up when checking if new connections can be created while the pool is full (#804; fixes #796).
The bug was introduced in 5.0.0 with #745. - Fix string representation of
neo4j.exceptions.ClientErrorandneo4j.exceptions.Neo4jErrorwhen raised from the driver code (806).
👏 Improvements
- Properly close sockets on async cancellation during
HELLOhandshakes. This resolves aResourceWarningthat otherwise would be emitted when the garbage collection cleans up the socket (#801).
🔧 Fixes
- Fix relying on garbage collector to close sockets under certain failure conditions (#795).
🧹Clean-up
⚠️ Removedignore_bookmark_managersession config option. It's a leftover from a previous design of the bookmark manager and was introduced in 5.0.0a2 (#792).
This release contains all fixes up until version 4.4.6 plus:
⭐ New Features
- Support for Bolt protocol version
5.0(#672, #737).⚠️ Deprecated Nodes' and Relationships'idproperty (int) in favor ofelement_id(str).
This also affectsGraphobjects as indexinggraph.nodes[...]andgraph.relationships[...]with integers has been deprecated in favor of indexing them with strings.- Fixed encoding of
DateTimes with zone id (#748).
- Added type hints for all public APIs (#767).
- Added
BookmarkManagersupport (#771).
This feature makes it easier to achieve causal chaining of sessions. See the API documentation for more details. - New
SSLconfig options (#639, #656, #666)⚠️ Thetrustoption has been deprecated.
Usetrusted_certificatesinstead. See the API documentation for more details.- New options
trusted_certificatesandssl_contexthave been added (see API docs for more details).
-
ResultAPI-
Result.singlehas a new optional argumentstrict(#646, #673).
IfstrictisTrueand the result set contains not exactly one record, an exception will be raised. - Added
Result.fetch(n)to fetch up tonrecords as a list (#673). -
Resultobjects are now iterators (i.e.next(result)/result.__next__()is supported) (#647).
result.__anext__()forAsyncResultrespectively.
-
- Added
Driver.get_server_info()(#654). - Added
.is_retryable()toNeo4jErrorandDriverError(#682, #742).
⚠️ Deprecatedneo4j.exceptions.Neo4jError.is_retriable()in favor ofneo4j.exceptions.Neo4jError.is_retryable().
This change helps users to implement custom retry policies together with explicit transactions. - Added
expandandparse_datesparameters toResult.to_df()(Pandas DataFrame export) (#663, #716).
🔧 Fixes
- Allow sending a transaction timeout of
0(#642).
Previously,0was interpreted asNoneand thus the server-side default timeout was used. Now,0denotes an infinite timeout. - Bookmarks (#649)
⚠️ Session.last_bookmarkwas deprecated. Its behaviour is partially incorrect and cannot be fixed without breaking its signature.
UseSession.last_bookmarksinstead.-
neo4j.Bookmarkwas deprecated.
Useneo4j.Bookmarksinstead.
- Many async fixes:
- Fix custom implementation of
AsyncCondition(#638). -
asyncio.iscoroutinefunctionwasNonein destructor (#643). - Add missing
awaitinSession.being_transaction(423e1e5). - Await and fix async socket closure (#701, #705).
- Handle
asyncio.CancelledErrorgracefully (#761). - Patch
asyncio.wait_forto no swallow cancellations (#761).
- Fix custom implementation of
- Fix sync socket close helper method (#777).
⚠️ Removed deprecated parts in theneo4j.timemodule (#635).-
Duration- The constructor does not accept
subsecondsanymore.
Usemilliseconds,microseconds, ornanosecondsinstead. - The property
subsecondshas been removed.
Usenanosecondsinstead. - The property
hours_minutes_secondshas been removed.
Usehours_minutes_seconds_nanosecondsinstead. - For all math operations holds: they are element-wise on
(
months,days,nanoseconds). This affects (i.e., changes) the working of//,%,/, and*.- Years are equal to 12 months.
- Weeks are equal to 7 days.
-
seconds,milliseconds,microseconds, andnanosecondsare implicitly converted tonanosecondsorsecondsas fit.
- Multiplication and division allow for floats but will always result in integer values (round to nearest even).
- The constructor does not accept
-
Time- The constructor does not accept
floats forsecondanymore.
Usenanosecondinstead. - Ticks are now nanoseconds since midnight (
int).- The property
ticks_nshas been renamed toticks.
The oldticksis no longer supported. - The property
from_ticks_nshas been renamed tofrom_ticks.
The oldfrom_ticksis no longer supported.
- The property
- The property
secondreturns anintinstead of afloat.
Usenanosecondto get the sub-second information. - The property
hour_minute_secondhas been removed.
Usehour_minute_second_nanosecondinstead.
- The constructor does not accept
-
DateTime- The property
hour_minute_secondhas been removed.
Usehour_minute_second_nanosecondinstead. - The property
secondreturns anintinstead of afloat.
Usenanosecondto get the sub-second information.
- The property
-
👏 Improvements
- Speed up by caching the local port number of connections (#724).
- Raise
ResultConsumedErrorwhen result is out of scope (#652):- Records of Results cannot be accessed (
peek,single,iter, ...) after their owning transaction has been closed, committed, or rolled back.
Previously, this would yield undefined behavior. It now raises aResultConsumedError. - Records of Results cannot be accessed (
peek,single,iter, ...) after the Result has been consumed (Result.consume()).
Previously, this would always yield no records. It now raises aResultConsumedError. - New method
Result.closed()can be used to check for this condition if necessary.
- Records of Results cannot be accessed (
- Improved output of logging helper
neo4j.debug.watch(#728, #755).- ANSI colour codes for log output are now opt-in.
- Prepend log format with log-level (if colours are disabled).
- Prepend log format with thread name and id.
- Change the transaction class passed to transaction functions (a.k.a. managed transactions) (#658):
The first argument of transaction functions is now aManagedTransactionobject. It behaves exactly like a regularTransactionobject, except it does not offer thecommit,rollback,close, andclosedmethods.
Those methods would have caused a hard to interpreted error previously. Hence, they have been removed. ⚠️ Certain deserialization errors (e.g., receiving a DateTime with an unsupported time zone) will no longer raise when receiving them but when trying to access them through theRecord(#759).neo4j.exceptions.BrokenRecordErrorhas been introduced to indicate this.
🧹Clean-up
⚠️ Removed deprecatedResultSummary.server.version_info(#636).
UseResultSummary.server.agent,ResultSummary.server.protocol_version, or call thedbms.componentsprocedure instead.⚠️ Deprecate implicit closing of drivers and sessions in__del__(destructor) (#653). This behaviour is non-deterministic as there is no guarantee that the destructor will ever be called. AResourceWarningis emitted instead.
Make sure to configure Python to output those warnings when developing your application locally (it does not by default).⚠️ Removed deprecated (since 4.4.6) timeout config options introduced in 4.4.5 (#769).
Server-side keep-alives communicated through configuration hints together withconnection_acquisition_timeoutare sufficient to avoid the driver getting stuck.- Creation of a driver with
bolt[+s[sc]]://scheme and a routing context has been deprecated and will raise an error in the Future. (#645, 655).
Previously, the routing context was silently ignored. ⚠️ Removed undocumented return value ofDriver.verify_connectivity()(#654, #743).
UseDriver.get_server_info()instead.⚠️ Package structure/imports (#748)- Importing submodules from
neo4j.time(neo4j.time.xyz) has been deprecated. Everything needed should be imported fromneo4j.timedirectly. -
neo4j.spatial.hydrate_pointandneo4j.spatial.dehydrate_pointhave been deprecated without replacement. They are internal functions. - Importing
neo4j.packstreamhas been deprecated. It's internal and should not be used by client code. - Importing
neo4j.routinghas been deprecated. It's internal and should not be used by client code. - Importing
neo4j.confighas been deprecated. It's internal and should not be used by client code. -
neoj4.Config,neoj4.PoolConfig,neoj4.SessionConfig, andneoj4.WorkspaceConfighave been deprecated without replacement. They are internal classes. - Importing
neo4j.metahas been deprecated. It's internal and should not be used by client code.ExperimantalWarningshould be imported directly fromneo4j.neo4j.meta.versionis exposed throughneo4j.__vesrion__ - Importing
neo4j.datahas been deprecated. It's internal and should not be used by client code.Recordshould be imported directly fromneo4jinstead.neo4j.data.DataHydratorandneo4j.data.DataDeydratorhave been removed without replacement.
- Importing submodules from
🌳 Maturing
- The async driver (
neo4j.AsyncGraphDatabase) is no longer experimental (#783). -
Result.to_df()(Pandas DataFrame export) is no longer experimental (#787).
IMPORTANT: this pre-release does not contain any 5.0 features and future pre-releases might have to be API-breaking. This release' sole purpose it to give early access to the async driver.
📚 Note on Documentation
You can find the preliminary API documentation here https://neo4j.com/docs/api/python-driver/5.0/
Note, that the compatible server versions are listed for the stable 5.0.x driver. The 5.0.0a1 driver supports the same server versions as 4.4.x drivers.
⭐ New Features
🧹Clean-up