... | ... |
@@ -303,20 +303,9 @@ sub _build_bind_values { |
303 | 303 |
if ($i == @$access_key - 1) { |
304 | 304 |
# Key is array reference |
305 | 305 |
if (ref $current_key eq 'ARRAY') { |
306 |
- # Filtering |
|
307 |
- if ($bind_filter && |
|
308 |
- !$no_bind_filters->{$original_key}) |
|
309 |
- { |
|
310 |
- push @bind_values, |
|
311 |
- $bind_filter->($root_params->[$current_key->[0]], |
|
312 |
- $original_key, $self, |
|
313 |
- {table => $table, column => $column}); |
|
314 |
- } |
|
315 |
- # Not filtering |
|
316 |
- else { |
|
317 |
- push @bind_values, |
|
318 |
- scalar $root_params->[$current_key->[0]]; |
|
319 |
- } |
|
306 |
+ push @bind_values, |
|
307 |
+ $self->_filter($root_params->[$current_key->[0]], |
|
308 |
+ $key_info, $query); |
|
320 | 309 |
} |
321 | 310 |
# Key is string |
322 | 311 |
else { |
... | ... |
@@ -324,20 +313,9 @@ sub _build_bind_values { |
324 | 313 |
next ACCESS_KEYS |
325 | 314 |
unless exists $root_params->{$current_key}; |
326 | 315 |
|
327 |
- # Filtering |
|
328 |
- if ($bind_filter && |
|
329 |
- !$no_bind_filters->{$original_key}) |
|
330 |
- { |
|
331 |
- push @bind_values, |
|
332 |
- $bind_filter->($root_params->{$current_key}, |
|
333 |
- $original_key, $self, |
|
334 |
- {table => $table, column => $column}); |
|
335 |
- } |
|
336 |
- # Not filtering |
|
337 |
- else { |
|
338 |
- push @bind_values, |
|
339 |
- scalar $root_params->{$current_key}; |
|
340 |
- } |
|
316 |
+ push @bind_values, |
|
317 |
+ $self->_filter($root_params->{$current_key}, |
|
318 |
+ $key_info, $query); |
|
341 | 319 |
} |
342 | 320 |
|
343 | 321 |
# Key is found |
... | ... |
@@ -377,6 +355,28 @@ sub _build_bind_values { |
377 | 355 |
return \@bind_values; |
378 | 356 |
} |
379 | 357 |
|
358 |
+sub _filter { |
|
359 |
+ my ($self, $value, $key_info, $query) = @_; |
|
360 |
+ |
|
361 |
+ my $bind_filter = $query->bind_filter; |
|
362 |
+ my $no_bind_filters = $query->_no_bind_filters || {}; |
|
363 |
+ |
|
364 |
+ my $original_key = $key_info->{original_key} || ''; |
|
365 |
+ my $table = $key_info->{table} || ''; |
|
366 |
+ my $column = $key_info->{column} || ''; |
|
367 |
+ |
|
368 |
+ # Filtering |
|
369 |
+ if ($bind_filter && |
|
370 |
+ !$no_bind_filters->{$original_key}) |
|
371 |
+ { |
|
372 |
+ return $bind_filter->($value, $original_key, $self, |
|
373 |
+ {table => $table, column => $column}); |
|
374 |
+ } |
|
375 |
+ |
|
376 |
+ # Not filtering |
|
377 |
+ return $value; |
|
378 |
+} |
|
379 |
+ |
|
380 | 380 |
sub transaction { DBIx::Custom::Transaction->new(dbi => shift) } |
381 | 381 |
|
382 | 382 |
sub create_table { |
... | ... |
@@ -97,7 +97,7 @@ $ret_val = $dbi->create_table( |
97 | 97 |
); |
98 | 98 |
ok(defined $ret_val, "$test : create_table"); |
99 | 99 |
|
100 |
-eval{$dbi->insert('table1', {key1 => 1, key2 => 2})}; |
|
100 |
+$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
101 | 101 |
ok(!$@, "$test : table exist"); |
102 | 102 |
|
103 | 103 |
$ret_val = $dbi->drop_table('table1'); |