Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.

Commit fe5903a

Browse files
committed
fix issue with duplicate column names
1 parent 1e0f679 commit fe5903a

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

databases/backends/postgres.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,16 @@ def __init__(self, row: tuple, result_columns: tuple, dialect: Dialect) -> None:
7373
column_name: (idx, datatype)
7474
for idx, (column_name, _, _, datatype) in enumerate(self._result_columns)
7575
}
76+
self._column_map_full = {
77+
str(column[0]): (idx, datatype)
78+
for idx, (_, _, column, datatype) in enumerate(self._result_columns)
79+
}
7680

77-
def __getitem__(self, key: str) -> typing.Any:
78-
idx, datatype = self._column_map[key]
81+
def __getitem__(self, key) -> typing.Any:
82+
if type(key) is str:
83+
idx, datatype = self._column_map[key]
84+
else:
85+
idx, datatype = self._column_map_full[str(key)]
7986
raw = self._row[idx]
8087
try:
8188
processor = _result_processors[datatype]

0 commit comments

Comments
 (0)