Merge ~cjwatson/launchpad:fix-stormify-person into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 82a4af0e227ac60120313f2a41f5ffebd9c2e929
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:fix-stormify-person
Merge into: launchpad:master
Diff against target: 113 lines (+14/-9)
6 files modified
lib/lp/registry/model/distroseries.py (+1/-1)
lib/lp/registry/model/person.py (+5/-0)
lib/lp/registry/vocabularies.py (+1/-1)
lib/lp/translations/model/pofile.py (+1/-1)
lib/lp/translations/scripts/remove_translations.py (+2/-2)
lib/lp/translations/scripts/tests/test_remove_translations.py (+4/-4)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+451670@code.launchpad.net

Commit message

Fix test failures due to "Convert Person to Storm"

Description of the change

I had to reintroduce the old `Person._storm_sortingColumns`, but I took the opportunity to give it a less horribly confusing name and explain the circumstances where it's still needed. The other changes are just little details I got slightly wrong.

To post a comment you must log in.
Revision history for this message
Guruprasad (lgp171188) wrote :

LGTM 👍

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
index 4119824..2e19dfb 100644
--- a/lib/lp/registry/model/distroseries.py
+++ b/lib/lp/registry/model/distroseries.py
@@ -1580,7 +1580,7 @@ class DistroSeries(
1580 POTemplate.distroseries == self,1580 POTemplate.distroseries == self,
1581 POTemplate.iscurrent == True,1581 POTemplate.iscurrent == True,
1582 )1582 )
1583 contributors = contributors.order_by(*Person._sortingColumns)1583 contributors = contributors.order_by(Person._separated_sortingColumns)
1584 contributors = contributors.config(distinct=True)1584 contributors = contributors.config(distinct=True)
1585 return contributors1585 return contributors
15861586
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index dcf118e..778f1dd 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -498,6 +498,11 @@ class Person(
498 return self.id498 return self.id
499499
500 sortingColumns = SQL("person_sort_key(Person.displayname, Person.name)")500 sortingColumns = SQL("person_sort_key(Person.displayname, Person.name)")
501 # If we're using SELECT DISTINCT, then we can't use sortingColumns
502 # unless `person_sort_key(Person.displayname, Person.name)` is also in
503 # the select list, which usually isn't convenient. Provide a separated
504 # version instead.
505 _separated_sortingColumns = ("Person.displayname", "Person.name")
501 # When doing any sort of set operations (union, intersect, except_) with506 # When doing any sort of set operations (union, intersect, except_) with
502 # Storm we can't use sortingColumns because the table name Person is not507 # Storm we can't use sortingColumns because the table name Person is not
503 # available in that context, so we use this one.508 # available in that context, so we use this one.
diff --git a/lib/lp/registry/vocabularies.py b/lib/lp/registry/vocabularies.py
index 0104a33..b267fec 100644
--- a/lib/lp/registry/vocabularies.py
+++ b/lib/lp/registry/vocabularies.py
@@ -401,7 +401,7 @@ class UserTeamsParticipationVocabulary(StormVocabularyBase):
401 teams = list(401 teams = list(
402 IStore(Person)402 IStore(Person)
403 .find(Person, *clauses)403 .find(Person, *clauses)
404 .order_by(Person._sortingColumns)404 .order_by(Person.sortingColumns)
405 )405 )
406 # Users can view all the teams they belong to.406 # Users can view all the teams they belong to.
407 precache_permission_for_objects(407 precache_permission_for_objects(
diff --git a/lib/lp/translations/model/pofile.py b/lib/lp/translations/model/pofile.py
index 623fb69..96196ca 100644
--- a/lib/lp/translations/model/pofile.py
+++ b/lib/lp/translations/model/pofile.py
@@ -456,7 +456,7 @@ class POFile(StormBase, POFileMixIn):
456 )456 )
457 .config(distinct=True)457 .config(distinct=True)
458 )458 )
459 contributors = contributors.order_by(*Person._sortingColumns)459 contributors = contributors.order_by(Person._separated_sortingColumns)
460 contributors = contributors.config(distinct=True)460 contributors = contributors.config(distinct=True)
461 return contributors461 return contributors
462462
diff --git a/lib/lp/translations/scripts/remove_translations.py b/lib/lp/translations/scripts/remove_translations.py
index e854640..c042b8a 100644
--- a/lib/lp/translations/scripts/remove_translations.py
+++ b/lib/lp/translations/scripts/remove_translations.py
@@ -444,11 +444,11 @@ def remove_translations(
444 conditions = set()444 conditions = set()
445 if submitter is not None:445 if submitter is not None:
446 conditions.add(446 conditions.add(
447 "TranslationMessage.submitter = %s" % sqlvalues(submitter.id)447 "TranslationMessage.submitter = %s" % sqlvalues(submitter)
448 )448 )
449 if reviewer is not None:449 if reviewer is not None:
450 conditions.add(450 conditions.add(
451 "TranslationMessage.reviewer = %s" % sqlvalues(reviewer.id)451 "TranslationMessage.reviewer = %s" % sqlvalues(reviewer)
452 )452 )
453 if date_created is not None:453 if date_created is not None:
454 conditions.add(454 conditions.add(
diff --git a/lib/lp/translations/scripts/tests/test_remove_translations.py b/lib/lp/translations/scripts/tests/test_remove_translations.py
index 15c2638..dbea556 100644
--- a/lib/lp/translations/scripts/tests/test_remove_translations.py
+++ b/lib/lp/translations/scripts/tests/test_remove_translations.py
@@ -420,7 +420,7 @@ class TestRemoveTranslations(TestCase):
420 # on reviewer instead.420 # on reviewer instead.
421 new_nl_message.reviewer = self.potemplate.owner421 new_nl_message.reviewer = self.potemplate.owner
422422
423 self._removeMessages(submitter=carlos)423 self._removeMessages(submitter=carlos.id)
424 self._checkInvariant()424 self._checkInvariant()
425425
426 def test_RemoveByReviewer(self):426 def test_RemoveByReviewer(self):
@@ -434,7 +434,7 @@ class TestRemoveTranslations(TestCase):
434 new_nl_message.reviewer = carlos434 new_nl_message.reviewer = carlos
435 new_de_message.reviewer = carlos435 new_de_message.reviewer = carlos
436436
437 self._removeMessages(reviewer=carlos)437 self._removeMessages(reviewer=carlos.id)
438 self._checkInvariant()438 self._checkInvariant()
439439
440 def test_RemoveByDateCreated(self):440 def test_RemoveByDateCreated(self):
@@ -473,7 +473,7 @@ class TestRemoveTranslations(TestCase):
473 )473 )
474 removeSecurityProxy(new_de_message).submitter = mark474 removeSecurityProxy(new_de_message).submitter = mark
475475
476 self._removeMessages(submitter=carlos, date_created="2015-05-12")476 self._removeMessages(submitter=carlos.id, date_created="2015-05-12")
477477
478 # First make sure we're not reading out of cache.478 # First make sure we're not reading out of cache.
479 Store.of(self.nl_pofile).flush()479 Store.of(self.nl_pofile).flush()
@@ -502,7 +502,7 @@ class TestRemoveTranslations(TestCase):
502 )502 )
503503
504 rowcount = self._removeMessages(504 rowcount = self._removeMessages(
505 submitter=carlos, date_created="2015-05-12"505 submitter=carlos.id, date_created="2015-05-12"
506 )506 )
507507
508 self.assertEqual(rowcount, 1)508 self.assertEqual(rowcount, 1)

Subscribers

People subscribed via source and target branches

to status/vote changes: