diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-28 11:35:57 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2013-06-28 11:38:28 -0400 |
| commit | 69179e009c2dcf71945415d455765b98ecd89fe4 (patch) | |
| tree | b5c38a387f65047ef5c236300c096f6f5b4a9969 /lib/sqlalchemy | |
| parent | d64c945eae682b34381dee327fcb27b1eaafec43 (diff) | |
| download | sqlalchemy-69179e009c2dcf71945415d455765b98ecd89fe4.tar.gz | |
Fixed bug in HSTORE type where keys/values that contained
backslashed quotes would not be escaped correctly when
using the "non native" (i.e. non-psycopg2) means
of translating HSTORE data. Patch courtesy Ryan Kelly.
[ticket:2766]
Conflicts:
doc/build/changelog/changelog_09.rst
lib/sqlalchemy/dialects/postgresql/hstore.py
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/dialects/postgresql/hstore.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/hstore.py b/lib/sqlalchemy/dialects/postgresql/hstore.py index 4daf54bab..dc9f05a60 100644 --- a/lib/sqlalchemy/dialects/postgresql/hstore.py +++ b/lib/sqlalchemy/dialects/postgresql/hstore.py @@ -68,11 +68,11 @@ def _parse_hstore(hstore_str): pair_match = HSTORE_PAIR_RE.match(hstore_str) while pair_match is not None: - key = pair_match.group('key') + key = pair_match.group('key').replace(r'\"', '"').replace("\\\\", "\\") if pair_match.group('value_null'): value = None else: - value = pair_match.group('value').replace(r'\"', '"') + value = pair_match.group('value').replace(r'\"', '"').replace("\\\\", "\\") result[key] = value pos += pair_match.end() @@ -98,7 +98,7 @@ def _serialize_hstore(val): if position == 'value' and s is None: return 'NULL' elif isinstance(s, basestring): - return '"%s"' % s.replace('"', r'\"') + return '"%s"' % s.replace("\\", "\\\\").replace('"', r'\"') else: raise ValueError("%r in %s position is not a string." % (s, position)) |
