#120 Fix cleanup type issues with non-sqlite backends
Merged 7 years ago by puiterwijk. Opened 7 years ago by puiterwijk.
puiterwijk/ipsilon fix-cleanup-type-error  into  master

file modified
+2 -2
@@ -791,7 +791,7 @@ 

          in_one_hour = datetime.datetime.now() - datetime.timedelta(hours=1)

          sel = select([table.c.uuid]). \

              where(and_(table.c.name == 'origintime',

-                        table.c.value <= in_one_hour))

+                        table.c.value <= str(in_one_hour)))

          # pylint: disable=no-value-for-parameter

          d = table.delete().where(table.c.uuid.in_(sel))

          return d.execute().rowcount
@@ -827,7 +827,7 @@ 

          table = SqlQuery(self._db, self.table, UNIQUE_DATA_TABLE)._table

          sel = select([table.c.uuid]). \

              where(and_(table.c.name == 'expiration_time',

-                        table.c.value <= datetime.datetime.now()))

+                        table.c.value <= str(datetime.datetime.now())))

          # pylint: disable=no-value-for-parameter

          d = table.delete().where(table.c.uuid.in_(sel))

          return d.execute().rowcount

file modified
+1 -1
@@ -44,7 +44,7 @@ 

          table = SqlQuery(self._db, 'sessions', SESSION_TABLE)._table

          # pylint: disable=no-value-for-parameter

          d = table.delete().where(table.c.expiration_time <=

-                                  datetime.datetime.now())

+                                  str(datetime.datetime.now()))

          return d.execute().rowcount

  

  

We store the data as strings, so when telling SQL to compare, we should be
sending strings to compare against.
SQLite does not actually check types, so doesn't throw this error, but for
example in Postgres, the following error is being recorded:
ProgrammingError: (psycopg2.ProgrammingError) operator does not exist: text <= timestamp without time zone

Signed-off-by: Patrick Uiterwijk puiterwijk@redhat.com

Looks fine to me, :thumbsup:

Yes, I should. And will.
Thanks for the ping.

Commit c736c0f fixes this pull-request

Pull-Request has been merged by puiterwijk@redhat.com

7 years ago