mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-08-03 03:40:09 +03:00
Modify hstore adaptor to only produce strings
The prior implementation would adapt the types, and the following would happen: input: {'foo': True, 'bar': "baz"} output: hstore(ARRAY['foo', 'bar'], ARRAY[true, 'baz']) The output value of foo is a boolean type, which is not acceptable in an hstore (at least not with this creation method). Anyways, coercing everything to a string solves the issue. I am using the unicode function to make the tests happy.
This commit is contained in:
parent
03b8b1e97a
commit
82ab0cde55
|
@ -644,7 +644,7 @@ class HstoreAdapter(object):
|
|||
|
||||
k = _ext.adapt(self.wrapped.keys())
|
||||
k.prepare(self.conn)
|
||||
v = _ext.adapt(self.wrapped.values())
|
||||
v = _ext.adapt([unicode(x) if x is not None else None for x in self.wrapped.values()])
|
||||
v.prepare(self.conn)
|
||||
return b("hstore(") + k.getquoted() + b(", ") + v.getquoted() + b(")")
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user