Project

General

Profile

« Previous | Next » 

Revision 2825

sql_gen.py: CompareCond.to_str(): Put handling nullable columns as a separate step so it can be expanded

View differences:

lib/sql_gen.py
379 379
        left_value = remove_col_rename(left_value)
380 380
        
381 381
        right_value = self.value
382
        left = left_value.to_str(db)
383
        right = right_value.to_str(db)
384 382
        
385 383
        # Parse operator
386 384
        operator = self.operator
......
389 387
        neg_ref = [False]
390 388
        operator = strings.remove_prefix('!', operator, neg_ref)
391 389
        equals = operator.endswith('=')
392
        if equals and is_null(self.value): operator = 'IS'
390
        if equals and is_null(right_value): operator = 'IS'
393 391
        
392
        # Handle nullable columns
393
        check_null = False
394
        if equals and not passthru_null_ref[0] and isinstance(right_value, Col):
395
            check_null = True
396
        
397
        left = left_value.to_str(db)
398
        right = right_value.to_str(db)
399
        
394 400
        # Create str
395 401
        str_ = left+' '+operator+' '+right
396
        if equals and not passthru_null_ref[0] and isinstance(right_value, Col):
402
        if check_null:
397 403
            str_ = '('+str_+' OR ('+left+' IS NULL AND '+right+' IS NULL))'
398 404
        if neg_ref[0]: str_ = 'NOT '+str_
399 405
        return str_

Also available in: Unified diff