Skip to content

Commit

Permalink
Merge pull request #202 from niphlod/fix/postgresql_unicode
Browse files Browse the repository at this point in the history
quickfix for unicode and postgresql on py2. Fails miserably on py3.
  • Loading branch information
gi0baro committed May 29, 2015
2 parents d8e24bc + fe72f8c commit cee77d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pydal/adapters/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from .._globals import IDENTITY
from ..drivers import psycopg2_adapt
from .._compat import PY2
from ..helpers.methods import varquote_aux
from .base import BaseAdapter
from ..objects import Expression
Expand Down Expand Up @@ -49,8 +50,9 @@ def varquote(self, name):
def adapt(self, obj):
if self.driver_name == 'psycopg2':
rv = psycopg2_adapt(obj).getquoted()
if isinstance(rv, bytes):
return rv.decode("utf8")
if not PY2:
if isinstance(rv, bytes):
return rv.decode('utf-8')
return rv
elif self.driver_name == 'pg8000':
return "'%s'" % obj.replace("%", "%%").replace("'", "''")
Expand Down

0 comments on commit cee77d7

Please sign in to comment.