fix(neo4j): route database_ to connection kwarg (#1481) - #1780
gauravch-code wants to merge 1 commit into
Conversation
Neo4jDriver.execute_query was placing `database_` inside `parameters_` (the Cypher variables dict) rather than passing it as a top-level kwarg on Neo4j's execute_query. As a result, `database_` was treated as an unused Cypher parameter and silently ignored, and every query routed to the connection's home database regardless of the `database` value passed to `Neo4jDriver(...)`. Route `database_` to the driver-level kwarg, while still honoring callers that historically passed it inside `params` for backwards compatibility. Add tests/driver/test_neo4j_driver.py with regression coverage: - Configured database is forwarded as a connection kwarg - Default database is used when none is configured - Explicit `database_` kwarg overrides the driver default - `database_` nested in `params` is promoted to the connection kwarg - Existing `routing_` and Cypher-parameter kwargs still pass through Include the new test file in the database-integration-tests job of unit_tests.yml alongside test_falkordb_driver.py. Closes getzep#1481
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: example@example.com or I have read the CLA Document and I hereby sign the CLA behalf of my company, e-mail: example@example.com Signature is valid for 6 months. This bot will be retriggered when the Contributor License Agreement comment has been provided. Posted by the CLA Assistant Lite bot. |
|
I have read the CLA Document and I hereby sign the CLA behalf on myself, e-mail: gaurav.pvt25@gmail.com |
|
Thanks for contributing to Graphiti and for diagnosing this. We’ve shipped the fix in graphiti-core v0.30.1 and MCP v1.1.0: Please note:
|
Summary
Fixes #1481.
Neo4jDriver.execute_querywas placingdatabase_insideparameters_(the Cypher variables dict) rather than passing it as a driver-level kwarg to Neo4j'sexecute_query. As a result,database_was treated as an unused Cypher parameter and silently ignored — every query routed to the connection's home database regardless of thedatabasevalue passed toNeo4jDriver(...). Only writes that went throughsession(database=...)explicitly (e.g.transaction()) hit the intended database.Fix
Route
database_to the driver-level kwarg onAsyncDriver.execute_query. Accept it from eitherparamsorkwargsfor backwards compatibility so callers that historically stuck it inparamskeep working.Tests
New
tests/driver/test_neo4j_driver.py— 7 tests, mock-only (no live Neo4j required):test_configured_database_is_passed_as_connection_kwarg— the core regression for [BUG] Database Parameter Not Honored in Neo4jDriver.execute_query() #1481test_default_database_is_used_when_none_configuredtest_explicit_database_kwarg_overrides_configured_defaulttest_database_nested_in_params_is_promoted_to_connection_kwarg— backwards compattest_routing_kwarg_is_forwarded_at_connection_leveltest_extra_kwargs_are_forwardedtest_providerAdded the new file to the
database-integration-testsjob in.github/workflows/unit_tests.yml, mirroring the existingtest_falkordb_driver.pyentry.Verified locally
ruff format+ruff check— cleanpyright graphiti_core/driver/neo4j_driver.py— 0 errors, 0 warningspytest tests/driver/test_falkordb_driver.py tests/driver/test_neo4j_driver.py— 32 passed, 1 skippedTest plan
main(assertsdatabase_is a top-level kwarg; observed{'parameters_': {'database_': 'mydb'}}on main)ruff+pyrightclean