... | ... |
@@ -598,22 +598,15 @@ sub insert { |
598 | 598 |
my $self = shift; |
599 | 599 |
|
600 | 600 |
# Arguments |
601 |
- my $param; |
|
602 |
- $param = shift if @_ % 2; |
|
601 |
+ my $param = @_ % 2 ? shift : undef; |
|
603 | 602 |
my %args = @_; |
604 |
- my $table = $args{table}; |
|
605 |
- croak qq{"table" option must be specified } . _subname |
|
606 |
- unless defined $table; |
|
607 |
- my $p = $args{param} || {}; |
|
608 |
- $param ||= $p; |
|
603 |
+ $param ||= $args{param} || {}; |
|
609 | 604 |
my $id = $args{id}; |
610 | 605 |
my $primary_key = $args{primary_key}; |
611 | 606 |
croak "insert method primary_key option " . |
612 | 607 |
"must be specified when id is specified " . _subname |
613 | 608 |
if defined $id && !defined $primary_key; |
614 | 609 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
615 |
- my $prefix = $args{prefix}; |
|
616 |
- my $wrap = $args{wrap}; |
|
617 | 610 |
my $timestamp = $args{timestamp}; |
618 | 611 |
|
619 | 612 |
# Timestamp |
... | ... |
@@ -634,9 +627,9 @@ sub insert { |
634 | 627 |
# Insert statement |
635 | 628 |
my $sql; |
636 | 629 |
$sql .= "insert "; |
637 |
- $sql .= "$prefix " if defined $prefix; |
|
638 |
- $sql .= "into " . $self->_q($table) . " " |
|
639 |
- . $self->values_clause($param, {wrap => $wrap}) . " "; |
|
630 |
+ $sql .= "$args{prefix} " if defined $args{prefix}; |
|
631 |
+ $sql .= "into " . $self->_q($args{table}) . " " |
|
632 |
+ . $self->values_clause($param, {wrap => $args{wrap}}) . " "; |
|
640 | 633 |
|
641 | 634 |
# Execute query |
642 | 635 |
return $self->execute($sql, $param, %args); |
... | ... |
@@ -1109,19 +1102,19 @@ sub update { |
1109 | 1102 |
my $table = $args{table} || ''; |
1110 | 1103 |
croak qq{"table" option must be specified } . _subname |
1111 | 1104 |
unless $table; |
1112 |
- my $p = delete $args{param} || {}; |
|
1105 |
+ my $p = $args{param} || {}; |
|
1113 | 1106 |
$param ||= $p; |
1114 |
- my $where = delete $args{where} || {}; |
|
1115 |
- my $where_param = delete $args{where_param} || {}; |
|
1116 |
- my $allow_update_all = delete $args{allow_update_all}; |
|
1117 |
- my $id = delete $args{id}; |
|
1118 |
- my $primary_key = delete $args{primary_key}; |
|
1107 |
+ my $where = $args{where} || {}; |
|
1108 |
+ my $where_param = $args{where_param} || {}; |
|
1109 |
+ my $allow_update_all = $args{allow_update_all}; |
|
1110 |
+ my $id = $args{id}; |
|
1111 |
+ my $primary_key = $args{primary_key}; |
|
1119 | 1112 |
croak "update method primary_key option " . |
1120 | 1113 |
"must be specified when id is specified " . _subname |
1121 | 1114 |
if defined $id && !defined $primary_key; |
1122 | 1115 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
1123 |
- my $prefix = delete $args{prefix}; |
|
1124 |
- my $wrap = delete $args{wrap}; |
|
1116 |
+ my $prefix = $args{prefix}; |
|
1117 |
+ my $wrap = $args{wrap}; |
|
1125 | 1118 |
my $timestamp = $args{timestamp}; |
1126 | 1119 |
|
1127 | 1120 |
# Timestamp |
... | ... |
@@ -1664,8 +1664,6 @@ is($dbi->{_tags}->{b}->(), 2); |
1664 | 1664 |
|
1665 | 1665 |
test 'table not specify exception'; |
1666 | 1666 |
$dbi = DBIx::Custom->connect; |
1667 |
-eval {$dbi->insert}; |
|
1668 |
-like($@, qr/table/); |
|
1669 | 1667 |
eval {$dbi->update}; |
1670 | 1668 |
like($@, qr/table/); |
1671 | 1669 |
eval {$dbi->delete}; |