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

Proposed by Colin Watson
Status: Merged
Merged at revision: 18925
Proposed branch: lp:~cjwatson/launchpad/upgrade-storm
Merge into: lp:launchpad
Diff against target: 129 lines (+9/-41)
3 files modified
constraints.txt (+2/-2)
lib/lp/registry/vocabularies.py (+6/-8)
lib/lp/services/database/stormexpr.py (+1/-31)
To merge this branch: bzr merge lp:~cjwatson/launchpad/upgrade-storm
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+365648@code.launchpad.net

Commit message

Upgrade to storm 0.20.0.99-lp-r410.

Description of the change

Storm has its own CASE implementation now, so drop our local one.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'constraints.txt'
2--- constraints.txt 2019-03-19 04:13:23 +0000
3+++ constraints.txt 2019-04-08 07:34:45 +0000
4@@ -354,8 +354,8 @@
5 snowballstemmer==1.2.1
6 soupmatchers==0.4
7 sphinxcontrib-websupport==1.0.1
8-# lp:~launchpad-committers/storm/with-without-datetime
9-storm==0.19.0.99-lpwithnodatetime-r408
10+# lp:~launchpad-committers/storm/lp
11+storm==0.20.0.99-lp-r410
12 subprocess32==3.2.6
13 subvertpy==0.9.1
14 testresources==0.2.7
15
16=== modified file 'lib/lp/registry/vocabularies.py'
17--- lib/lp/registry/vocabularies.py 2018-05-14 09:25:45 +0000
18+++ lib/lp/registry/vocabularies.py 2019-04-08 07:34:45 +0000
19@@ -72,6 +72,7 @@
20 CONTAINSSTRING,
21 OR,
22 )
23+from storm.databases.postgres import Case
24 from storm.expr import (
25 And,
26 Column,
27@@ -178,10 +179,7 @@
28 SQLBase,
29 sqlvalues,
30 )
31-from lp.services.database.stormexpr import (
32- Case,
33- RegexpMatch,
34- )
35+from lp.services.database.stormexpr import RegexpMatch
36 from lp.services.helpers import (
37 ensure_unicode,
38 shortlist,
39@@ -2004,13 +2002,13 @@
40 *self._clauses),
41 tables=self._table))))
42 rank = Case(
43- when=(
44+ cases=(
45 (self._table.name == query, 100),
46 (self._table.name.startswith(query + "-"), 75),
47 (self._table.name.startswith(query), 50),
48 (self._table.name.contains_string("-" + query), 25),
49 ),
50- else_=1)
51+ default=1)
52 results.order_by(Desc(rank), self._table.name)
53 return self.iterator(results.count(), results, self.toTerm)
54
55@@ -2169,7 +2167,7 @@
56 "sourcepackagename", SearchableDSPC)
57 searchable_dspc_binpkgnames = Column("binpkgnames", SearchableDSPC)
58 rank = Case(
59- when=(
60+ cases=(
61 # name == query
62 (searchable_dspc_name == query, 100),
63 (RegexpMatch(searchable_dspc_binpkgnames,
64@@ -2187,7 +2185,7 @@
65 (RegexpMatch(searchable_dspc_binpkgnames,
66 r'-%s' % query_re), 30),
67 ),
68- else_=1)
69+ default=1)
70 results = store.with_(searchable_dspc_cte).using(
71 DistributionSourcePackageInDatabase, SearchableDSPC).find(
72 (DistributionSourcePackageInDatabase,
73
74=== modified file 'lib/lp/services/database/stormexpr.py'
75--- lib/lp/services/database/stormexpr.py 2018-05-14 09:25:45 +0000
76+++ lib/lp/services/database/stormexpr.py 2019-04-08 07:34:45 +0000
77@@ -9,7 +9,6 @@
78 'ArrayContains',
79 'ArrayIntersects',
80 'BulkUpdate',
81- 'Case',
82 'ColumnSelect',
83 'Concatenate',
84 'CountDistinct',
85@@ -28,10 +27,7 @@
86 ]
87
88 from storm import Undef
89-from storm.exceptions import (
90- ClassInfoError,
91- ExprError,
92- )
93+from storm.exceptions import ClassInfoError
94 from storm.expr import (
95 BinaryOper,
96 COLUMN_NAME,
97@@ -234,32 +230,6 @@
98 suffix = "NULLS LAST"
99
100
101-class Case(Expr):
102- """Generic conditional expression."""
103- __slots__ = ("when", "else_")
104-
105- def __init__(self, when, else_=None):
106- if not when:
107- raise ExprError("Must specify at least one WHEN clause")
108- self.when = when
109- self.else_ = else_
110-
111-
112-@compile.when(Case)
113-def compile_case(compile, expr, state):
114- tokens = ["CASE"]
115- for condition, result in expr.when:
116- tokens.append(" WHEN ")
117- tokens.append(compile(condition, state))
118- tokens.append(" THEN ")
119- tokens.append(compile(result, state))
120- if expr.else_ is not None:
121- tokens.append(" ELSE ")
122- tokens.append(compile(expr.else_, state))
123- tokens.append(" END")
124- return "".join(tokens)
125-
126-
127 class RegexpMatch(BinaryOper):
128 __slots__ = ()
129 oper = " ~ "