Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
-
None
-
None
Description
A row can only carry a given field name once, so two columns with the same name ( like SELECT t1.id, t2.id FROM t1 JOIN t2 typically) can't both be reached. Both drivers accept it and lose a column silently:
cur = conn.cursor(named_tuple=True)
cur.execute("SELECT 1 AS id, 2 AS id")
print(cur.fetchone())
- C extension: Row(id=1, id=2) -> row.id is 2, first column unreachable
- pure Python: Row(id=1, id_1=2) -> field name the query never asked for
Once all columns are known, the result set should be rejected with a ProgrammingError naming the duplicate. Tuple and dictionary cursors are unaffected.