From: Torsten Werner Date: Fri, 14 Jan 2011 18:46:42 +0000 (+0100) Subject: Really fix the DebVersion type in dbconn.py. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad2d0b8d5d092f4ebbb14570640abf8901d20d10;p=dak Really fix the DebVersion type in dbconn.py. Signed-off-by: Torsten Werner --- 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))