From ad2d0b8d5d092f4ebbb14570640abf8901d20d10 Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Fri, 14 Jan 2011 19:46:42 +0100 Subject: [PATCH] Really fix the DebVersion type in dbconn.py. Signed-off-by: Torsten Werner --- daklib/dbconn.py | 2 +- tests/dbtest_debversion.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/daklib/dbconn.py b/daklib/dbconn.py index bae2bb35..cc7f6fe3 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -78,7 +78,7 @@ class DebVersion(UserDefinedType): def bind_processor(self, dialect): return None - def result_processor(self, dialect): + def result_processor(self, dialect, coltype): return None sa_major_version = sqlalchemy.__version__[0:3] diff --git a/tests/dbtest_debversion.py b/tests/dbtest_debversion.py index 548a2e8e..86dd3d28 100755 --- a/tests/dbtest_debversion.py +++ b/tests/dbtest_debversion.py @@ -16,6 +16,13 @@ class Version(object): return "" % self.version class DebVersionTestCase(DBDakTestCase): + """ + The DebVersionTestCase tests both comparison (<=, ==, >, !=), the in_() + method and aggregate functions (min, max) for the DebVersion type. To + simplify the test it creates a separate table 'version' which is not used + by dak itself. + """ + def setUp(self): super(DebVersionTestCase, self).setUp() self.version_table = Table('version', self.metadata, \ @@ -32,12 +39,15 @@ class DebVersionTestCase(DBDakTestCase): self.session.add(v) v = Version('1.0') self.session.add(v) - #self.session.commit() q = self.session.query(Version) self.assertEqual(3, q.count()) + self.assertEqual(2, q.filter(Version.version <= '0.5').count()) + self.assertEqual(1, q.filter(Version.version == '0.5').count()) self.assertEqual(2, q.filter(Version.version > '0.5~').count()) self.assertEqual(1, q.filter(Version.version > '0.5').count()) self.assertEqual(0, q.filter(Version.version > '1.0').count()) + self.assertEqual(2, q.filter(Version.version != '1.0').count()) + self.assertEqual(2, q.filter(Version.version.in_(['0.5~', '1.0'])).count()) q = self.session.query(func.min(Version.version)) self.assertEqual('0.5~', q.one()[0]) q = self.session.query(func.max(Version.version)) -- 2.39.5