1.1 --- a/imiptools/period.py Thu Apr 21 16:34:27 2016 +0200
1.2 +++ b/imiptools/period.py Thu Apr 21 23:17:35 2016 +0200
1.3 @@ -34,6 +34,12 @@
1.4 if x is None: return y
1.5 else: return x
1.6
1.7 +def to_string(s, encoding):
1.8 + if s:
1.9 + return s.encode(encoding)
1.10 + else:
1.11 + return s
1.12 +
1.13 class Comparable:
1.14
1.15 "A date/datetime wrapper that allows comparisons with other types."
1.16 @@ -896,7 +902,7 @@
1.17 "insert into %(table)s (:columns) values (:values)" % {
1.18 "table" : self.table_name
1.19 },
1.20 - columns, values)
1.21 + columns, [to_string(v, "utf-8") for v in values])
1.22
1.23 self.cursor.execute(query, values)
1.24
1.25 @@ -907,11 +913,14 @@
1.26 self._check_mutable()
1.27
1.28 for period in periods:
1.29 + values = period.as_tuple(string_datetimes=True)
1.30 +
1.31 query, values = self.get_query(
1.32 "delete from %(table)s :condition" % {
1.33 "table" : self.table_name
1.34 },
1.35 - self.period_columns, period.as_tuple(string_datetimes=True))
1.36 + self.period_columns, [to_string(v, "utf-8") for v in values])
1.37 +
1.38 self.cursor.execute(query, values)
1.39
1.40 def remove_event_periods(self, uid, recurrenceid=None):