Changeset 2418
- Timestamp:
- 06/25/20 11:22:38 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r2415 r2418 1106 1106 # foo=1 bar=1 => foo =1 and bar = 2 1107 1107 my $results = {}; 1108 my $NegResults = {};1109 1108 my $noalias = 0; 1110 1109 … … 1116 1115 } 1117 1116 1117 my $FilterCounter = 0; 1118 1118 while (my $item = shift(@filter)) { 1119 $FilterCounter++; 1119 1120 # attr=foo => no extra white space ! 1120 1121 # \W is false, it is possible to have two char 1121 my ($ NegFilter, $attr, $attrref, $operator, $val) = $item =~ /^([\!\+\-]?)(\w+)(?:\.([\.\w]+))?(?:([^\w*]+)(.+))?$/ or next;1122 my ($OpFilter, $attr, $attrref, $operator, $val) = $item =~ /^([\!\+\-]?)(\w+)(?:\.([\.\w]+))?(?:([^\w*]+)(.+))?$/ or next; 1122 1123 if (!$operator) { 1123 1124 $operator = '~'; … … 1158 1159 1159 1160 if (!@results) { 1160 if ($ NegFilter eq '!') {1161 $ NegResults->{$attrKey} ||= {};1161 if ($OpFilter eq '!') { 1162 $results->{$attrKey} ||= {}; 1162 1163 } else { 1163 1164 $results->{$attrKey} ||= {}; … … 1173 1174 $base->log(LA_DEBUG, "Search result: %s: %s", $attr, join(' ', @results)); 1174 1175 1175 if ($NegFilter eq '!') { 1176 # Filter result to remove: 1177 $NegResults->{$_} = 1 foreach (@results); 1178 } elsif ($NegFilter eq '-') { 1176 # ! Add a list of object included only if 1177 # we create a result list that will not be cumulated with same attribute 1178 if ( $OpFilter eq '!') { 1179 $attrKey .= '%' . $FilterCounter; 1180 } 1181 1182 if ($OpFilter eq '-') { 1179 1183 # Filter result to filter from attribute result 1180 1184 $results->{$attrKey} ||= {}; 1181 1185 $results->{$attrKey}{$_} = -1 foreach (@results); 1182 } elsif ($ NegFilter eq '+') {1186 } elsif ($OpFilter eq '+') { 1183 1187 # Filter result to filter from attribute result 1184 1188 $results->{$attrKey} ||= {}; … … 1198 1202 foreach my $value (sort(@values)) { 1199 1203 my $v = $results->{$attr}{$value} || 0; 1200 if ( $v < 1 || $NegResults->{$value}) {1201 1204 if ( $v < 1 ) { 1205 delete($mresults{$value}); 1202 1206 } 1207 1203 1208 } 1204 1209 }
Note: See TracChangeset
for help on using the changeset viewer.