← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:testfix-version-lookup-as-text into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:testfix-version-lookup-as-text into launchpad:master.

Commit message:
testfix: Coerce version to text in Archive.getPublished{Sources,Binaries}

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/389890

All the callers here should eventually be passing text, but to fix the test suite let's take this approach for now.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:testfix-version-lookup-as-text into launchpad:master.
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index 3217e1d..a37b737 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -17,6 +17,7 @@ from operator import attrgetter
 import re
 
 from lazr.lifecycle.event import ObjectCreatedEvent
+import six
 from sqlobject import (
     BoolCol,
     ForeignKey,
@@ -658,7 +659,8 @@ class Archive(SQLBase):
                     "The 'version' parameter can be used only together with"
                     " the 'name' parameter.")
             clauses.append(
-                Cast(SourcePackageRelease.version, "text") == version)
+                Cast(SourcePackageRelease.version, "text") ==
+                six.ensure_text(version))
         elif not order_by_date:
             order_by.insert(1, Desc(SourcePackageRelease.version))
 
@@ -857,7 +859,8 @@ class Archive(SQLBase):
                     " the 'name' parameter.")
 
             clauses.append(
-                Cast(BinaryPackageRelease.version, "text") == version)
+                Cast(BinaryPackageRelease.version, "text") ==
+                six.ensure_text(version))
         elif ordered:
             order_by.insert(1, Desc(BinaryPackageRelease.version))