Author: fw Date: 2005-09-18 13:15:48 +0000 (Sun, 18 Sep 2005) New Revision: 2040 Modified: lib/python/security_db.py Log: lib/python/security_db.py (DB._initFunctions): Introduce collation function for Debian versions. (DB.getBinaryPackagesForSource, DB.getSourcePackages, DB.getBinaryPackages): Use it. Modified: lib/python/security_db.py ==================================================================--- lib/python/security_db.py 2005-09-18 13:13:29 UTC (rev 2039) +++ lib/python/security_db.py 2005-09-18 13:15:48 UTC (rev 2040) @@ -322,6 +322,12 @@ return release self.db.createscalarfunction("release_name", release_name, 3) + # This is slower than the version_linear_order table, but + # often more convenient to use in queries. + def collate_version(a, b): + return debian_support.Version(a).__cmp__(debian_support.Version(b)) + self.db.createcollation("version", collate_version) + def filePrint(self, filename): """Returns a fingerprint string for filename.""" @@ -1207,7 +1213,8 @@ ORDER BY release_to_number(release)) GROUP BY package, version ORDER BY package) - GROUP BY releases, version""", (pkg,)): + GROUP BY releases, version + ORDER BY version COLLATE version""", (pkg,)): yield packages.split('', ''), releases.split('', ''), version def getSourcePackages(self, cursor, bug): @@ -1225,7 +1232,7 @@ WHERE n.bug_name = ? AND s.note = n.id AND p.rowid = s.package ORDER BY release_to_number(p.release), p.subrelease) GROUP BY package, version, vulnerable - ORDER BY package, version""", + ORDER BY package, version COLLATE version""", (bug,)): yield package, releases.split('', ''), version, vulnerable @@ -1250,9 +1257,9 @@ p.version, vulnerable ORDER BY release_to_number(p.release), p.subrelease) GROUP BY package, version, vulnerable, archs - ORDER BY package, version) + ORDER BY package) GROUP BY releases, version, vulnerable, archs - ORDER BY packages, version""", + ORDER BY packages, version COLLATE version""", (bug,)): yield (packages.split('', ''), releases.split('',''), version, archs.split('',''), vulnerable)