← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/upgrade-storm into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/upgrade-storm into lp:launchpad.

Commit message:
Upgrade to storm 0.20.0.99-lp-r410.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/upgrade-storm/+merge/365648

Storm has its own CASE implementation now, so drop our local one.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/upgrade-storm into lp:launchpad.
=== modified file 'constraints.txt'
--- constraints.txt	2019-03-19 04:13:23 +0000
+++ constraints.txt	2019-04-08 07:34:45 +0000
@@ -354,8 +354,8 @@
 snowballstemmer==1.2.1
 soupmatchers==0.4
 sphinxcontrib-websupport==1.0.1
-# lp:~launchpad-committers/storm/with-without-datetime
-storm==0.19.0.99-lpwithnodatetime-r408
+# lp:~launchpad-committers/storm/lp
+storm==0.20.0.99-lp-r410
 subprocess32==3.2.6
 subvertpy==0.9.1
 testresources==0.2.7

=== modified file 'lib/lp/registry/vocabularies.py'
--- lib/lp/registry/vocabularies.py	2018-05-14 09:25:45 +0000
+++ lib/lp/registry/vocabularies.py	2019-04-08 07:34:45 +0000
@@ -72,6 +72,7 @@
     CONTAINSSTRING,
     OR,
     )
+from storm.databases.postgres import Case
 from storm.expr import (
     And,
     Column,
@@ -178,10 +179,7 @@
     SQLBase,
     sqlvalues,
     )
-from lp.services.database.stormexpr import (
-    Case,
-    RegexpMatch,
-    )
+from lp.services.database.stormexpr import RegexpMatch
 from lp.services.helpers import (
     ensure_unicode,
     shortlist,
@@ -2004,13 +2002,13 @@
                         *self._clauses),
                     tables=self._table))))
         rank = Case(
-            when=(
+            cases=(
                 (self._table.name == query, 100),
                 (self._table.name.startswith(query + "-"), 75),
                 (self._table.name.startswith(query), 50),
                 (self._table.name.contains_string("-" + query), 25),
                 ),
-            else_=1)
+            default=1)
         results.order_by(Desc(rank), self._table.name)
         return self.iterator(results.count(), results, self.toTerm)
 
@@ -2169,7 +2167,7 @@
             "sourcepackagename", SearchableDSPC)
         searchable_dspc_binpkgnames = Column("binpkgnames", SearchableDSPC)
         rank = Case(
-            when=(
+            cases=(
                 # name == query
                 (searchable_dspc_name == query, 100),
                 (RegexpMatch(searchable_dspc_binpkgnames,
@@ -2187,7 +2185,7 @@
                 (RegexpMatch(searchable_dspc_binpkgnames,
                              r'-%s' % query_re), 30),
                 ),
-            else_=1)
+            default=1)
         results = store.with_(searchable_dspc_cte).using(
             DistributionSourcePackageInDatabase, SearchableDSPC).find(
                 (DistributionSourcePackageInDatabase,

=== modified file 'lib/lp/services/database/stormexpr.py'
--- lib/lp/services/database/stormexpr.py	2018-05-14 09:25:45 +0000
+++ lib/lp/services/database/stormexpr.py	2019-04-08 07:34:45 +0000
@@ -9,7 +9,6 @@
     'ArrayContains',
     'ArrayIntersects',
     'BulkUpdate',
-    'Case',
     'ColumnSelect',
     'Concatenate',
     'CountDistinct',
@@ -28,10 +27,7 @@
     ]
 
 from storm import Undef
-from storm.exceptions import (
-    ClassInfoError,
-    ExprError,
-    )
+from storm.exceptions import ClassInfoError
 from storm.expr import (
     BinaryOper,
     COLUMN_NAME,
@@ -234,32 +230,6 @@
     suffix = "NULLS LAST"
 
 
-class Case(Expr):
-    """Generic conditional expression."""
-    __slots__ = ("when", "else_")
-
-    def __init__(self, when, else_=None):
-        if not when:
-            raise ExprError("Must specify at least one WHEN clause")
-        self.when = when
-        self.else_ = else_
-
-
-@compile.when(Case)
-def compile_case(compile, expr, state):
-    tokens = ["CASE"]
-    for condition, result in expr.when:
-        tokens.append(" WHEN ")
-        tokens.append(compile(condition, state))
-        tokens.append(" THEN ")
-        tokens.append(compile(result, state))
-    if expr.else_ is not None:
-        tokens.append(" ELSE ")
-        tokens.append(compile(expr.else_, state))
-    tokens.append(" END")
-    return "".join(tokens)
-
-
 class RegexpMatch(BinaryOper):
     __slots__ = ()
     oper = " ~ "


Follow ups