Merge ~cjwatson/launchpad:stormify-bug into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 781668475e3065ef27a871302ea3b82ad5ae1c1c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:stormify-bug
Merge into: launchpad:master
Diff against target: 602 lines (+107/-91)
21 files modified
lib/lp/answers/doc/karma.rst (+1/-1)
lib/lp/bugs/browser/bug.py (+2/-5)
lib/lp/bugs/browser/buglisting.py (+1/-1)
lib/lp/bugs/browser/bugtask.py (+1/-1)
lib/lp/bugs/doc/bug.rst (+1/-1)
lib/lp/bugs/doc/bugnotificationrecipients.rst (+3/-2)
lib/lp/bugs/doc/bugnotifications.rst (+1/-1)
lib/lp/bugs/doc/cve.rst (+2/-1)
lib/lp/bugs/interfaces/bug.py (+1/-1)
lib/lp/bugs/model/bug.py (+69/-52)
lib/lp/bugs/model/bugtask.py (+2/-2)
lib/lp/bugs/model/bugtasksearch.py (+1/-1)
lib/lp/bugs/model/personsubscriptioninfo.py (+1/-1)
lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst (+4/-3)
lib/lp/bugs/templates/bug-portlet-duplicates.pt (+1/-1)
lib/lp/bugs/tests/bugs-emailinterface.rst (+8/-8)
lib/lp/bugs/vocabularies.py (+2/-3)
lib/lp/registry/tests/test_person.py (+1/-1)
lib/lp/scripts/harness.py (+2/-2)
lib/lp/services/database/tests/test_bulk.py (+1/-1)
lib/lp/services/statistics/model/statistics.py (+2/-2)
Reviewer Review Type Date Requested Status
Guruprasad Approve
Review via email: mp+447358@code.launchpad.net

Commit message

Convert Bug to Storm

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

