From dd635d9364458cbc9db167293e6ac7fe752532cf Mon Sep 17 00:00:00 2001 From: Patrick Uiterwijk Date: Sep 13 2016 13:13:25 +0000 Subject: Fix cleanup type issues with non-sqlite backends 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 --- diff --git a/ipsilon/util/data.py b/ipsilon/util/data.py index cf7bf21..5a06093 100644 --- a/ipsilon/util/data.py +++ b/ipsilon/util/data.py @@ -791,7 +791,7 @@ class TranStore(Store): 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 @@ class SAML2SessionStore(Store): 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 diff --git a/ipsilon/util/sessions.py b/ipsilon/util/sessions.py index 1b35db0..fa4418e 100644 --- a/ipsilon/util/sessions.py +++ b/ipsilon/util/sessions.py @@ -44,7 +44,7 @@ class SessionStore(Store): 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