root/galaxy-central/eggs/SQLAlchemy-0.5.6_dev_r6498-py2.6.egg/sqlalchemy/sql/operators.py

リビジョン 3, 2.3 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# This module is part of SQLAlchemy and is released under
2# the MIT License: http://www.opensource.org/licenses/mit-license.php
3
4"""Defines operators used in SQL expressions."""
5
6from operator import (
7    and_, or_, inv, add, mul, sub, div, mod, truediv, lt, le, ne, gt, ge, eq
8    )
9from sqlalchemy.util import symbol
10
11
12def from_():
13    raise NotImplementedError()
14
15def as_():
16    raise NotImplementedError()
17
18def exists():
19    raise NotImplementedError()
20
21def is_():
22    raise NotImplementedError()
23
24def isnot():
25    raise NotImplementedError()
26
27def collate():
28    raise NotImplementedError()
29
30def op(a, opstring, b):
31    return a.op(opstring)(b)
32
33def like_op(a, b, escape=None):
34    return a.like(b, escape=escape)
35
36def notlike_op(a, b, escape=None):
37    raise NotImplementedError()
38
39def ilike_op(a, b, escape=None):
40    return a.ilike(b, escape=escape)
41
42def notilike_op(a, b, escape=None):
43    raise NotImplementedError()
44
45def between_op(a, b, c):
46    return a.between(b, c)
47
48def in_op(a, b):
49    return a.in_(b)
50
51def notin_op(a, b):
52    raise NotImplementedError()
53
54def distinct_op(a):
55    return a.distinct()
56
57def startswith_op(a, b, escape=None):
58    return a.startswith(b, escape=escape)
59
60def endswith_op(a, b, escape=None):
61    return a.endswith(b, escape=escape)
62
63def contains_op(a, b, escape=None):
64    return a.contains(b, escape=escape)
65
66def match_op(a, b):
67    return a.match(b)
68
69def comma_op(a, b):
70    raise NotImplementedError()
71
72def concat_op(a, b):
73    return a.concat(b)
74
75def desc_op(a):
76    return a.desc()
77
78def asc_op(a):
79    return a.asc()
80
81_commutative = set([eq, ne, add, mul])
82def is_commutative(op):
83    return op in _commutative
84
85_smallest = symbol('_smallest')
86_largest = symbol('_largest')
87
88_PRECEDENCE = {
89    from_: 15,
90    mul: 7,
91    div: 7,
92    mod: 7,
93    add: 6,
94    sub: 6,
95    concat_op: 6,
96    match_op: 6,
97    ilike_op: 5,
98    notilike_op: 5,
99    like_op: 5,
100    notlike_op: 5,
101    in_op: 5,
102    notin_op: 5,
103    is_: 5,
104    isnot: 5,
105    eq: 5,
106    ne: 5,
107    gt: 5,
108    lt: 5,
109    ge: 5,
110    le: 5,
111    between_op: 5,
112    distinct_op: 5,
113    inv: 5,
114    and_: 3,
115    or_: 2,
116    comma_op: -1,
117    collate: 7,
118    as_: -1,
119    exists: 0,
120    _smallest: -1000,
121    _largest: 1000
122}
123
124def is_precedent(operator, against):
125    return (_PRECEDENCE.get(operator, _PRECEDENCE[_smallest]) <=
126            _PRECEDENCE.get(against, _PRECEDENCE[_largest]))
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。