LGTM 👍

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Guruprasad (lgp171188) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/answers/doc/karma.rst b/lib/lp/answers/doc/karma.rst
index 5bc61ef..488a2a3 100644
--- a/lib/lp/answers/doc/karma.rst
+++ b/lib/lp/answers/doc/karma.rst
@@ -216,7 +216,7 @@ Linking to a bug
216................216................
217217
218 >>> from lp.bugs.model.bug import Bug218 >>> from lp.bugs.model.bug import Bug
219 >>> questionbug = firefox_question.linkBug(Bug.get(5))219 >>> questionbug = firefox_question.linkBug(IStore(Bug).get(Bug, 5))
220 Karma added: action=questionlinkedtobug, product=firefox, person=name12220 Karma added: action=questionlinkedtobug, product=firefox, person=name12
221221
222222
diff --git a/lib/lp/bugs/browser/bug.py b/lib/lp/bugs/browser/bug.py
index 3a34c23..190ba78 100644
--- a/lib/lp/bugs/browser/bug.py
+++ b/lib/lp/bugs/browser/bug.py
@@ -1202,11 +1202,8 @@ class BugTextView(LaunchpadView):
1202 else:1202 else:
1203 text.append("duplicate-of: ")1203 text.append("duplicate-of: ")
12041204
1205 if bug.duplicates:1205 dupes = " ".join(str(dupe.id) for dupe in bug.duplicates)
1206 dupes = " ".join(str(dupe.id) for dupe in bug.duplicates)1206 text.append("duplicates: %s" % dupes)
1207 text.append("duplicates: %s" % dupes)
1208 else:
1209 text.append("duplicates: ")
12101207
1211 if bug.private:1208 if bug.private:
1212 # XXX kiko 2007-10-31: this could include date_made_private and1209 # XXX kiko 2007-10-31: this could include date_made_private and
diff --git a/lib/lp/bugs/browser/buglisting.py b/lib/lp/bugs/browser/buglisting.py
index cef7d6e..3b579c7 100644
--- a/lib/lp/bugs/browser/buglisting.py
+++ b/lib/lp/bugs/browser/buglisting.py
@@ -682,7 +682,7 @@ class BugTaskListingItem:
682 assignee = None682 assignee = None
683 if self.assignee_id is not None:683 if self.assignee_id is not None:
684 assignee = self.people[self.assignee_id].displayname684 assignee = self.people[self.assignee_id].displayname
685 reporter = self.people[self.bug.ownerID]685 reporter = self.people[self.bug.owner_id]
686686
687 # the case that there is no target context (e.g. viewing bug that687 # the case that there is no target context (e.g. viewing bug that
688 # are related to a user account) is intercepted688 # are related to a user account) is intercepted
diff --git a/lib/lp/bugs/browser/bugtask.py b/lib/lp/bugs/browser/bugtask.py
index ad3a7a2..adedd6b 100644
--- a/lib/lp/bugs/browser/bugtask.py
+++ b/lib/lp/bugs/browser/bugtask.py
@@ -435,7 +435,7 @@ class BugTaskView(LaunchpadView, BugViewMixin, FeedsMixin):
435 self.context = context435 self.context = context
436 list(436 list(
437 getUtility(IPersonSet).getPrecachedPersonsFromIDs(437 getUtility(IPersonSet).getPrecachedPersonsFromIDs(
438 [self.context.bug.ownerID], need_validity=True438 [self.context.bug.owner_id], need_validity=True
439 )439 )
440 )440 )
441441
diff --git a/lib/lp/bugs/doc/bug.rst b/lib/lp/bugs/doc/bug.rst
index e1c54e5..7893e52 100644
--- a/lib/lp/bugs/doc/bug.rst
+++ b/lib/lp/bugs/doc/bug.rst
@@ -263,7 +263,7 @@ private:
263 >>> from lp.bugs.model.bug import Bug263 >>> from lp.bugs.model.bug import Bug
264 >>> from lp.services.database.interfaces import IStore264 >>> from lp.services.database.interfaces import IStore
265265
266 >>> all_bugs = set(IStore(Bug).find(Bug).values(Bug.id))266 >>> all_bugs = set(IStore(Bug).find(Bug.id))
267267
268 >>> taskset = getUtility(IBugTaskSet)268 >>> taskset = getUtility(IBugTaskSet)
269 >>> def hidden_bugs():269 >>> def hidden_bugs():
diff --git a/lib/lp/bugs/doc/bugnotificationrecipients.rst b/lib/lp/bugs/doc/bugnotificationrecipients.rst
index c633ea9..c3688c9 100644
--- a/lib/lp/bugs/doc/bugnotificationrecipients.rst
+++ b/lib/lp/bugs/doc/bugnotificationrecipients.rst
@@ -14,7 +14,8 @@ action:
14 >>> from lp.bugs.model.bug import Bug14 >>> from lp.bugs.model.bug import Bug
15 >>> from lp.registry.model.distribution import Distribution15 >>> from lp.registry.model.distribution import Distribution
16 >>> from lp.registry.model.product import Product16 >>> from lp.registry.model.product import Product
17 >>> bug_one = Bug.get(1)17 >>> from lp.services.database.interfaces import IStore
18 >>> bug_one = IStore(Bug).get(Bug, 1)
18 >>> recipients = bug_one.getBugNotificationRecipients()19 >>> recipients = bug_one.getBugNotificationRecipients()
1920
20The instance of BugNotificationRecipients we get back correctly21The instance of BugNotificationRecipients we get back correctly
@@ -124,7 +125,7 @@ additional step is involved. A BugNotificationRecipients instance is
124created, annotating that it represents a master bug (of which we are a125created, annotating that it represents a master bug (of which we are a
125duplicate of).126duplicate of).
126127
127 >>> bug_two = Bug.get(2)128 >>> bug_two = IStore(Bug).get(Bug, 2)
128 >>> recipients = BugNotificationRecipients(duplicateof=bug_two)129 >>> recipients = BugNotificationRecipients(duplicateof=bug_two)
129130
130 >>> foo_bar = personset.getByEmail("foo.bar@canonical.com")131 >>> foo_bar = personset.getByEmail("foo.bar@canonical.com")
diff --git a/lib/lp/bugs/doc/bugnotifications.rst b/lib/lp/bugs/doc/bugnotifications.rst
index c7aaeb5..4b4d755 100644
--- a/lib/lp/bugs/doc/bugnotifications.rst
+++ b/lib/lp/bugs/doc/bugnotifications.rst
@@ -354,7 +354,7 @@ this document:
354 ... status=CveStatus.ENTRY,354 ... status=CveStatus.ENTRY,
355 ... )355 ... )
356 >>> from lp.bugs.model.bug import Bug356 >>> from lp.bugs.model.bug import Bug
357 >>> bug = Bug.get(1)357 >>> bug = IStore(Bug).get(Bug, 1)
358 >>> bugcve = cve.linkBug(bug) # note this creates the event and notifies358 >>> bugcve = cve.linkBug(bug) # note this creates the event and notifies
359359
360 >>> latest_notification = (360 >>> latest_notification = (
diff --git a/lib/lp/bugs/doc/cve.rst b/lib/lp/bugs/doc/cve.rst
index e06fe5f..86b2a3f 100644
--- a/lib/lp/bugs/doc/cve.rst
+++ b/lib/lp/bugs/doc/cve.rst
@@ -75,7 +75,8 @@ You can link a CVE to a bug. You can also see which CVEs are currently
75linked to a bug:75linked to a bug:
7676
77 >>> from lp.bugs.model.bug import Bug77 >>> from lp.bugs.model.bug import Bug
78 >>> b = Bug.get(1)78 >>> from lp.services.database.interfaces import IStore
79 >>> b = IStore(Bug).get(Bug, 1)
79 >>> for c in b.cves:80 >>> for c in b.cves:
80 ... print(c.displayname)81 ... print(c.displayname)
81 ...82 ...
diff --git a/lib/lp/bugs/interfaces/bug.py b/lib/lp/bugs/interfaces/bug.py
index e02f2ff..acf5c6e 100644
--- a/lib/lp/bugs/interfaces/bug.py
+++ b/lib/lp/bugs/interfaces/bug.py
@@ -240,7 +240,7 @@ class IBugView(Interface):
240 max_length=50000,240 max_length=50000,
241 )241 )
242 )242 )
243 ownerID = Int(title=_("Owner"), required=True, readonly=True)243 owner_id = Int(title=_("Owner"), required=True, readonly=True)
244 owner = exported(244 owner = exported(
245 Reference(IPerson, title=_("The owner's IPerson"), readonly=True)245 Reference(IPerson, title=_("The owner's IPerson"), readonly=True)
246 )246 )
diff --git a/lib/lp/bugs/model/bug.py b/lib/lp/bugs/model/bug.py
index dc2d66b..2db7afe 100644
--- a/lib/lp/bugs/model/bug.py
+++ b/lib/lp/bugs/model/bug.py
@@ -33,6 +33,7 @@ from lazr.lifecycle.snapshot import Snapshot
33from lazr.restful.declarations import error_status33from lazr.restful.declarations import error_status
34from storm.expr import (34from storm.expr import (
35 SQL,35 SQL,
36 Add,
36 And,37 And,
37 Coalesce,38 Coalesce,
38 Desc,39 Desc,
@@ -170,19 +171,10 @@ from lp.registry.model.pillar import pillar_sort_key
170from lp.registry.model.teammembership import TeamParticipation171from lp.registry.model.teammembership import TeamParticipation
171from lp.services.config import config172from lp.services.config import config
172from lp.services.database import bulk173from lp.services.database import bulk
173from lp.services.database.constants import UTC_NOW174from lp.services.database.constants import DEFAULT, UTC_NOW
174from lp.services.database.datetimecol import UtcDateTimeCol
175from lp.services.database.decoratedresultset import DecoratedResultSet175from lp.services.database.decoratedresultset import DecoratedResultSet
176from lp.services.database.enumcol import DBEnum176from lp.services.database.enumcol import DBEnum
177from lp.services.database.interfaces import IStore177from lp.services.database.interfaces import IStore
178from lp.services.database.sqlbase import SQLBase, sqlvalues
179from lp.services.database.sqlobject import (
180 ForeignKey,
181 IntCol,
182 SQLMultipleJoin,
183 SQLObjectNotFound,
184 StringCol,
185)
186from lp.services.database.stormbase import StormBase178from lp.services.database.stormbase import StormBase
187from lp.services.database.stormexpr import WithMaterialized179from lp.services.database.stormexpr import WithMaterialized
188from lp.services.fields import DuplicateBug180from lp.services.fields import DuplicateBug
@@ -261,7 +253,6 @@ class BugTag(StormBase):
261 __storm_table__ = "BugTag"253 __storm_table__ = "BugTag"
262 id = Int(primary=True)254 id = Int(primary=True)
263255
264 bug = ForeignKey(dbName="bug", foreignKey="Bug", notNull=True)
265 bug_id = Int(name="bug", allow_none=False)256 bug_id = Int(name="bug", allow_none=False)
266 bug = Reference(bug_id, "Bug.id")257 bug = Reference(bug_id, "Bug.id")
267258
@@ -356,33 +347,36 @@ def update_bug_heat(bug_ids):
356347
357348
358@implementer(IBug, IInformationType)349@implementer(IBug, IInformationType)
359class Bug(SQLBase, InformationTypeMixin):350class Bug(StormBase, InformationTypeMixin):
360 """A bug."""351 """A bug."""
361352
362 _defaultOrder = "-id"353 __storm_table__ = "Bug"
354 __storm_order__ = "-id"
363355
364 # db field names356 # db field names
365 name = StringCol(unique=True, default=None)357 id = Int(primary=True)
366 title = StringCol(notNull=True)358 name = Unicode(default=None)
367 description = StringCol(notNull=False, default=None)359 title = Unicode(allow_none=False)
368 owner = ForeignKey(360 description = Unicode(allow_none=True, default=None)
369 dbName="owner",361 owner_id = Int(
370 foreignKey="Person",362 name="owner", validator=validate_public_person, allow_none=False
371 storm_validator=validate_public_person,363 )
372 notNull=True,364 owner = Reference(owner_id, "Person.id")
365 duplicateof_id = Int(name="duplicateof", default=None)
366 duplicateof = Reference(duplicateof_id, "Bug.id")
367 datecreated = DateTime(
368 allow_none=False, default=UTC_NOW, tzinfo=timezone.utc
369 )
370 date_last_updated = DateTime(
371 allow_none=False, default=UTC_NOW, tzinfo=timezone.utc
373 )372 )
374 duplicateof = ForeignKey(373 date_made_private = DateTime(
375 dbName="duplicateof", foreignKey="Bug", default=None374 allow_none=True, default=None, tzinfo=timezone.utc
376 )375 )
377 datecreated = UtcDateTimeCol(notNull=True, default=UTC_NOW)376 who_made_private_id = Int(
378 date_last_updated = UtcDateTimeCol(notNull=True, default=UTC_NOW)377 name="who_made_private", validator=validate_public_person, default=None
379 date_made_private = UtcDateTimeCol(notNull=False, default=None)
380 who_made_private = ForeignKey(
381 dbName="who_made_private",
382 foreignKey="Person",
383 storm_validator=validate_public_person,
384 default=None,
385 )378 )
379 who_made_private = Reference(who_made_private_id, "Person.id")
386 information_type = DBEnum(380 information_type = DBEnum(
387 enum=InformationType, allow_none=False, default=InformationType.PUBLIC381 enum=InformationType, allow_none=False, default=InformationType.PUBLIC
388 )382 )
@@ -397,25 +391,44 @@ class Bug(SQLBase, InformationTypeMixin):
397 BugWatch.bug_id,391 BugWatch.bug_id,
398 order_by=(BugWatch.bugtracker_id, BugWatch.remotebug),392 order_by=(BugWatch.bugtracker_id, BugWatch.remotebug),
399 )393 )
400 duplicates = SQLMultipleJoin("Bug", joinColumn="duplicateof", orderBy="id")394 duplicates = ReferenceSet("id", "Bug.duplicateof_id", order_by="Bug.id")
401 linked_bugbranches = ReferenceSet(395 linked_bugbranches = ReferenceSet(
402 "id", BugBranch.bug_id, order_by=BugBranch.id396 "id", BugBranch.bug_id, order_by=BugBranch.id
403 )397 )
404 date_last_message = UtcDateTimeCol(default=None)398 date_last_message = DateTime(default=None, tzinfo=timezone.utc)
405 number_of_duplicates = IntCol(notNull=True, default=0)399 number_of_duplicates = Int(allow_none=False, default=0)
406 message_count = IntCol(notNull=True, default=0)400 message_count = Int(allow_none=False, default=0)
407 users_affected_count = IntCol(notNull=True, default=0)401 users_affected_count = Int(allow_none=False, default=0)
408 users_unaffected_count = IntCol(notNull=True, default=0)402 users_unaffected_count = Int(allow_none=False, default=0)
409 heat = IntCol(notNull=True, default=0)403 heat = Int(allow_none=False, default=0)
410 heat_last_updated = UtcDateTimeCol(default=None)404 heat_last_updated = DateTime(default=None, tzinfo=timezone.utc)
411 latest_patch_uploaded = UtcDateTimeCol(default=None)405 latest_patch_uploaded = DateTime(default=None, tzinfo=timezone.utc)
412 lock_status = DBEnum(406 lock_status = DBEnum(
413 name="lock_status",407 name="lock_status",
414 enum=BugLockStatus,408 enum=BugLockStatus,
415 allow_none=False,409 allow_none=False,
416 default=BugLockStatus.UNLOCKED,410 default=BugLockStatus.UNLOCKED,
417 )411 )
418 lock_reason = StringCol(notNull=False, default=None)412 lock_reason = Unicode(allow_none=True, default=None)
413
414 def __init__(
415 self,
416 title,
417 owner,
418 description=None,
419 datecreated=DEFAULT,
420 date_made_private=None,
421 who_made_private=None,
422 information_type=InformationType.PUBLIC,
423 ):
424 super().__init__()
425 self.title = title
426 self.owner = owner
427 self.description = description
428 self.datecreated = datecreated
429 self.date_made_private = date_made_private
430 self.who_made_private = who_made_private
431 self.information_type = information_type
419432
420 @property433 @property
421 def locked(self):434 def locked(self):
@@ -1905,7 +1918,7 @@ class Bug(SQLBase, InformationTypeMixin):
1905 def _question_from_bug(self):1918 def _question_from_bug(self):
1906 for question in self.questions:1919 for question in self.questions:
1907 if (1920 if (
1908 question.owner_id == self.ownerID1921 question.owner_id == self.owner_id
1909 and question.datecreated == self.datecreated1922 and question.datecreated == self.datecreated
1910 ):1923 ):
1911 return question1924 return question
@@ -1934,10 +1947,12 @@ class Bug(SQLBase, InformationTypeMixin):
1934 # range.1947 # range.
1935 slices.append(1948 slices.append(
1936 BugMessage.index1949 BugMessage.index
1937 >= SQL(1950 >= Add(
1938 "(select max(index) from "1951 Select(
1939 "bugmessage where bug=%s) + 1 - %s"1952 Max(BugMessage.index),
1940 % (sqlvalues(self.id, -slice.start))1953 where=(BugMessage.bug == self),
1954 ),
1955 slice.start + 1,
1941 )1956 )
1942 )1957 )
1943 else:1958 else:
@@ -2397,7 +2412,7 @@ class Bug(SQLBase, InformationTypeMixin):
2397 try:2412 try:
2398 if duplicate_of is not None:2413 if duplicate_of is not None:
2399 field._validate(duplicate_of)2414 field._validate(duplicate_of)
2400 if self.duplicates:2415 if not self.duplicates.is_empty():
2401 user = getUtility(ILaunchBag).user2416 user = getUtility(ILaunchBag).user
2402 for duplicate in self.duplicates:2417 for duplicate in self.duplicates:
2403 old_value = duplicate.duplicateof2418 old_value = duplicate.duplicateof
@@ -3204,17 +3219,17 @@ class BugSet:
32043219
3205 def get(self, bugid):3220 def get(self, bugid):
3206 """See `IBugSet`."""3221 """See `IBugSet`."""
3207 try:3222 bug = IStore(Bug).get(Bug, int(bugid))
3208 return Bug.get(bugid)3223 if bug is None:
3209 except SQLObjectNotFound:
3210 raise NotFoundError(3224 raise NotFoundError(
3211 "Unable to locate bug with ID %s." % str(bugid)3225 "Unable to locate bug with ID %s." % str(bugid)
3212 )3226 )
3227 return bug
32133228
3214 def getByNameOrID(self, bugid):3229 def getByNameOrID(self, bugid):
3215 """See `IBugSet`."""3230 """See `IBugSet`."""
3216 if self.valid_bug_name_re.match(bugid):3231 if self.valid_bug_name_re.match(bugid):
3217 bug = Bug.selectOneBy(name=bugid)3232 bug = IStore(Bug).find(Bug, name=bugid).one()
3218 if bug is None:3233 if bug is None:
3219 raise NotFoundError("Unable to locate bug with ID %s." % bugid)3234 raise NotFoundError("Unable to locate bug with ID %s." % bugid)
3220 else:3235 else:
@@ -3334,6 +3349,8 @@ class BugSet:
3334 if params.tags:3349 if params.tags:
3335 bug.tags = params.tags3350 bug.tags = params.tags
33363351
3352 Store.of(bug).flush()
3353
3337 # Link the bug to the message.3354 # Link the bug to the message.
3338 BugMessage(bug=bug, message=params.msg, index=0)3355 BugMessage(bug=bug, message=params.msg, index=0)
33393356
@@ -3497,7 +3514,7 @@ def generate_subscription_with(bug, person):
3497 BugSubscription,3514 BugSubscription,
3498 Join(Bug, Bug.id == BugSubscription.bug_id),3515 Join(Bug, Bug.id == BugSubscription.bug_id),
3499 ],3516 ],
3500 where=Or(Bug.id == bug.id, Bug.duplicateofID == bug.id),3517 where=Or(Bug.id == bug.id, Bug.duplicateof_id == bug.id),
3501 ),3518 ),
3502 ),3519 ),
3503 WithMaterialized(3520 WithMaterialized(
diff --git a/lib/lp/bugs/model/bugtask.py b/lib/lp/bugs/model/bugtask.py
index 2a0dce7..2606bed 100644
--- a/lib/lp/bugs/model/bugtask.py
+++ b/lib/lp/bugs/model/bugtask.py
@@ -1019,7 +1019,7 @@ class BugTask(StormBase):
1019 return True1019 return True
1020 elif (1020 elif (
1021 self.status == BugTaskStatus.FIXRELEASED1021 self.status == BugTaskStatus.FIXRELEASED
1022 and user.id != self.bug.ownerID1022 and user.id != self.bug.owner_id
1023 and not user.inTeam(self.bug.owner)1023 and not user.inTeam(self.bug.owner)
1024 ):1024 ):
1025 # The bug reporter can reopen a Fix Released bug.1025 # The bug reporter can reopen a Fix Released bug.
@@ -1606,7 +1606,7 @@ class BugTaskSet:
16061606
1607 people_ids = set(1607 people_ids = set(
1608 [bugtask.assignee_id for bugtask in bugtasks]1608 [bugtask.assignee_id for bugtask in bugtasks]
1609 + [bugtask.bug.ownerID for bugtask in bugtasks]1609 + [bugtask.bug.owner_id for bugtask in bugtasks]
1610 )1610 )
1611 people = getUtility(IPersonSet).getPrecachedPersonsFromIDs(people_ids)1611 people = getUtility(IPersonSet).getPrecachedPersonsFromIDs(people_ids)
1612 return {person.id: person for person in people}1612 return {person.id: person for person in people}
diff --git a/lib/lp/bugs/model/bugtasksearch.py b/lib/lp/bugs/model/bugtasksearch.py
index 9ec4c25..7f7dd20 100644
--- a/lib/lp/bugs/model/bugtasksearch.py
+++ b/lib/lp/bugs/model/bugtasksearch.py
@@ -1105,7 +1105,7 @@ def _build_exclude_conjoined_clause(milestone):
1105 """1105 """
1106 # XXX: EdwinGrubbs 2010-12-15 bug=6829891106 # XXX: EdwinGrubbs 2010-12-15 bug=682989
1107 # (ConjoinedPrimary.bug == X) produces the wrong sql, but1107 # (ConjoinedPrimary.bug == X) produces the wrong sql, but
1108 # (ConjoinedPrimary.bugID == X) works right. This bug applies to1108 # (ConjoinedPrimary.bug_id == X) works right. This bug applies to
1109 # all foreign keys on the ClassAlias.1109 # all foreign keys on the ClassAlias.
11101110
1111 # Perform a LEFT JOIN to the conjoined primary bugtask. If the1111 # Perform a LEFT JOIN to the conjoined primary bugtask. If the
diff --git a/lib/lp/bugs/model/personsubscriptioninfo.py b/lib/lp/bugs/model/personsubscriptioninfo.py
index 8e28966..aaff8d4 100644
--- a/lib/lp/bugs/model/personsubscriptioninfo.py
+++ b/lib/lp/bugs/model/personsubscriptioninfo.py
@@ -184,7 +184,7 @@ class PersonSubscriptions:
184 # Preload bug owners, then all pillars.184 # Preload bug owners, then all pillars.
185 list(185 list(
186 getUtility(IPersonSet).getPrecachedPersonsFromIDs(186 getUtility(IPersonSet).getPrecachedPersonsFromIDs(
187 [bug.ownerID for bug in bugs]187 [bug.owner_id for bug in bugs]
188 )188 )
189 )189 )
190 all_tasks = load_referencing(BugTask, bugs, ["bug_id"])190 all_tasks = load_referencing(BugTask, bugs, ["bug_id"])
diff --git a/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst b/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst
index bfa0b6e..116baaa 100644
--- a/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst
+++ b/lib/lp/bugs/stories/bugs/xx-bug-text-pages.rst
@@ -9,14 +9,15 @@ To demonstrate this feature, we'll use bug 1.
9We'll start by adding some attachments to the bug:9We'll start by adding some attachments to the bug:
1010
11 >>> from io import BytesIO11 >>> from io import BytesIO
12 >>> from lp.services.database.sqlbase import flush_database_updates
13 >>> from lp.testing import login, logout
14 >>> from lp.bugs.model.bug import Bug12 >>> from lp.bugs.model.bug import Bug
15 >>> from lp.registry.model.person import Person13 >>> from lp.registry.model.person import Person
14 >>> from lp.services.database.interfaces import IStore
15 >>> from lp.services.database.sqlbase import flush_database_updates
16 >>> from lp.testing import login, logout
16 >>> login("foo.bar@canonical.com")17 >>> login("foo.bar@canonical.com")
17 >>> mark = Person.selectOneBy(name="mark")18 >>> mark = Person.selectOneBy(name="mark")
18 >>> mark.display_name = "M\xe1rk Sh\xfattlew\xf2rth"19 >>> mark.display_name = "M\xe1rk Sh\xfattlew\xf2rth"
19 >>> bug = Bug.get(1)20 >>> bug = IStore(Bug).get(Bug, 1)
20 >>> content = BytesIO(b"<html><body>bogus</body></html>")21 >>> content = BytesIO(b"<html><body>bogus</body></html>")
21 >>> a1 = bug.addAttachment(22 >>> a1 = bug.addAttachment(
22 ... mark,23 ... mark,
diff --git a/lib/lp/bugs/templates/bug-portlet-duplicates.pt b/lib/lp/bugs/templates/bug-portlet-duplicates.pt
index 0a11c96..a2f0afa 100644
--- a/lib/lp/bugs/templates/bug-portlet-duplicates.pt
+++ b/lib/lp/bugs/templates/bug-portlet-duplicates.pt
@@ -3,7 +3,7 @@
3 xmlns:metal="http://xml.zope.org/namespaces/metal"3 xmlns:metal="http://xml.zope.org/namespaces/metal"
4 xmlns:i18n="http://xml.zope.org/namespaces/i18n"4 xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5 class="portlet" id="portlet-duplicates"5 class="portlet" id="portlet-duplicates"
6 tal:condition="context/duplicates">6 tal:condition="not: context/duplicates/is_empty">
7 <h2>Duplicates of this bug</h2>7 <h2>Duplicates of this bug</h2>
8 <ul>8 <ul>
9 <li tal:repeat="dupe view/duplicates">9 <li tal:repeat="dupe view/duplicates">
diff --git a/lib/lp/bugs/tests/bugs-emailinterface.rst b/lib/lp/bugs/tests/bugs-emailinterface.rst
index 1a8a900..6555137 100644
--- a/lib/lp/bugs/tests/bugs-emailinterface.rst
+++ b/lib/lp/bugs/tests/bugs-emailinterface.rst
@@ -2085,7 +2085,7 @@ An empty unsigned mail to new@malone:
2085If we submit an email with no affects command, it is rejected.2085If we submit an email with no affects command, it is rejected.
20862086
2087 >>> from lp.bugs.model.bug import Bug2087 >>> from lp.bugs.model.bug import Bug
2088 >>> before_count = Bug.select().count()2088 >>> before_count = IStore(Bug).find(Bug).count()
2089 >>> submit_mail = b"""From: Foo Bar <foo.bar@canonical.com>2089 >>> submit_mail = b"""From: Foo Bar <foo.bar@canonical.com>
2090 ... To: new@bugs.launchpad.ubuntu.com2090 ... To: new@bugs.launchpad.ubuntu.com
2091 ... Date: Fri Jun 17 10:20:23 BST 20052091 ... Date: Fri Jun 17 10:20:23 BST 2005
@@ -2099,7 +2099,7 @@ If we submit an email with no affects command, it is rejected.
2099 ... """2099 ... """
21002100
2101 >>> process_email(submit_mail)2101 >>> process_email(submit_mail)
2102 >>> before_count == Bug.select().count()2102 >>> before_count == IStore(Bug).find(Bug).count()
2103 True2103 True
21042104
2105 >>> print_latest_email()2105 >>> print_latest_email()
@@ -2118,7 +2118,7 @@ required. If it is missing, the message is also rejected.
2118XXX: Gavin Panella 2009-07-24 bug=404010: The need for this test2118XXX: Gavin Panella 2009-07-24 bug=404010: The need for this test
2119arises from the implementation of MaloneHandler.2119arises from the implementation of MaloneHandler.
21202120
2121 >>> before_count = Bug.select().count()2121 >>> before_count = IStore(Bug).find(Bug).count()
2122 >>> submit_mail = b"""From: Foo Bar <foo.bar@canonical.com>2122 >>> submit_mail = b"""From: Foo Bar <foo.bar@canonical.com>
2123 ... To: new@bugs.launchpad.ubuntu.com2123 ... To: new@bugs.launchpad.ubuntu.com
2124 ... Date: Fri Jun 17 10:20:23 BST 20052124 ... Date: Fri Jun 17 10:20:23 BST 2005
@@ -2130,7 +2130,7 @@ arises from the implementation of MaloneHandler.
2130 ... """2130 ... """
21312131
2132 >>> process_email(submit_mail)2132 >>> process_email(submit_mail)
2133 >>> before_count == Bug.select().count()2133 >>> before_count == IStore(Bug).find(Bug).count()
2134 True2134 True
21352135
2136 >>> print_latest_email()2136 >>> print_latest_email()
@@ -2151,7 +2151,7 @@ edit@bugs).
2151XXX: Gavin Panella 2009-07-24 bug=404010: The need for this test2151XXX: Gavin Panella 2009-07-24 bug=404010: The need for this test
2152arises from the implementation of MaloneHandler.2152arises from the implementation of MaloneHandler.
21532153
2154 >>> before_count = Bug.select().count()2154 >>> before_count = IStore(Bug).find(Bug).count()
2155 >>> submit_mail = b"""\2155 >>> submit_mail = b"""\
2156 ... From: Foo Bar <foo.bar@canonical.com>2156 ... From: Foo Bar <foo.bar@canonical.com>
2157 ... To: new@bugs.launchpad.ubuntu.com2157 ... To: new@bugs.launchpad.ubuntu.com
@@ -2162,7 +2162,7 @@ arises from the implementation of MaloneHandler.
2162 ... """2162 ... """
21632163
2164 >>> process_email(submit_mail)2164 >>> process_email(submit_mail)
2165 >>> before_count == Bug.select().count()2165 >>> before_count == IStore(Bug).find(Bug).count()
2166 True2166 True
21672167
2168 >>> print_latest_email()2168 >>> print_latest_email()
@@ -2184,7 +2184,7 @@ bug-related commands do blow up before the check for a bugtask is
2184reached. For example, unsubscribing oneself from a private bug then2184reached. For example, unsubscribing oneself from a private bug then
2185linking a CVE.2185linking a CVE.
21862186
2187 >>> before_count = Bug.select().count()2187 >>> before_count = IStore(Bug).find(Bug).count()
2188 >>> submit_mail = b"""\2188 >>> submit_mail = b"""\
2189 ... From: Foo Bar <foo.bar@canonical.com>2189 ... From: Foo Bar <foo.bar@canonical.com>
2190 ... To: new@bugs.launchpad.ubuntu.com2190 ... To: new@bugs.launchpad.ubuntu.com
@@ -2197,7 +2197,7 @@ linking a CVE.
2197 ... """2197 ... """
21982198
2199 >>> process_email(submit_mail)2199 >>> process_email(submit_mail)
2200 >>> before_count == Bug.select().count()2200 >>> before_count == IStore(Bug).find(Bug).count()
2201 True2201 True
22022202
2203 >>> print_latest_email()2203 >>> print_latest_email()
diff --git a/lib/lp/bugs/vocabularies.py b/lib/lp/bugs/vocabularies.py
index 9b337e0..5586ef3 100644
--- a/lib/lp/bugs/vocabularies.py
+++ b/lib/lp/bugs/vocabularies.py
@@ -56,7 +56,6 @@ from lp.services.webapp.vocabulary import (
56 CountableIterator,56 CountableIterator,
57 IHugeVocabulary,57 IHugeVocabulary,
58 NamedSQLObjectVocabulary,58 NamedSQLObjectVocabulary,
59 SQLObjectVocabularyBase,
60 StormVocabularyBase,59 StormVocabularyBase,
61)60)
6261
@@ -85,9 +84,9 @@ class UsesBugsDistributionVocabulary(DistributionVocabulary):
85 )84 )
8685
8786
88class BugVocabulary(SQLObjectVocabularyBase):87class BugVocabulary(StormVocabularyBase):
89 _table = Bug88 _table = Bug
90 _orderBy = "id"89 _order_by = "id"
9190
9291
93@implementer(IHugeVocabulary)92@implementer(IHugeVocabulary)
diff --git a/lib/lp/registry/tests/test_person.py b/lib/lp/registry/tests/test_person.py
index e0f005c..3646ff7 100644
--- a/lib/lp/registry/tests/test_person.py
+++ b/lib/lp/registry/tests/test_person.py
@@ -1016,7 +1016,7 @@ class TestPersonStates(TestCaseWithFactory):
1016 )1016 )
10171017
1018 def test_Bug_person_validator(self):1018 def test_Bug_person_validator(self):
1019 bug = Bug.select(limit=1)[0]1019 bug = IStore(Bug).find(Bug).first()
1020 for attr_name in ["owner", "who_made_private"]:1020 for attr_name in ["owner", "who_made_private"]:
1021 self.assertRaises(1021 self.assertRaises(
1022 PrivatePersonLinkageError, setattr, bug, attr_name, self.myteam1022 PrivatePersonLinkageError, setattr, bug, attr_name, self.myteam
diff --git a/lib/lp/scripts/harness.py b/lib/lp/scripts/harness.py
index 7be9884..a5a03ec 100644
--- a/lib/lp/scripts/harness.py
+++ b/lib/lp/scripts/harness.py
@@ -77,8 +77,8 @@ def _get_locals():
77 ds = DistroSeries.get(1)77 ds = DistroSeries.get(1)
78 prod = Product.get(1)78 prod = Product.get(1)
79 proj = ProjectGroup.get(1)79 proj = ProjectGroup.get(1)
80 b2 = Bug.get(2)80 b2 = store.get(Bug, 2)
81 b1 = Bug.get(1)81 b1 = store.get(Bug, 1)
82 s = store.get(Specification, 1)82 s = store.get(Specification, 1)
83 q = store.get(Question, 1)83 q = store.get(Question, 1)
84 # Silence unused name warnings84 # Silence unused name warnings
diff --git a/lib/lp/services/database/tests/test_bulk.py b/lib/lp/services/database/tests/test_bulk.py
index 6cdf569..b9f64c8 100644
--- a/lib/lp/services/database/tests/test_bulk.py
+++ b/lib/lp/services/database/tests/test_bulk.py
@@ -252,7 +252,7 @@ class TestLoaders(TestCaseWithFactory):
252 expected = {bug.owner for bug in owning_objects}252 expected = {bug.owner for bug in owning_objects}
253 self.assertEqual(253 self.assertEqual(
254 expected,254 expected,
255 set(bulk.load_related(Person, owning_objects, ["ownerID"])),255 set(bulk.load_related(Person, owning_objects, ["owner_id"])),
256 )256 )
257257
258 def test_load_referencing(self):258 def test_load_referencing(self):
diff --git a/lib/lp/services/statistics/model/statistics.py b/lib/lp/services/statistics/model/statistics.py
index 4b4ff60..f0a182e 100644
--- a/lib/lp/services/statistics/model/statistics.py
+++ b/lib/lp/services/statistics/model/statistics.py
@@ -106,10 +106,10 @@ class LaunchpadStatisticSet:
106 getUtility(IPersonSet).updateStatistics()106 getUtility(IPersonSet).updateStatistics()
107107
108 def _updateMaloneStatistics(self, ztm):108 def _updateMaloneStatistics(self, ztm):
109 self.update("bug_count", Bug.select().count())109 store = IStore(Bug)
110 self.update("bug_count", store.find(Bug).count())
110 ztm.commit()111 ztm.commit()
111112
112 store = IStore(BugTask)
113 self.update("bugtask_count", store.find(BugTask).count())113 self.update("bugtask_count", store.find(BugTask).count())
114 ztm.commit()114 ztm.commit()
115115

Subscribers

People subscribed via source and target branches

to status/vote changes: