Revision 2577
Added by Aaron Marcuse-Kubitza about 12 years ago
sql_gen.py | ||
---|---|---|
220 | 220 |
|
221 | 221 |
def to_str(self, db): return self.value.to_str(db, self.col) |
222 | 222 |
|
223 |
def combine_conds(conds, keyword=None): |
|
224 |
''' |
|
225 |
@param keyword The keyword to add before the conditions, if any |
|
226 |
''' |
|
227 |
str_ = '' |
|
228 |
if keyword != None: |
|
229 |
if conds == []: whitespace = '' |
|
230 |
elif len(conds) == 1: whitespace = ' ' |
|
231 |
else: whitespace = '\n' |
|
232 |
str_ += keyword+whitespace |
|
233 |
|
|
234 |
str_ += '\nAND '.join(conds) |
|
235 |
return str_ |
|
236 |
|
|
223 | 237 |
##### Condition column comparisons |
224 | 238 |
|
225 | 239 |
class ValueCond(BasicObject): |
... | ... | |
341 | 355 |
else: |
342 | 356 |
if len(joins) == 1: whitespace = ' ' |
343 | 357 |
else: whitespace = '\n' |
344 |
join_cond = 'ON'+whitespace+('\nAND '.join( |
|
345 |
map(join, joins.iteritems()))) |
|
358 |
join_cond = combine_conds(map(join, joins.iteritems()), 'ON') |
|
346 | 359 |
|
347 | 360 |
# Create join |
348 | 361 |
if type_ is filter_out: type_ = 'LEFT' |
Also available in: Unified diff
sql_gen.py: Added combine_conds() and use it in Join.to_str() and sql.py mk_select()