| ... | ... |
@@ -349,11 +349,11 @@ sub execute {
|
| 349 | 349 |
my $sql = shift; |
| 350 | 350 |
|
| 351 | 351 |
# Options |
| 352 |
- my $param; |
|
| 353 |
- $param = shift if @_ % 2; |
|
| 352 |
+ my $params; |
|
| 353 |
+ $params = shift if @_ % 2; |
|
| 354 | 354 |
my %opt = @_; |
| 355 | 355 |
warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
|
| 356 |
- $param ||= $opt{param} || {};
|
|
| 356 |
+ $params ||= $opt{param} || {};
|
|
| 357 | 357 |
my $tables = $opt{table} || [];
|
| 358 | 358 |
$tables = [$tables] unless ref $tables eq 'ARRAY'; |
| 359 | 359 |
my $filter = ref $opt{filter} eq 'ARRAY' ?
|
| ... | ... |
@@ -362,25 +362,25 @@ sub execute {
|
| 362 | 362 |
# Merge second parameter |
| 363 | 363 |
my @cleanup; |
| 364 | 364 |
my $saved_param; |
| 365 |
- if (($opt{statement} || '') ne 'insert' && ref $param eq 'ARRAY') {
|
|
| 366 |
- my $param2 = $param->[1]; |
|
| 367 |
- $param = $param->[0]; |
|
| 368 |
- for my $column (keys %$param2) {
|
|
| 369 |
- if (!exists $param->{$column}) {
|
|
| 370 |
- $param->{$column} = $param2->{$column};
|
|
| 365 |
+ if (($opt{statement} || '') ne 'insert' && ref $params eq 'ARRAY') {
|
|
| 366 |
+ my $params2 = $params->[1]; |
|
| 367 |
+ $params = $params->[0]; |
|
| 368 |
+ for my $column (keys %$params2) {
|
|
| 369 |
+ if (!exists $params->{$column}) {
|
|
| 370 |
+ $params->{$column} = $params2->{$column};
|
|
| 371 | 371 |
push @cleanup, $column; |
| 372 | 372 |
} |
| 373 | 373 |
else {
|
| 374 |
- delete $param->{$_} for @cleanup;
|
|
| 374 |
+ delete $params->{$_} for @cleanup;
|
|
| 375 | 375 |
@cleanup = (); |
| 376 |
- $saved_param = $param; |
|
| 377 |
- $param = $self->merge_param($param, $param2); |
|
| 376 |
+ $saved_param = $params; |
|
| 377 |
+ $params = $self->merge_param($params, $params2); |
|
| 378 | 378 |
delete $saved_param->{$_} for (@{$opt{cleanup} || []});
|
| 379 | 379 |
last; |
| 380 | 380 |
} |
| 381 | 381 |
} |
| 382 | 382 |
} |
| 383 |
- $param = [$param] unless ref $param eq 'ARRAY'; |
|
| 383 |
+ $params = [$params] unless ref $params eq 'ARRAY'; |
|
| 384 | 384 |
|
| 385 | 385 |
# Append |
| 386 | 386 |
$sql .= $opt{append} if defined $opt{append} && !ref $sql;
|
| ... | ... |
@@ -397,8 +397,8 @@ sub execute {
|
| 397 | 397 |
unless ($query) {
|
| 398 | 398 |
my $c = $self->{safety_character};
|
| 399 | 399 |
# Check unsafety keys |
| 400 |
- unless ((join('', keys %{$param->[0]}) || '') =~ /^[$c\.]+$/) {
|
|
| 401 |
- for my $column (keys %{$param->[0]}) {
|
|
| 400 |
+ unless ((join('', keys %{$params->[0]}) || '') =~ /^[$c\.]+$/) {
|
|
| 401 |
+ for my $column (keys %{$params->[0]}) {
|
|
| 402 | 402 |
croak qq{"$column" is not safety column name } . _subname
|
| 403 | 403 |
unless $column =~ /^[$c\.]+$/; |
| 404 | 404 |
} |
| ... | ... |
@@ -415,7 +415,7 @@ sub execute {
|
| 415 | 415 |
# Return query |
| 416 | 416 |
if ($opt{query}) {
|
| 417 | 417 |
for my $column (@cleanup, @{$opt{cleanup} || []}) {
|
| 418 |
- delete $_->{$column} for @$param;
|
|
| 418 |
+ delete $_->{$column} for @$params;
|
|
| 419 | 419 |
} |
| 420 | 420 |
return $query; |
| 421 | 421 |
}; |
| ... | ... |
@@ -439,8 +439,8 @@ sub execute {
|
| 439 | 439 |
my $key = $opt{primary_key}->[$i];
|
| 440 | 440 |
$key = "$main_table.$key" if $statement eq 'update' || |
| 441 | 441 |
$statement eq 'delete' || $statement eq 'select'; |
| 442 |
- next if exists $param->[0]->{$key};
|
|
| 443 |
- $param->[0]->{$key} = $opt{id}->[$i];
|
|
| 442 |
+ next if exists $params->[0]->{$key};
|
|
| 443 |
+ $params->[0]->{$key} = $opt{id}->[$i];
|
|
| 444 | 444 |
push @cleanup, $key;1 |
| 445 | 445 |
} |
| 446 | 446 |
} |
| ... | ... |
@@ -505,11 +505,11 @@ sub execute {
|
| 505 | 505 |
if (!$query->{duplicate} && $type_rule_off && !keys %$filter && !$self->{default_out_filter}
|
| 506 | 506 |
&& !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
|
| 507 | 507 |
{
|
| 508 |
- eval { $affected = $sth->execute(map { $param->[0]->{$_} } @{$query->{columns}}) };
|
|
| 508 |
+ eval { $affected = $sth->execute(map { $params->[0]->{$_} } @{$query->{columns}}) };
|
|
| 509 | 509 |
} |
| 510 | 510 |
else {
|
| 511 | 511 |
# Create bind values |
| 512 |
- my ($bind, $bind_types) = $self->_create_bind_values($param->[0], $query->{columns},
|
|
| 512 |
+ my ($bind, $bind_types) = $self->_create_bind_values($params->[0], $query->{columns},
|
|
| 513 | 513 |
$filter, $type_filters, $opt{bind_type} || $opt{type} || {});
|
| 514 | 514 |
|
| 515 | 515 |
# Execute |
| ... | ... |
@@ -544,7 +544,7 @@ sub execute {
|
| 544 | 544 |
|
| 545 | 545 |
# Remove id from parameter |
| 546 | 546 |
for my $column (@cleanup, @{$opt{cleanup} || []}) {
|
| 547 |
- delete $_->{$column} for @$param;
|
|
| 547 |
+ delete $_->{$column} for @$params;
|
|
| 548 | 548 |
} |
| 549 | 549 |
|
| 550 | 550 |
# Not select statement |