launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30207
[Merge] ~cjwatson/launchpad:storm-0.26 into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:storm-0.26 into launchpad:master.
Commit message:
Upgrade to storm 0.26+lp418
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/446345
This also takes advantage of `Comparable.contains_string(case_sensitive=False)` (added in 0.25) and `storm.expr.Is` and `storm.expr.IsNot` (added in 0.26).
Dependencies MP: https://code.launchpad.net/~cjwatson/lp-source-dependencies/+git/lp-source-dependencies/+merge/446344
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:storm-0.26 into launchpad:master.
diff --git a/lib/lp/charms/model/charmrecipe.py b/lib/lp/charms/model/charmrecipe.py
index eb3891c..2195dab 100644
--- a/lib/lp/charms/model/charmrecipe.py
+++ b/lib/lp/charms/model/charmrecipe.py
@@ -17,7 +17,7 @@ from lazr.lifecycle.event import ObjectCreatedEvent
from pymacaroons import Macaroon
from pymacaroons.serializers import JsonSerializer
from storm.databases.postgres import JSON
-from storm.expr import Cast, Coalesce, Except
+from storm.expr import Cast, Coalesce, Except, Is
from storm.locals import (
And,
Bool,
@@ -112,12 +112,7 @@ from lp.services.database.decoratedresultset import DecoratedResultSet
from lp.services.database.enumcol import DBEnum
from lp.services.database.interfaces import IPrimaryStore, IStore
from lp.services.database.stormbase import StormBase
-from lp.services.database.stormexpr import (
- Greatest,
- IsTrue,
- JSONExtract,
- NullsLast,
-)
+from lp.services.database.stormexpr import Greatest, JSONExtract, NullsLast
from lp.services.features import getFeatureFlag
from lp.services.job.interfaces.job import JobStatus
from lp.services.job.model.job import Job
@@ -1190,8 +1185,8 @@ class CharmRecipeSet:
minutes=config.charms.auto_build_frequency
)
stale_clauses = [
- IsTrue(CharmRecipe.is_stale),
- IsTrue(CharmRecipe.auto_build),
+ Is(CharmRecipe.is_stale, True),
+ Is(CharmRecipe.auto_build, True),
]
recent_clauses = [
CharmRecipeJob.recipe_id == CharmRecipe.id,
diff --git a/lib/lp/registry/model/distroseries.py b/lib/lp/registry/model/distroseries.py
index 68b7275..f0b7064 100644
--- a/lib/lp/registry/model/distroseries.py
+++ b/lib/lp/registry/model/distroseries.py
@@ -17,7 +17,7 @@ from typing import List
import apt_pkg
from lazr.delegates import delegate_to
-from storm.expr import SQL, And, Column, Desc, Join, Or, Select, Table
+from storm.expr import SQL, And, Column, Desc, Is, Join, Or, Select, Table
from storm.locals import JSON, Int, Reference, ReferenceSet
from storm.store import Store
from zope.component import getUtility
@@ -77,7 +77,7 @@ from lp.services.database.sqlobject import (
SQLObjectNotFound,
StringCol,
)
-from lp.services.database.stormexpr import IsTrue, WithMaterialized, fti_search
+from lp.services.database.stormexpr import WithMaterialized, fti_search
from lp.services.librarian.interfaces import ILibraryFileAliasSet
from lp.services.librarian.model import LibraryFileAlias
from lp.services.mail.signedmessage import signed_message_from_bytes
@@ -760,7 +760,7 @@ class DistroSeries(
DistroSeriesLanguage,
DistroSeriesLanguage.language == Language.id,
DistroSeriesLanguage.distroseries == self,
- IsTrue(Language.visible),
+ Is(Language.visible, True),
)
.order_by(Language.englishname)
)
@@ -1009,12 +1009,12 @@ class DistroSeries(
IStore(Language)
.find(
Language,
- IsTrue(Language.visible),
+ Is(Language.visible, True),
Language.id == POFile.languageID,
Language.code != "en",
POFile.potemplateID == POTemplate.id,
POTemplate.distroseries == self,
- IsTrue(POTemplate.iscurrent),
+ Is(POTemplate.iscurrent, True),
)
.config(distinct=True)
)
diff --git a/lib/lp/services/database/stormexpr.py b/lib/lp/services/database/stormexpr.py
index 92b3ce0..3a7aeb2 100644
--- a/lib/lp/services/database/stormexpr.py
+++ b/lib/lp/services/database/stormexpr.py
@@ -16,8 +16,6 @@ __all__ = [
"get_where_for_reference",
"ImmutablePgJSON",
"IsDistinctFrom",
- "IsFalse",
- "IsTrue",
"JSONContains",
"JSONExtract",
"NullCount",
@@ -231,28 +229,6 @@ class ArrayIntersects(CompoundOper):
oper = "&&"
-class IsTrue(SuffixExpr):
- """True iff the input Boolean expression is `TRUE`.
-
- Unlike `expr` or `expr == True`, this returns `FALSE` when
- `expr IS NULL`.
- """
-
- __slots__ = ()
- suffix = "IS TRUE"
-
-
-class IsFalse(SuffixExpr):
- """True iff the input Boolean expression is `FALSE`.
-
- Unlike `Not(expr)` or `expr == False`, this returns `FALSE` when
- `expr IS NULL`.
- """
-
- __slots__ = ()
- suffix = "IS FALSE"
-
-
class IsDistinctFrom(CompoundOper):
"""True iff the left side is distinct from the right side."""
diff --git a/lib/lp/services/statistics/tests/test_update_stats.py b/lib/lp/services/statistics/tests/test_update_stats.py
index 9d7652e..577ff58 100644
--- a/lib/lp/services/statistics/tests/test_update_stats.py
+++ b/lib/lp/services/statistics/tests/test_update_stats.py
@@ -8,7 +8,7 @@ import subprocess
import unittest
from datetime import timedelta
-from storm.expr import Cast, Max, Select
+from storm.expr import Cast, Is, Max, Select
from zope.component import getUtility
from lp.registry.interfaces.distribution import IDistributionSet
@@ -17,7 +17,6 @@ from lp.registry.model.distroseries import DistroSeries
from lp.services.config import config
from lp.services.database.constants import UTC_NOW
from lp.services.database.interfaces import IStore
-from lp.services.database.stormexpr import IsTrue
from lp.services.statistics.model.statistics import LaunchpadStatistic
from lp.services.worlddata.interfaces.language import ILanguageSet
from lp.services.worlddata.model.language import Language
@@ -134,7 +133,7 @@ class UpdateStatsTest(unittest.TestCase):
store.find(
DistroSeriesLanguage,
DistroSeriesLanguage.language == Language.id,
- IsTrue(Language.visible),
+ Is(Language.visible, True),
term,
).count(),
)
diff --git a/lib/lp/soyuz/scripts/expire_archive_files.py b/lib/lp/soyuz/scripts/expire_archive_files.py
index 13af377..6f1ef0f 100755
--- a/lib/lp/soyuz/scripts/expire_archive_files.py
+++ b/lib/lp/soyuz/scripts/expire_archive_files.py
@@ -3,12 +3,12 @@
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
-from storm.expr import And, Cast, Except, Not, Or, Select
+from storm.expr import And, Cast, Except, Is, Not, Or, Select
from lp.registry.model.person import Person
from lp.services.database.constants import UTC_NOW
from lp.services.database.interfaces import IStore
-from lp.services.database.stormexpr import Concatenate, IsTrue
+from lp.services.database.stormexpr import Concatenate
from lp.services.librarian.model import LibraryFileAlias
from lp.services.scripts.base import LaunchpadCronScript
from lp.soyuz.enums import ArchivePurpose
@@ -190,7 +190,7 @@ class ArchiveExpirer(LaunchpadCronScript):
Archive.purpose == ArchivePurpose.PPA,
),
And(
- IsTrue(Archive.private),
+ Is(Archive.private, True),
Not(full_archive_name.is_in(self.always_expire)),
),
Not(Archive.purpose.is_in(archive_types)),
diff --git a/lib/lp/translations/model/distroserieslanguage.py b/lib/lp/translations/model/distroserieslanguage.py
index c0b1e79..d147f4b 100644
--- a/lib/lp/translations/model/distroserieslanguage.py
+++ b/lib/lp/translations/model/distroserieslanguage.py
@@ -12,7 +12,7 @@ __all__ = [
from datetime import datetime, timezone
from operator import itemgetter
-from storm.expr import LeftJoin
+from storm.expr import Is, LeftJoin
from storm.locals import DateTime, Desc, Int, Join, Reference
from zope.interface import implementer
@@ -21,7 +21,6 @@ from lp.services.database.constants import DEFAULT, UTC_NOW
from lp.services.database.decoratedresultset import DecoratedResultSet
from lp.services.database.interfaces import IStore
from lp.services.database.stormbase import StormBase
-from lp.services.database.stormexpr import IsTrue
from lp.translations.interfaces.distroserieslanguage import (
IDistroSeriesLanguage,
IDistroSeriesLanguageSet,
@@ -86,7 +85,7 @@ class DistroSeriesLanguage(StormBase, RosettaStats):
(POFile, SourcePackageName),
POFile.language == self.language,
POTemplate.distroseries == self.distroseries,
- IsTrue(POTemplate.iscurrent),
+ Is(POTemplate.iscurrent, True),
)
.order_by(Desc(POTemplate.priority), POFile.id)
)
diff --git a/lib/lp/translations/model/pofile.py b/lib/lp/translations/model/pofile.py
index 6539f65..e2e13b9 100644
--- a/lib/lp/translations/model/pofile.py
+++ b/lib/lp/translations/model/pofile.py
@@ -22,12 +22,10 @@ from storm.expr import (
Exists,
Join,
LeftJoin,
- Like,
Not,
Or,
Select,
Union,
- like_escape,
)
from storm.info import ClassAlias
from storm.store import EmptyResultSet, Store
@@ -167,11 +165,8 @@ class POFileMixIn(RosettaStats):
distinct=True,
)
),
- Like(
- POTranslation.translation,
- "%" + text.translate(like_escape) + "%",
- "!",
- case_sensitive=False,
+ POTranslation.translation.contains_string(
+ text, case_sensitive=False
),
]
return Select(
@@ -221,12 +216,7 @@ class POFileMixIn(RosettaStats):
),
)
),
- Like(
- POMsgID.msgid,
- "%" + text.translate(like_escape) + "%",
- "!",
- case_sensitive=False,
- ),
+ POMsgID.msgid.contains_string(text, case_sensitive=False),
]
return Select(
POTMsgSet.id,
diff --git a/lib/lp/translations/model/potmsgset.py b/lib/lp/translations/model/potmsgset.py
index 4635d5c..ed9c0cb 100644
--- a/lib/lp/translations/model/potmsgset.py
+++ b/lib/lp/translations/model/potmsgset.py
@@ -16,6 +16,8 @@ from storm.expr import (
Coalesce,
Column,
Desc,
+ Is,
+ IsNot,
Join,
Not,
Or,
@@ -36,7 +38,6 @@ from lp.services.database.interfaces import IStore
from lp.services.database.sqlbase import SQLBase, sqlvalues
from lp.services.database.sqlobject import StringCol
from lp.services.database.stormexpr import (
- IsTrue,
NullsFirst,
NullsLast,
WithMaterialized,
@@ -325,8 +326,8 @@ class POTMsgSet(SQLBase):
):
"""See `IPOTMsgSet`."""
clauses = [
- Not(IsTrue(TranslationMessage.is_current_ubuntu)),
- Not(IsTrue(TranslationMessage.is_current_upstream)),
+ IsNot(TranslationMessage.is_current_ubuntu, True),
+ IsNot(TranslationMessage.is_current_upstream, True),
TranslationMessage.potmsgset == self,
TranslationMessage.language == language,
SQL(make_plurals_sql_fragment("msgstr%(form)d IS NOT NULL", "OR")),
@@ -384,8 +385,8 @@ class POTMsgSet(SQLBase):
# a way so that indexes are indeed hit when the query is executed.
# Also note that there is a NOT(in_use_clause) index.
in_use_clause = Or(
- IsTrue(TranslationMessage.is_current_ubuntu),
- IsTrue(TranslationMessage.is_current_upstream),
+ Is(TranslationMessage.is_current_ubuntu, True),
+ Is(TranslationMessage.is_current_upstream, True),
)
# Present a list of language + usage constraints to sql. A language
# can either be unconstrained, used, or suggested depending on which
diff --git a/lib/lp/translations/model/translationimportqueue.py b/lib/lp/translations/model/translationimportqueue.py
index f27c939..3565e27 100644
--- a/lib/lp/translations/model/translationimportqueue.py
+++ b/lib/lp/translations/model/translationimportqueue.py
@@ -17,7 +17,7 @@ from io import BytesIO
from operator import attrgetter
from textwrap import dedent
-from storm.expr import SQL, Alias, And, Func, Or, Select
+from storm.expr import SQL, Alias, And, Func, Is, Or, Select
from storm.locals import Bool, DateTime, Int, Reference, Unicode
from zope.component import getUtility, queryAdapter
from zope.interface import implementer
@@ -42,7 +42,6 @@ from lp.services.database.interfaces import (
)
from lp.services.database.sqlbase import quote
from lp.services.database.stormbase import StormBase
-from lp.services.database.stormexpr import IsFalse
from lp.services.librarian.interfaces.client import ILibrarianClient
from lp.services.worlddata.interfaces.language import ILanguageSet
from lp.translations.enums import RosettaImportStatus
@@ -1477,7 +1476,7 @@ class TranslationImportQueue:
[
TranslationImportQueueEntry.distroseries
== DistroSeries.id,
- IsFalse(DistroSeries.defer_translation_imports),
+ Is(DistroSeries.defer_translation_imports, False),
]
)
diff --git a/requirements/launchpad.txt b/requirements/launchpad.txt
index a76d45e..3392b12 100644
--- a/requirements/launchpad.txt
+++ b/requirements/launchpad.txt
@@ -170,7 +170,7 @@ soupsieve==1.9
statsd==3.3.0
stevedore==1.32.0
# lp:~launchpad-committers/storm/lp
-storm==0.24+lp417
+storm==0.26+lp418
subprocess32==3.2.6
tenacity==6.1.0
testresources==0.2.7