File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,12 @@ def _enable_hstore(conn):
39
39
""" )
40
40
rv0 , rv1 = [], []
41
41
for oids in (yield from cur .fetchall ()):
42
- rv0 .append (oids [0 ])
43
- rv1 .append (oids [1 ])
42
+ if isinstance (oids , dict ):
43
+ rv0 .append (oids ['oid' ])
44
+ rv1 .append (oids ['typarray' ])
45
+ else :
46
+ rv0 .append (oids [0 ])
47
+ rv1 .append (oids [1 ])
44
48
45
49
cur .close ()
46
50
return tuple (rv0 ), tuple (rv1 )
Original file line number Diff line number Diff line change @@ -52,6 +52,27 @@ def test_simple_select(connect):
52
52
assert (1 ,) == ret
53
53
54
54
55
+ @asyncio .coroutine
56
+ def test_simple_select_with_hstore (connect ):
57
+ conn = yield from connect ()
58
+ cur = yield from conn .cursor ()
59
+ yield from cur .execute ("""
60
+ CREATE EXTENSION IF NOT EXISTS hstore;
61
+ CREATE TABLE hfoo (id serial, hcol hstore);
62
+ INSERT INTO hfoo (hcol) VALUES ('"col1"=>"456", "col2"=>"zzz"');
63
+ """ )
64
+
65
+ # Reconnect because this is where the problem happens.
66
+ cur .close ()
67
+ conn .close ()
68
+ conn = yield from connect (cursor_factory = psycopg2 .extras .RealDictCursor )
69
+ cur = yield from conn .cursor ()
70
+ yield from cur .execute ("SELECT * FROM hfoo;" )
71
+ ret = yield from cur .fetchone ()
72
+ yield from cur .execute ("DROP TABLE hfoo;" )
73
+ assert {'hcol' : {'col1' : '456' , 'col2' : 'zzz' }, 'id' : 1 } == ret
74
+
75
+
55
76
@asyncio .coroutine
56
77
def test_default_event_loop (connect , loop ):
57
78
asyncio .set_event_loop (loop )
You can’t perform that action at this time.
0 commit comments