Skip to content

Commit cee04fc

Browse files
committed
Fix
1 parent c9e625e commit cee04fc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drift/instrumentation/psycopg2/instrumentation.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,14 @@ def _mock_execute_with_data(self, cursor: Any, mock_data: dict[str, Any]) -> Non
843843
# If it's a dict cursor and we have description, convert rows to dicts
844844
if is_dict_cursor and description_data:
845845
column_names = [col["name"] for col in description_data]
846-
mock_rows = [dict(zip(column_names, row)) for row in mock_rows]
846+
converted_rows = []
847+
for row in mock_rows:
848+
if len(column_names) != len(row):
849+
raise ValueError(
850+
f"Column count mismatch: {len(column_names)} columns but row has {len(row)} values"
851+
)
852+
converted_rows.append(dict(zip(column_names, row)))
853+
mock_rows = converted_rows
847854

848855
cursor._mock_rows = mock_rows # pyright: ignore[reportAttributeAccessIssue]
849856
cursor._mock_index = 0 # pyright: ignore[reportAttributeAccessIssue]

0 commit comments

Comments
 (0)