Skip to content

Commit 04a16af

Browse files
committed
Revert breaking change in summary.notification introduced in neo4j#1060
When introducing bolt 5.5 support for GQL statuses in the summary, the driver gained the ability to polyfill old-style notifications from the statuses. However, `ResultSummary.notifications` used to be `None` when the server didn't send any notifications. When using the polyfill, the field would be set to `[]` instead in the same scenario. This PR fixes this.
1 parent 36b8103 commit 04a16af

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/neo4j/_work/summary.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _notification_from_status(status: dict) -> dict:
175175

176176
return notification
177177

178-
def _set_notifications(self):
178+
def _set_notifications(self) -> None:
179179
if "notifications" in self.metadata:
180180
notifications = self.metadata["notifications"]
181181
if not isinstance(notifications, list):
@@ -197,7 +197,7 @@ def _set_notifications(self):
197197
continue
198198
notification = self._notification_from_status(status)
199199
notifications.append(notification)
200-
self.notifications = notifications
200+
self.notifications = notifications or None
201201
return
202202

203203
self.notifications = None

tests/unit/common/work/test_summary.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,7 @@ def test_no_notification_from_status(raw_status, summary_args_kwargs) -> None:
14651465
summary.summary_notifications
14661466
)
14671467

1468-
assert notifications == []
1468+
assert notifications is None
14691469
assert summary_notifications == []
14701470

14711471

@@ -1736,7 +1736,7 @@ def test_no_notification_from_wrong_type_status(
17361736
notifications = summary.notifications
17371737
summary_notifications = summary.summary_notifications
17381738

1739-
assert notifications == []
1739+
assert notifications is None
17401740
assert summary_notifications == []
17411741

17421742

@@ -1930,7 +1930,7 @@ def test_no_notification_from_status_without_neo4j_code(
19301930
notifications = summary.notifications
19311931
summary_notifications = summary.summary_notifications
19321932

1933-
assert notifications == []
1933+
assert notifications is None
19341934
assert summary_notifications == []
19351935

19361936

@@ -2081,7 +2081,7 @@ def test_notification_from_broken_status(
20812081
summary = ResultSummary(*args, **kwargs)
20822082

20832083
notifications = summary.notifications
2084-
assert notifications == []
2084+
assert notifications is None
20852085

20862086

20872087
def test_notifications_from_statuses_keep_order(

0 commit comments

Comments
 (0)