Ignore:
Timestamp:
01/27/16 13:05:25 (8 years ago)
Author:
nanardon
Message:

Support other operators in search than = and ~

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm

    r1624 r1672  
    795795 
    796796        # Invalid filter due to impossible value: 
    797         $attribute->checkinputformat($val) or do { 
     797        if (!$attribute->checkinputformat($val) && $mode ne '~') { 
    798798            $base->log(LA_ERR, "Invalid format value $val for attribute $attr"); 
    799799            return; 
    800         }; 
     800        } 
    801801 
    802802        $val = $attribute->input($val); 
     
    813813        } elsif ($attribute->{inline}) { 
    814814            $sql = sprintf( 
    815                 q{select ikey from %s where %s::text %s}, 
     815                q{select ikey from %s where %s%s %s}, 
    816816                $base->db->quote_identifier($class->_object_table), 
     817                ($mode eq '~' ? '::text' : ''), 
    817818                $base->db->quote_identifier($attribute->iname), 
    818819                $val eq '*' 
     
    820821                    : $mode eq '~' 
    821822                        ? 'ILIKE ?' 
    822                         : '= ?'  
     823                        : "$mode ?" 
    823824            ); 
    824825            push(@{$attrbind{$attr}}, $mode eq '~' ? '%' . $val . '%' : $val) unless($val eq '*'); 
     
    832833                    ? '' 
    833834                    : $mode eq '~' 
    834                         ? q{and value ILIKE ?} 
    835                         : q{and value = ?} 
     835                        ? q{and value::text ILIKE ?} 
     836                        : qq{and value $mode ?} 
    836837 
    837838            ); 
Note: See TracChangeset for help on using the changeset viewer.