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
=== 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 @@
354snowballstemmer==1.2.1354snowballstemmer==1.2.1
355soupmatchers==0.4355soupmatchers==0.4
356sphinxcontrib-websupport==1.0.1356sphinxcontrib-websupport==1.0.1
357# lp:~launchpad-committers/storm/with-without-datetime357# lp:~launchpad-committers/storm/lp
358storm==0.19.0.99-lpwithnodatetime-r408358storm==0.20.0.99-lp-r410
359subprocess32==3.2.6359subprocess32==3.2.6
360subvertpy==0.9.1360subvertpy==0.9.1
361testresources==0.2.7361testresources==0.2.7
362362
=== 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 @@
72 CONTAINSSTRING,72 CONTAINSSTRING,
73 OR,73 OR,
74 )74 )
75from storm.databases.postgres import Case
75from storm.expr import (76from storm.expr import (
76 And,77 And,
77 Column,78 Column,
@@ -178,10 +179,7 @@
178 SQLBase,179 SQLBase,
179 sqlvalues,180 sqlvalues,
180 )181 )
181from lp.services.database.stormexpr import (182from lp.services.database.stormexpr import RegexpMatch
182 Case,
183 RegexpMatch,
184 )
185from lp.services.helpers import (183from lp.services.helpers import (
186 ensure_unicode,184 ensure_unicode,
187 shortlist,185 shortlist,
@@ -2004,13 +2002,13 @@
2004 *self._clauses),2002 *self._clauses),
2005 tables=self._table))))2003 tables=self._table))))
2006 rank = Case(2004 rank = Case(
2007 when=(2005 cases=(
2008 (self._table.name == query, 100),2006 (self._table.name == query, 100),
2009 (self._table.name.startswith(query + "-"), 75),2007 (self._table.name.startswith(query + "-"), 75),
2010 (self._table.name.startswith(query), 50),2008 (self._table.name.startswith(query), 50),
2011 (self._table.name.contains_string("-" + query), 25),2009 (self._table.name.contains_string("-" + query), 25),
2012 ),2010 ),
2013 else_=1)2011 default=1)
2014 results.order_by(Desc(rank), self._table.name)2012 results.order_by(Desc(rank), self._table.name)
2015 return self.iterator(results.count(), results, self.toTerm)2013 return self.iterator(results.count(), results, self.toTerm)
20162014
@@ -2169,7 +2167,7 @@
2169 "sourcepackagename", SearchableDSPC)2167 "sourcepackagename", SearchableDSPC)
2170 searchable_dspc_binpkgnames = Column("binpkgnames", SearchableDSPC)2168 searchable_dspc_binpkgnames = Column("binpkgnames", SearchableDSPC)
2171 rank = Case(2169 rank = Case(
2172 when=(2170 cases=(
2173 # name == query2171 # name == query
2174 (searchable_dspc_name == query, 100),2172 (searchable_dspc_name == query, 100),
2175 (RegexpMatch(searchable_dspc_binpkgnames,2173 (RegexpMatch(searchable_dspc_binpkgnames,
@@ -2187,7 +2185,7 @@
2187 (RegexpMatch(searchable_dspc_binpkgnames,2185 (RegexpMatch(searchable_dspc_binpkgnames,
2188 r'-%s' % query_re), 30),2186 r'-%s' % query_re), 30),
2189 ),2187 ),
2190 else_=1)2188 default=1)
2191 results = store.with_(searchable_dspc_cte).using(2189 results = store.with_(searchable_dspc_cte).using(
2192 DistributionSourcePackageInDatabase, SearchableDSPC).find(2190 DistributionSourcePackageInDatabase, SearchableDSPC).find(
2193 (DistributionSourcePackageInDatabase,2191 (DistributionSourcePackageInDatabase,
21942192
=== 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 @@
9 'ArrayContains',9 'ArrayContains',
10 'ArrayIntersects',10 'ArrayIntersects',
11 'BulkUpdate',11 'BulkUpdate',
12 'Case',
13 'ColumnSelect',12 'ColumnSelect',
14 'Concatenate',13 'Concatenate',
15 'CountDistinct',14 'CountDistinct',
@@ -28,10 +27,7 @@
28 ]27 ]
2928
30from storm import Undef29from storm import Undef
31from storm.exceptions import (30from storm.exceptions import ClassInfoError
32 ClassInfoError,
33 ExprError,
34 )
35from storm.expr import (31from storm.expr import (
36 BinaryOper,32 BinaryOper,
37 COLUMN_NAME,33 COLUMN_NAME,
@@ -234,32 +230,6 @@
234 suffix = "NULLS LAST"230 suffix = "NULLS LAST"
235231
236232
237class Case(Expr):
238 """Generic conditional expression."""
239 __slots__ = ("when", "else_")
240
241 def __init__(self, when, else_=None):
242 if not when:
243 raise ExprError("Must specify at least one WHEN clause")
244 self.when = when
245 self.else_ = else_
246
247
248@compile.when(Case)
249def compile_case(compile, expr, state):
250 tokens = ["CASE"]
251 for condition, result in expr.when:
252 tokens.append(" WHEN ")
253 tokens.append(compile(condition, state))
254 tokens.append(" THEN ")
255 tokens.append(compile(result, state))
256 if expr.else_ is not None:
257 tokens.append(" ELSE ")
258 tokens.append(compile(expr.else_, state))
259 tokens.append(" END")
260 return "".join(tokens)
261
262
263class RegexpMatch(BinaryOper):233class RegexpMatch(BinaryOper):
264 __slots__ = ()234 __slots__ = ()
265 oper = " ~ "235 oper = " ~ "