Skip to content

Commit

Permalink
Merge branch 'master' of github.com:web2py/pydal
Browse files Browse the repository at this point in the history
  • Loading branch information
mdipierro committed Apr 17, 2021
2 parents 03cb4b0 + 472722a commit 232e841
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pydal/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import types
import re
from collections import OrderedDict
from io import TextIOWrapper
from ._compat import (
PY2,
StringIO,
Expand Down Expand Up @@ -99,7 +100,7 @@

def csv_reader(utf8_data, dialect=csv.excel, encoding="utf-8", **kwargs):
"""like csv.reader but allows to specify an encoding, defaults to utf-8"""
csv_reader = csv.reader(utf8_data, dialect=dialect, **kwargs)
csv_reader = csv.reader(TextIOWrapper(utf8_data,encoding), dialect=dialect, **kwargs)
for row in csv_reader:
yield [to_unicode(cell, encoding) for cell in row]

Expand Down Expand Up @@ -1501,6 +1502,13 @@ def __invert__(self):

def __add__(self, other):
return Expression(self.db, self._dialect.add, self, other, self.type)

def __radd__(self, other):
if not hasattr(other, "type"):
if isinstance(other, str):
other = self._dialect.quote(other)
other = Expression(self.db, other, type = self.type)
return Expression(self.db, self._dialect.add, other, self, self.type)

def __sub__(self, other):
if self.type in ("integer", "bigint"):
Expand Down

0 comments on commit 232e841

Please sign in to comment.