Skip to content

Commit 5458535

Browse files
committed
Error hard on some protocol violations
When the announced record fields don't match the number of fields returned in the following `RECORD` messages, the driver should properly error and not silently swallow some fields.
1 parent 8367b44 commit 5458535

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed

src/neo4j/_async/io/_bolt3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ async def route(
309309
await self.send_all()
310310
await self.fetch_all()
311311
return [
312-
dict(zip(metadata.get("fields", ()), values, strict=False))
312+
dict(zip(metadata.get("fields", ()), values, strict=True))
313313
for values in records
314314
]
315315

src/neo4j/_async/io/_bolt4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ async def route(
224224
await self.send_all()
225225
await self.fetch_all()
226226
return [
227-
dict(zip(metadata.get("fields", ()), values, strict=False))
227+
dict(zip(metadata.get("fields", ()), values, strict=True))
228228
for values in records
229229
]
230230

src/neo4j/_async/work/result.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def on_records(records):
247247
for record in records
248248
)
249249
self._record_buffer.extend(
250-
Record(zip(self._keys, record, strict=False))
250+
Record(zip(self._keys, record, strict=True))
251251
for record in records
252252
)
253253

@@ -919,7 +919,7 @@ async def to_df(
919919
else:
920920
# The rows have different keys. We need to pass a list
921921
# of dicts to pandas
922-
rows = [dict(zip(df_keys, r, strict=False)) for r in rows]
922+
rows = [dict(zip(df_keys, r, strict=True)) for r in rows]
923923
df_keys = False
924924
rows.append(row)
925925
if df_keys is False:

src/neo4j/_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def __repr__(self) -> str:
9393
fields = " ".join(
9494
f"{field}={value!r}"
9595
for field, value in zip(
96-
self.__keys, super().__iter__(), strict=False
96+
self.__keys, super().__iter__(), strict=True
9797
)
9898
)
9999
return f"<{self.__class__.__name__} {fields}>"

src/neo4j/_sync/io/_bolt3.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/neo4j/_sync/io/_bolt4.py

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/neo4j/_sync/work/result.py

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)