Skip to content

Commit c70a8f3

Browse files
committed
Add a (failing) test for duplicate field names handling in Records
1 parent 9c16280 commit c70a8f3

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

tests/test_record.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import sys
1313
import unittest
1414

15+
from asyncpg import _testbase as tb
1516
from asyncpg.protocol.protocol import _create_record as Record
1617

1718

@@ -21,7 +22,7 @@
2122
R_ABC = collections.OrderedDict([('a', 0), ('b', 1), ('c', 2)])
2223

2324

24-
class TestRecord(unittest.TestCase):
25+
class TestRecord(tb.ConnectedTestCase):
2526

2627
@contextlib.contextmanager
2728
def checkref(self, *objs):
@@ -279,3 +280,11 @@ def test_record_not_pickleable(self):
279280
r = Record(R_A, (42,))
280281
with self.assertRaises(Exception):
281282
pickle.dumps(r)
283+
284+
@unittest.expectedFailure
285+
async def test_record_duplicate_colnames(self):
286+
"""Test that Record handles duplicate column names."""
287+
r = await self.con.fetchrow('SELECT 1 as a, 2 as a')
288+
self.assertEqual(r['a'], 2)
289+
self.assertEqual(r[0], 1)
290+
self.assertEqual(repr(r), '<Record a=1 a=2>')

0 commit comments

Comments
 (0)