Skip to content

Commit be9431c

Browse files
committed
Fix so that integer-lookups are not included in dict(record) for postgres
1 parent a0eec21 commit be9431c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

databases/backends/postgres.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,20 @@ def __init__(
7373
self._result_columns = result_columns
7474
self._dialect = dialect
7575
self._column_map = {}
76+
self._column_map_int = {}
7677
self._column_map_full = {}
7778
for idx, (column_name, _, column, datatype) in enumerate(self._result_columns):
7879
self._column_map[column_name] = (idx, datatype)
79-
self._column_map[idx] = (idx, datatype)
80+
self._column_map_int[idx] = (idx, datatype)
8081
self._column_map_full[str(column[0])] = (idx, datatype)
8182

8283
def __getitem__(self, key: typing.Any) -> typing.Any:
8384
if len(self._column_map) == 0: # raw query
8485
return self._row[tuple(self._row.keys()).index(key)]
8586
elif type(key) is Column:
8687
idx, datatype = self._column_map_full[str(key)]
88+
elif type(key) is int:
89+
idx, datatype = self._column_map_int[key]
8790
else:
8891
idx, datatype = self._column_map[key]
8992
raw = self._row[idx]

0 commit comments

Comments
 (0)