Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 36b7bf7b

Von Sven Schöling vor fast 10 Jahren hinzugefügt

  • ID 36b7bf7bb11f3875b818387aeda1fad363eb6c96
  • Vorgänger 071e5546
  • Nachfolger c8a25928

ParseFilter: Laundern schon vor dem eigentlichen parsen.

Erlaubt es indirekte Filter im Template roundtrip safe zu machen.

Unterschiede anzeigen:

SL/Controller/Helper/ParseFilter.pm
43 43
    _add_uniq($objects, $_) for @$auto_objects;
44 44
  }
45 45

  
46
  my $query = _parse_filter($flattened, $objects, %params);
47

  
48 46
  _launder_keys($filter, $params{launder_to}) unless $params{no_launder};
49 47

  
48
  my $query = _parse_filter($flattened, $objects, %params);
49

  
50 50
  return
51 51
    ($query   && @$query   ? (query => $query) : ()),
52 52
    ($objects && @$objects ? ( with_objects => [ uniq @$objects ]) : ());
t/controllers/helpers/parse_filter.t
1 1
use lib 't';
2 2

  
3
use Test::More tests => 31;
3
use Test::More tests => 36;
4 4
use Test::Deep;
5 5
use Data::Dumper;
6 6

  
......
179 179
  }
180 180
}, 'deep laundering, check for laundered hash', target => 'launder', launder_to => { };
181 181

  
182
test {
183
  part => {
184
   'sellprice:number' => '2',
185
   'sellprice:number::' => 'le',
186
  }
187
}, {
188
  part => {
189
   'sellprice:number' => '2',
190
   'sellprice:number::' => 'le',
191
  }
192
}, 'laundering of indirect filters does not alter', target => 'filter', launder_to => { };
193

  
194
test {
195
  part => {
196
   'sellprice:number' => '2',
197
   'sellprice:number::' => 'le',
198
  }
199
}, {
200
  part => {
201
    'sellprice_number' => '2',
202
    'sellprice_number__' => 'le',
203
  }
204
}, 'laundering of indirect filters', target => 'launder', launder_to => { };
205

  
206
test {
207
  part => {
208
   'sellprice:number' => '2',
209
   'sellprice:number::' => 'le',
210
  }
211
}, {
212
  part => {
213
    'sellprice:number' => '2',
214
    'sellprice:number::' => 'le',
215
    'sellprice_number' => '2',
216
    'sellprice_number__' => 'le',
217
  }
218
}, 'laundering of indirect filters - inplace', target => 'filter';
219

  
182 220
### bug: sub objects
183 221

  
184 222
test {
......
335 373
    ]
336 374
  ]
337 375
}, ':multi with complex tokenizing';
376

  
377
# test tokenizing for custom filters by monkeypatching a custom filter into Part
378
SL::DB::Manager::Part->add_filter_specs(
379
  test => sub {
380
    my ($key, $value, $prefix, @additional) = @_;
381
    return "$prefix$key" => { @additional, $value };
382
  }
383
);
384

  
385
test {
386
  'part.test.what' => 2,
387
}, {
388
  query => [
389
    'part.test' => { 'what', 2 },
390
  ]
391
}, 'additional tokens', class => 'SL::DB::Manager::OrderItem';
392

  
393
test {
394
  'part.test.what:substr::ilike' => 2,
395
}, {
396
  query => [
397
    'part.test' => { 'what', { ilike => '%2%' } },
398
  ]
399
}, 'additional tokens + filters + methods', class => 'SL::DB::Manager::OrderItem';

Auch abrufbar als: Unified diff