... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
0.1701 |
2 |
+ - simplified arguments check |
|
2 | 3 |
- added EXPERIMENTAL each_table method |
3 | 4 |
- select method column option [COLUMN, as => ALIAS] format is DEPRECATED! |
4 | 5 |
changed to [COLUMN => ALIAS] |
... | ... |
@@ -19,9 +19,6 @@ use Encode qw/encode encode_utf8 decode_utf8/; |
19 | 19 |
use constant DEBUG => $ENV{DBIX_CUSTOM_DEBUG} || 0; |
20 | 20 |
use constant DEBUG_ENCODING => $ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8'; |
21 | 21 |
|
22 |
-our @COMMON_ARGS = qw/bind_type table query filter id primary_key |
|
23 |
- type_rule_off type_rule1_off type_rule2_off type table_alias/; |
|
24 |
- |
|
25 | 22 |
has [qw/connector dsn password quote user/], |
26 | 23 |
cache => 0, |
27 | 24 |
cache_method => sub { |
... | ... |
@@ -170,18 +167,9 @@ sub dbh { |
170 | 167 |
} |
171 | 168 |
} |
172 | 169 |
|
173 |
-our %DELETE_ARGS = map { $_ => 1 } @COMMON_ARGS, |
|
174 |
- qw/where append allow_delete_all where_param prefix/; |
|
175 |
- |
|
176 | 170 |
sub delete { |
177 | 171 |
my ($self, %args) = @_; |
178 | 172 |
|
179 |
- # Check arguments |
|
180 |
- foreach my $name (keys %args) { |
|
181 |
- croak qq{"$name" is wrong option } . _subname |
|
182 |
- unless $DELETE_ARGS{$name}; |
|
183 |
- } |
|
184 |
- |
|
185 | 173 |
# Arguments |
186 | 174 |
my $table = $args{table} || ''; |
187 | 175 |
croak qq{"table" option must be specified. } . _subname |
... | ... |
@@ -297,7 +285,10 @@ sub each_table { |
297 | 285 |
} |
298 | 286 |
} |
299 | 287 |
|
300 |
-our %EXECUTE_ARGS = map { $_ => 1 } @COMMON_ARGS, 'param'; |
|
288 |
+our %VALID_ARGS = map { $_ => 1 } qw/append allow_delete_all |
|
289 |
+ allow_update_all bind_type column filter id join param prefix primary_key |
|
290 |
+ query relation table table_alias type type_rule_off type_rule1_off |
|
291 |
+ type_rule2_off wrap/; |
|
301 | 292 |
|
302 | 293 |
sub execute { |
303 | 294 |
my $self = shift; |
... | ... |
@@ -326,7 +317,7 @@ sub execute { |
326 | 317 |
# Check argument names |
327 | 318 |
foreach my $name (keys %args) { |
328 | 319 |
croak qq{"$name" is wrong option } . _subname |
329 |
- unless $EXECUTE_ARGS{$name}; |
|
320 |
+ unless $VALID_ARGS{$name}; |
|
330 | 321 |
} |
331 | 322 |
|
332 | 323 |
# Create query |
... | ... |
@@ -481,8 +472,6 @@ sub execute { |
481 | 472 |
else { return $affected } |
482 | 473 |
} |
483 | 474 |
|
484 |
-our %INSERT_ARGS = map { $_ => 1 } @COMMON_ARGS, qw/param/; |
|
485 |
- |
|
486 | 475 |
sub insert { |
487 | 476 |
my $self = shift; |
488 | 477 |
|
... | ... |
@@ -492,7 +481,7 @@ sub insert { |
492 | 481 |
my %args = @_; |
493 | 482 |
my $table = delete $args{table}; |
494 | 483 |
croak qq{"table" option must be specified } . _subname |
495 |
- unless $table; |
|
484 |
+ unless defined $table; |
|
496 | 485 |
my $p = delete $args{param} || {}; |
497 | 486 |
$param ||= $p; |
498 | 487 |
my $append = delete $args{append} || ''; |
... | ... |
@@ -504,12 +493,6 @@ sub insert { |
504 | 493 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
505 | 494 |
my $prefix = delete $args{prefix}; |
506 | 495 |
|
507 |
- # Check arguments |
|
508 |
- foreach my $name (keys %args) { |
|
509 |
- croak qq{"$name" is wrong option } . _subname |
|
510 |
- unless $INSERT_ARGS{$name}; |
|
511 |
- } |
|
512 |
- |
|
513 | 496 |
# Merge parameter |
514 | 497 |
if (defined $id) { |
515 | 498 |
my $id_param = $self->_create_param_from_id($id, $primary_key); |
... | ... |
@@ -767,9 +750,6 @@ sub register_filter { |
767 | 750 |
return $self; |
768 | 751 |
} |
769 | 752 |
|
770 |
-our %SELECT_ARGS = map { $_ => 1 } @COMMON_ARGS, |
|
771 |
- qw/column where relation join param where_param wrap prefix/; |
|
772 |
- |
|
773 | 753 |
sub select { |
774 | 754 |
my ($self, %args) = @_; |
775 | 755 |
|
... | ... |
@@ -800,12 +780,6 @@ sub select { |
800 | 780 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
801 | 781 |
my $prefix = delete $args{prefix}; |
802 | 782 |
|
803 |
- # Check arguments |
|
804 |
- foreach my $name (keys %args) { |
|
805 |
- croak qq{"$name" is wrong option } . _subname |
|
806 |
- unless $SELECT_ARGS{$name}; |
|
807 |
- } |
|
808 |
- |
|
809 | 783 |
# Add relation tables(DEPRECATED!); |
810 | 784 |
$self->_add_relation_table($tables, $relation); |
811 | 785 |
|
... | ... |
@@ -1034,9 +1008,6 @@ sub type_rule { |
1034 | 1008 |
return $self->{type_rule} || {}; |
1035 | 1009 |
} |
1036 | 1010 |
|
1037 |
-our %UPDATE_ARGS = map { $_ => 1 } @COMMON_ARGS, |
|
1038 |
- qw/param where allow_update_all where_param prefix/; |
|
1039 |
- |
|
1040 | 1011 |
sub update { |
1041 | 1012 |
my $self = shift; |
1042 | 1013 |
|
... | ... |
@@ -1060,12 +1031,6 @@ sub update { |
1060 | 1031 |
if defined $id && !defined $primary_key; |
1061 | 1032 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
1062 | 1033 |
my $prefix = delete $args{prefix}; |
1063 |
- |
|
1064 |
- # Check argument names |
|
1065 |
- foreach my $name (keys %args) { |
|
1066 |
- croak qq{"$name" is wrong option } . _subname |
|
1067 |
- unless $UPDATE_ARGS{$name}; |
|
1068 |
- } |
|
1069 | 1034 |
|
1070 | 1035 |
# Update clause |
1071 | 1036 |
my $update_clause = $self->update_param($param); |
... | ... |
@@ -1536,7 +1501,7 @@ sub apply_filter { |
1536 | 1501 |
} |
1537 | 1502 |
|
1538 | 1503 |
# DEPRECATED! |
1539 |
-our %SELECT_AT_ARGS = (%SELECT_ARGS, where => 1, primary_key => 1); |
|
1504 |
+our %SELECT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1); |
|
1540 | 1505 |
sub select_at { |
1541 | 1506 |
my ($self, %args) = @_; |
1542 | 1507 |
|
... | ... |
@@ -1566,7 +1531,7 @@ sub select_at { |
1566 | 1531 |
} |
1567 | 1532 |
|
1568 | 1533 |
# DEPRECATED! |
1569 |
-our %DELETE_AT_ARGS = (%DELETE_ARGS, where => 1, primary_key => 1); |
|
1534 |
+our %DELETE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1); |
|
1570 | 1535 |
sub delete_at { |
1571 | 1536 |
my ($self, %args) = @_; |
1572 | 1537 |
|
... | ... |
@@ -1590,7 +1555,7 @@ sub delete_at { |
1590 | 1555 |
} |
1591 | 1556 |
|
1592 | 1557 |
# DEPRECATED! |
1593 |
-our %UPDATE_AT_ARGS = (%UPDATE_ARGS, where => 1, primary_key => 1); |
|
1558 |
+our %UPDATE_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1); |
|
1594 | 1559 |
sub update_at { |
1595 | 1560 |
my $self = shift; |
1596 | 1561 |
|
... | ... |
@@ -1619,7 +1584,7 @@ sub update_at { |
1619 | 1584 |
} |
1620 | 1585 |
|
1621 | 1586 |
# DEPRECATED! |
1622 |
-our %INSERT_AT_ARGS = (%INSERT_ARGS, where => 1, primary_key => 1); |
|
1587 |
+our %INSERT_AT_ARGS = (%VALID_ARGS, where => 1, primary_key => 1); |
|
1623 | 1588 |
sub insert_at { |
1624 | 1589 |
my $self = shift; |
1625 | 1590 |
|
... | ... |
@@ -350,7 +350,7 @@ is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5}, |
350 | 350 |
|
351 | 351 |
$result = $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, append => ' '); |
352 | 352 |
|
353 |
-eval{$dbi->update(table => 'table1', noexist => 1)}; |
|
353 |
+eval{$dbi->update(table => 'table1', where => {key1 => 1}, noexist => 1)}; |
|
354 | 354 |
like($@, qr/noexist/, "invalid"); |
355 | 355 |
|
356 | 356 |
eval{$dbi->update(table => 'table1')}; |
... | ... |
@@ -483,7 +483,7 @@ $dbi->delete(table => 'table1', where => {key1 => 1, key2 => 2}); |
483 | 483 |
$rows = $dbi->select(table => 'table1')->all; |
484 | 484 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "delete multi key"); |
485 | 485 |
|
486 |
-eval{$dbi->delete(table => 'table1', noexist => 1)}; |
|
486 |
+eval{$dbi->delete(table => 'table1', where => {key1 => 1}, noexist => 1)}; |
|
487 | 487 |
like($@, qr/noexist/, "invalid"); |
488 | 488 |
|
489 | 489 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |