From bb41acd1daa61530166aac0cec3dfc1adf573539 Mon Sep 17 00:00:00 2001 From: Daniele Varrazzo Date: Mon, 27 Sep 2010 01:45:16 +0100 Subject: [PATCH] Favour the PG9 implementation of the hstore adapter. --- lib/extras.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/extras.py b/lib/extras.py index e7fbfb4e..1db6e961 100644 --- a/lib/extras.py +++ b/lib/extras.py @@ -482,9 +482,9 @@ class HstoreAdapter(object): def prepare(self, conn): self.conn = conn - # select the most efficient getquoted implementation - if conn.server_version >= 90000: - self.getquoted = self._getquoted_9 + # use an old-style getquoted implementation if required + if conn.server_version < 90000: + self.getquoted = self._getquoted_8 def _getquoted_8(self): """Use the operators available in PG pre-9.0.""" @@ -509,8 +509,6 @@ class HstoreAdapter(object): return "(" + '||'.join(rv) + ")" - getquoted = _getquoted_8 - def _getquoted_9(self): """Use the hstore(text[], text[]) function.""" if not self.wrapped: @@ -522,6 +520,8 @@ class HstoreAdapter(object): v.prepare(self.conn) return "hstore(%s, %s)" % (k.getquoted(), v.getquoted()) + getquoted = _getquoted_9 + _re_hstore = regex.compile(r""" # hstore key: # a string of normal or escaped chars