fixed small insert, update, delete, select method id...
...option bug
| ... | ... |
@@ -1,3 +1,6 @@ |
| 1 |
+0.1696 |
|
| 2 |
+ - added EXPERIMENTAL insert, update, and select method prefix option |
|
| 3 |
+ - fixed small insert, update, delete, select method id option bug |
|
| 1 | 4 |
0.1695 |
| 2 | 5 |
- changed EXPERIMENTAL DBIx::Custom::Result type_rule_off method argument |
| 3 | 6 |
- added EXPERIMENTAL DBIx::Custom::Result type_rule_on method |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
package DBIx::Custom; |
| 2 | 2 |
|
| 3 |
-our $VERSION = '0.1695'; |
|
| 3 |
+our $VERSION = '0.1696'; |
|
| 4 | 4 |
use 5.008001; |
| 5 | 5 |
|
| 6 | 6 |
use Object::Simple -base; |
| ... | ... |
@@ -259,7 +259,7 @@ sub delete {
|
| 259 | 259 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
| 260 | 260 |
|
| 261 | 261 |
# Where |
| 262 |
- $where = $self->_create_param_from_id($id, $primary_key) if $id; |
|
| 262 |
+ $where = $self->_create_param_from_id($id, $primary_key) if defined $id; |
|
| 263 | 263 |
my $where_clause = ''; |
| 264 | 264 |
if (ref $where) {
|
| 265 | 265 |
$where = $self->_where_to_obj($where); |
| ... | ... |
@@ -545,7 +545,7 @@ sub insert {
|
| 545 | 545 |
} |
| 546 | 546 |
|
| 547 | 547 |
# Merge parameter |
| 548 |
- if ($id) {
|
|
| 548 |
+ if (defined $id) {
|
|
| 549 | 549 |
my $id_param = $self->_create_param_from_id($id, $primary_key); |
| 550 | 550 |
$param = $self->merge_param($id_param, $param); |
| 551 | 551 |
} |
| ... | ... |
@@ -853,7 +853,7 @@ sub select {
|
| 853 | 853 |
|
| 854 | 854 |
# Where |
| 855 | 855 |
my $where_clause = ''; |
| 856 |
- $where = $self->_create_param_from_id($id, $primary_key) if $id; |
|
| 856 |
+ $where = $self->_create_param_from_id($id, $primary_key) if defined $id; |
|
| 857 | 857 |
if (ref $where) {
|
| 858 | 858 |
$where = $self->_where_to_obj($where); |
| 859 | 859 |
$where_param = keys %$where_param |
| ... | ... |
@@ -1060,7 +1060,7 @@ sub update {
|
| 1060 | 1060 |
my $update_clause = $self->update_param($param); |
| 1061 | 1061 |
|
| 1062 | 1062 |
# Where |
| 1063 |
- $where = $self->_create_param_from_id($id, $primary_key) if $id; |
|
| 1063 |
+ $where = $self->_create_param_from_id($id, $primary_key) if defined $id; |
|
| 1064 | 1064 |
my $where_clause = ''; |
| 1065 | 1065 |
if (ref $where) {
|
| 1066 | 1066 |
$where = $self->_where_to_obj($where); |
| ... | ... |
@@ -1246,7 +1246,7 @@ sub _create_param_from_id {
|
| 1246 | 1246 |
|
| 1247 | 1247 |
# Create parameter |
| 1248 | 1248 |
my $param = {};
|
| 1249 |
- if ($id) {
|
|
| 1249 |
+ if (defined $id) {
|
|
| 1250 | 1250 |
$id = [$id] unless ref $id; |
| 1251 | 1251 |
croak qq{"id" must be constant value or array reference}
|
| 1252 | 1252 |
. " (" . (caller 1)[3] . ")"
|
| ... | ... |
@@ -2432,15 +2432,14 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
|
| 2432 | 2432 |
is($dbi->select(table => 'table1')->one->{key3}, 3);
|
| 2433 | 2433 |
|
| 2434 | 2434 |
$dbi->delete_all(table => 'table1'); |
| 2435 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
|
| 2436 | 2435 |
$dbi->insert( |
| 2437 | 2436 |
primary_key => 'key1', |
| 2438 | 2437 |
table => 'table1', |
| 2439 |
- id => 1, |
|
| 2438 |
+ id => 0, |
|
| 2440 | 2439 |
param => {key2 => 2, key3 => 3}
|
| 2441 | 2440 |
); |
| 2442 | 2441 |
|
| 2443 |
-is($dbi->select(table => 'table1')->one->{key1}, 1);
|
|
| 2442 |
+is($dbi->select(table => 'table1')->one->{key1}, 0);
|
|
| 2444 | 2443 |
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
| 2445 | 2444 |
is($dbi->select(table => 'table1')->one->{key3}, 3);
|
| 2446 | 2445 |
|
| ... | ... |
@@ -2497,14 +2496,14 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
|
| 2497 | 2496 |
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
| 2498 | 2497 |
|
| 2499 | 2498 |
$dbi->delete_all(table => 'table1'); |
| 2500 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
|
| 2499 |
+$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
|
|
| 2501 | 2500 |
$dbi->update( |
| 2502 | 2501 |
table => 'table1', |
| 2503 | 2502 |
primary_key => 'key1', |
| 2504 |
- id => 1, |
|
| 2503 |
+ id => 0, |
|
| 2505 | 2504 |
param => {key3 => 4}
|
| 2506 | 2505 |
); |
| 2507 |
-is($dbi->select(table => 'table1')->one->{key1}, 1);
|
|
| 2506 |
+is($dbi->select(table => 'table1')->one->{key1}, 0);
|
|
| 2508 | 2507 |
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
| 2509 | 2508 |
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
| 2510 | 2509 |
|
| ... | ... |
@@ -2548,11 +2547,11 @@ $dbi->delete( |
| 2548 | 2547 |
); |
| 2549 | 2548 |
is_deeply($dbi->select(table => 'table1')->all, []); |
| 2550 | 2549 |
|
| 2551 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
|
| 2550 |
+$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
|
|
| 2552 | 2551 |
$dbi->delete( |
| 2553 | 2552 |
table => 'table1', |
| 2554 | 2553 |
primary_key => 'key1', |
| 2555 |
- id => 1, |
|
| 2554 |
+ id => 0, |
|
| 2556 | 2555 |
); |
| 2557 | 2556 |
is_deeply($dbi->select(table => 'table1')->all, []); |
| 2558 | 2557 |
|
| ... | ... |
@@ -2588,14 +2587,14 @@ is($row->{key2}, 2);
|
| 2588 | 2587 |
is($row->{key3}, 3);
|
| 2589 | 2588 |
|
| 2590 | 2589 |
$dbi->delete_all(table => 'table1'); |
| 2591 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
|
| 2590 |
+$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
|
|
| 2592 | 2591 |
$result = $dbi->select( |
| 2593 | 2592 |
table => 'table1', |
| 2594 | 2593 |
primary_key => 'key1', |
| 2595 |
- id => 1, |
|
| 2594 |
+ id => 0, |
|
| 2596 | 2595 |
); |
| 2597 | 2596 |
$row = $result->one; |
| 2598 |
-is($row->{key1}, 1);
|
|
| 2597 |
+is($row->{key1}, 0);
|
|
| 2599 | 2598 |
is($row->{key2}, 2);
|
| 2600 | 2599 |
is($row->{key3}, 3);
|
| 2601 | 2600 |
|