equal
deleted
inserted
replaced
|
1 """ |
|
2 Useful auxilliary data structures for query construction. Not useful outside |
|
3 the SQL domain. |
|
4 """ |
|
5 |
|
6 class EmptyResultSet(Exception): |
|
7 pass |
|
8 |
|
9 class FullResultSet(Exception): |
|
10 pass |
|
11 |
|
12 class MultiJoin(Exception): |
|
13 """ |
|
14 Used by join construction code to indicate the point at which a |
|
15 multi-valued join was attempted (if the caller wants to treat that |
|
16 exceptionally). |
|
17 """ |
|
18 def __init__(self, level): |
|
19 self.level = level |
|
20 |
|
21 class Empty(object): |
|
22 pass |
|
23 |
|
24 class RawValue(object): |
|
25 def __init__(self, value): |
|
26 self.value = value |
|
27 |
|
28 class Date(object): |
|
29 """ |
|
30 Add a date selection column. |
|
31 """ |
|
32 def __init__(self, col, lookup_type): |
|
33 self.col = col |
|
34 self.lookup_type = lookup_type |
|
35 |
|
36 def relabel_aliases(self, change_map): |
|
37 c = self.col |
|
38 if isinstance(c, (list, tuple)): |
|
39 self.col = (change_map.get(c[0], c[0]), c[1]) |
|
40 |
|
41 def as_sql(self, qn, connection): |
|
42 if isinstance(self.col, (list, tuple)): |
|
43 col = '%s.%s' % tuple([qn(c) for c in self.col]) |
|
44 else: |
|
45 col = self.col |
|
46 return connection.ops.date_trunc_sql(self.lookup_type, col) |