Project

General

Profile

« Previous | Next » 

Revision 2578

sql_gen.py CompareCond.to_str(), callers of combine_conds(): Removed unnecessary grouping () to make SQL clearer

View differences:

lib/sql_gen.py
280 280
        # Create str
281 281
        str_ = left+' '+operator+' '+right
282 282
        if equals and not passthru_null_ref[0] and isinstance(right_value, Col):
283
            str_ += ' OR ('+left+' IS NULL AND '+right+' IS NULL)'
284
        if neg_ref[0]: str_ = 'NOT ('+str_+')'
283
            str_ = '('+str_+' OR ('+left+' IS NULL AND '+right+' IS NULL))'
284
        if neg_ref[0]: str_ = 'NOT '+str_
285 285
        return str_
286 286

  
287 287
# Tells as_ValueCond() to assume a non-ValueCond is a literal value
......
342 342
                right = CompareCond(as_Col(left, right_table), '~=')
343 343
            
344 344
            right = as_ValueCond(right, right_table)
345
            return '('+right.to_str(db, as_Col(left, left_table))+')'
345
            return right.to_str(db, as_Col(left, left_table))
346 346
        
347 347
        # Create join condition
348 348
        type_ = self.type_
lib/sql.py
511 511
    if conds != []:
512 512
        if len(conds) == 1: whitespace = ' '
513 513
        else: whitespace = '\n'
514
        query += '\n'+sql_gen.combine_conds(['('+sql_gen.ColValueCond(l, r)
515
            .to_str(db)+')' for l, r in conds], 'WHERE')
514
        query += '\n'+sql_gen.combine_conds([sql_gen.ColValueCond(l, r)
515
            .to_str(db) for l, r in conds], 'WHERE')
516 516
        missing = False
517 517
    if order_by != None:
518 518
        query += '\nORDER BY '+sql_gen.as_Col(order_by, table0).to_str(db)

Also available in: Unified diff