Changeset 1776 for trunk/LATMOS-Accounts


Ignore:
Timestamp:
05/31/16 09:34:46 (8 years ago)
Author:
nanardon
Message:

Allow search for NULL value to any field (included not inline)

File:
1 edited

Legend:

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

    r1764 r1776  
    786786            push(@{$attrbind{$attr}}, $mode eq '~' ? '%' . $val . '%' : $val) unless($mode eq '=' && ($val eq '*' || $val eq 'NULL')); 
    787787        } else { 
    788             $sql = sprintf( 
    789                 q{select okey from %s where attr = ? %s}, 
    790                 $base->db->quote_identifier( 
    791                     $class->_object_table . '_attributes' 
    792                 ), 
    793                 $val eq '*' 
    794                     ? '' 
    795                     : $mode eq '~' 
    796                         ? q{and value::text ILIKE ?} 
    797                         : qq{and value $mode ?} 
    798  
    799             ); 
    800             push(@{$attrbind{$attr}}, $attribute->iname); 
    801             push(@{$attrbind{$attr}}, $mode eq '~' ? '%' . $val . '%' : $val) unless($val eq '*'); 
     788            if ($mode eq '=' && $val eq 'NULL') { 
     789                $sql = sprintf(q{ select ikey from %s where ikey 
     790                          not in (select okey from %s where attr = ? and value is not NULL) }, 
     791                          $base->db->quote_identifier($class->_object_table), 
     792                          $base->db->quote_identifier( 
     793                              $class->_object_table . '_attributes' 
     794                          ), 
     795                ); 
     796                push(@{$attrbind{$attr}}, $attribute->iname); 
     797            } else { 
     798                $sql = sprintf( 
     799                    q{select okey from %s where attr = ? %s}, 
     800                    $base->db->quote_identifier( 
     801                        $class->_object_table . '_attributes' 
     802                    ), 
     803                    $val eq '*' 
     804                        ? '' 
     805                        : $mode eq '~' 
     806                            ? q{and value::text ILIKE ?} 
     807                            : qq{and value $mode ?} 
     808 
     809                ); 
     810                push(@{$attrbind{$attr}}, $attribute->iname); 
     811                push(@{$attrbind{$attr}}, $mode eq '~' ? '%' . $val . '%' : $val) unless($val eq '*'); 
     812            } 
    802813        } 
    803814 
Note: See TracChangeset for help on using the changeset viewer.