~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/services/database/stormexpr.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-02-09 19:25:43 UTC
  • mfrom: (12316.1.2 bug-181368-view)
  • Revision ID: launchpad@pqm.canonical.com-20110209192543-a657vi9uxrrjggfc
[r=adeuring][bug=181368] Gut BinaryPackageFilePublishing view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
__metaclass__ = type
5
5
__all__ = [
 
6
    'Concatenate',
6
7
    'CountDistinct',
7
8
    'Greatest',
8
9
    ]
9
10
 
10
11
from storm.expr import (
 
12
    BinaryOper,
11
13
    compile,
12
14
    EXPR,
13
15
    Expr,
15
17
    )
16
18
 
17
19
 
18
 
# XXX wallyworld 2011-01-31 bug=710466:
19
 
# We need to use a Postgres greatest() function call but Storm doesn't
20
 
# support that yet.
21
20
class Greatest(NamedFunc):
 
21
    # XXX wallyworld 2011-01-31 bug=710466:
 
22
    # We need to use a Postgres greatest() function call but Storm
 
23
    # doesn't support that yet.
22
24
    __slots__ = ()
23
25
    name = "GREATEST"
24
26
 
25
27
 
26
 
# XXX: wallyworld 2010-11-26 bug=675377:
27
 
# storm's Count() implementation is broken for distinct with > 1 column
28
28
class CountDistinct(Expr):
 
29
    # XXX: wallyworld 2010-11-26 bug=675377:
 
30
    # storm's Count() implementation is broken for distinct with > 1
 
31
    # column.
29
32
 
30
33
    __slots__ = ("columns")
31
34
 
39
42
    col = compile(countselect.columns)
40
43
    state.pop()
41
44
    return "count(distinct(%s))" % col
 
45
 
 
46
 
 
47
class Concatenate(BinaryOper):
 
48
    """Storm operator for string concatenation."""
 
49
    __slots__ = ()
 
50
    oper = " || "