Skip to content

Commit

Permalink
quickfix for unicode and postgresql on py2. Fails miserably on py3.
Browse files Browse the repository at this point in the history
Needs further reconsideration but can be included for a new tagged
release to be released with web2py, that can't suffer for py3 errors.
  • Loading branch information
niphlod committed May 29, 2015
1 parent d8e24bc commit fe72f8c
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 fe72f8c

Please sign in to comment.