- changed EXPERIMENTAL DBIx::Custom::Result type_ru...
...le_off method argument
| ... | ... |
@@ -1,3 +1,12 @@ |
| 1 |
+0.1695 |
|
| 2 |
+ - changed EXPERIMENTAL DBIx::Custom::Result type_rule_off method argument |
|
| 3 |
+ - added EXPERIMENTAL DBIx::Custom::Result type_rule_on method |
|
| 4 |
+ - changed EXPERIMENTAL DBIx::Custom::Result type_rule1_off method argument |
|
| 5 |
+ - added EXPERIMENTAL DBIx::Custom::Result type_rule1_on method |
|
| 6 |
+ - changed EXPERIMENTAL DBIx::Custom::Result type_rule2_off method argument |
|
| 7 |
+ - added EXPERIMENTAL DBIx::Custom::Result type_rule2_on method |
|
| 8 |
+ - changed EXPERIMENTAL DBIx::Custom::Result filter_off method argument |
|
| 9 |
+ - added EXPERIMENTAL DBIx::Custom::Result filter_on method |
|
| 1 | 10 |
0.1694 |
| 2 | 11 |
- EXPERIMENTAL type_rule argument format is changed |
| 3 | 12 |
- DBIx::Custom::Result type_rule method on setting return self |
| ... | ... |
@@ -1,6 +1,6 @@ |
| 1 | 1 |
package DBIx::Custom; |
| 2 | 2 |
|
| 3 |
-our $VERSION = '0.1694'; |
|
| 3 |
+our $VERSION = '0.1695'; |
|
| 4 | 4 |
use 5.008001; |
| 5 | 5 |
|
| 6 | 6 |
use Object::Simple -base; |
| ... | ... |
@@ -4,8 +4,8 @@ use Object::Simple -base; |
| 4 | 4 |
use Carp 'croak'; |
| 5 | 5 |
use DBIx::Custom::Util qw/_array_to_hash _subname/; |
| 6 | 6 |
|
| 7 |
-has [qw/filters filter_off sth type_rule_off type_rule1_off type_rule2_off/]; |
|
| 8 |
-has stash => sub { {} };
|
|
| 7 |
+has [qw/filters sth/], |
|
| 8 |
+ stash => sub { {} };
|
|
| 9 | 9 |
|
| 10 | 10 |
*all = \&fetch_hash_all; |
| 11 | 11 |
|
| ... | ... |
@@ -39,6 +39,18 @@ sub filter {
|
| 39 | 39 |
return $self->{filter} ||= {};
|
| 40 | 40 |
} |
| 41 | 41 |
|
| 42 |
+sub filter_off {
|
|
| 43 |
+ my $self = shift; |
|
| 44 |
+ $self->{filter_off} = 1;
|
|
| 45 |
+ return $self; |
|
| 46 |
+} |
|
| 47 |
+ |
|
| 48 |
+sub filter_on {
|
|
| 49 |
+ my $self = shift; |
|
| 50 |
+ $self->{filter_off} = 0;
|
|
| 51 |
+ return $self; |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 42 | 54 |
sub fetch {
|
| 43 | 55 |
my $self = shift; |
| 44 | 56 |
|
| ... | ... |
@@ -234,6 +246,42 @@ sub type_rule {
|
| 234 | 246 |
return $self->{type_rule} || {};
|
| 235 | 247 |
} |
| 236 | 248 |
|
| 249 |
+sub type_rule_off {
|
|
| 250 |
+ my $self = shift; |
|
| 251 |
+ $self->{type_rule_off} = 1;
|
|
| 252 |
+ return $self; |
|
| 253 |
+} |
|
| 254 |
+ |
|
| 255 |
+sub type_rule_on {
|
|
| 256 |
+ my $self = shift; |
|
| 257 |
+ $self->{type_rule_off} = 0;
|
|
| 258 |
+ return $self; |
|
| 259 |
+} |
|
| 260 |
+ |
|
| 261 |
+sub type_rule1_off {
|
|
| 262 |
+ my $self = shift; |
|
| 263 |
+ $self->{type_rule1_off} = 1;
|
|
| 264 |
+ return $self; |
|
| 265 |
+} |
|
| 266 |
+ |
|
| 267 |
+sub type_rule1_on {
|
|
| 268 |
+ my $self = shift; |
|
| 269 |
+ $self->{type_rule1_off} = 0;
|
|
| 270 |
+ return $self; |
|
| 271 |
+} |
|
| 272 |
+ |
|
| 273 |
+sub type_rule2_off {
|
|
| 274 |
+ my $self = shift; |
|
| 275 |
+ $self->{type_rule2_off} = 1;
|
|
| 276 |
+ return $self; |
|
| 277 |
+} |
|
| 278 |
+ |
|
| 279 |
+sub type_rule2_on {
|
|
| 280 |
+ my $self = shift; |
|
| 281 |
+ $self->{type_rule2_off} = 0;
|
|
| 282 |
+ return $self; |
|
| 283 |
+} |
|
| 284 |
+ |
|
| 237 | 285 |
# DEPRECATED! |
| 238 | 286 |
sub end_filter {
|
| 239 | 287 |
my $self = shift; |
| ... | ... |
@@ -339,13 +387,6 @@ DBIx::Custom::Result - Result of select statement |
| 339 | 387 |
|
| 340 | 388 |
=head1 ATTRIBUTES |
| 341 | 389 |
|
| 342 |
-=head2 C<filter_off> EXPERIMENTAL |
|
| 343 |
- |
|
| 344 |
- my $filter_off = $resutl->filter_off; |
|
| 345 |
- $result = $result->filter_off(1); |
|
| 346 |
- |
|
| 347 |
-Filtering by C<filter> method is turned off. |
|
| 348 |
- |
|
| 349 | 390 |
=head2 C<filters> |
| 350 | 391 |
|
| 351 | 392 |
my $filters = $result->filters; |
| ... | ... |
@@ -360,27 +401,6 @@ Filters. |
| 360 | 401 |
|
| 361 | 402 |
Statement handle of L<DBI>. |
| 362 | 403 |
|
| 363 |
-=head2 C<type_rule_off> EXPERIMENTAL |
|
| 364 |
- |
|
| 365 |
- my $type_rule_off = $result->type_rule_off; |
|
| 366 |
- $result = $result->type_rule_off(1); |
|
| 367 |
- |
|
| 368 |
-Turn C<from1> and C<from2> type rule off. |
|
| 369 |
- |
|
| 370 |
-=head2 C<type_rule1_off> EXPERIMENTAL |
|
| 371 |
- |
|
| 372 |
- my $type_rule1_off = $result->type_rule1_off; |
|
| 373 |
- $result = $result->type_rule1_off(1); |
|
| 374 |
- |
|
| 375 |
-Turn C<from1> type rule off. |
|
| 376 |
- |
|
| 377 |
-=head2 C<type_rule2_off> EXPERIMENTAL |
|
| 378 |
- |
|
| 379 |
- my $type_rule2_off = $result->type_rule2_off; |
|
| 380 |
- $result = $result->type_rule2_off(1); |
|
| 381 |
- |
|
| 382 |
-Turn C<from2> type rule off. |
|
| 383 |
- |
|
| 384 | 404 |
=head1 METHODS |
| 385 | 405 |
|
| 386 | 406 |
L<DBIx::Custom::Result> inherits all methods from L<Object::Simple> |
| ... | ... |
@@ -451,6 +471,20 @@ Set filter for column. |
| 451 | 471 |
You can use subroutine or filter name as filter. |
| 452 | 472 |
This filter is executed after C<type_rule> filter. |
| 453 | 473 |
|
| 474 |
+=head2 C<filter_off> EXPERIMENTAL |
|
| 475 |
+ |
|
| 476 |
+ $result = $result->filter_off; |
|
| 477 |
+ |
|
| 478 |
+Turn filtering by C<filter> method off. |
|
| 479 |
+By default, filterin is on. |
|
| 480 |
+ |
|
| 481 |
+=head2 C<filter_on> EXPERIMENTAL |
|
| 482 |
+ |
|
| 483 |
+ $result = $resutl->filter_on; |
|
| 484 |
+ |
|
| 485 |
+Turn filtering by C<filter> method on. |
|
| 486 |
+By default, filterin is on. |
|
| 487 |
+ |
|
| 454 | 488 |
=head2 C<one> |
| 455 | 489 |
|
| 456 | 490 |
my $row = $result->one; |
| ... | ... |
@@ -485,4 +519,46 @@ Stash is hash reference for data. |
| 485 | 519 |
|
| 486 | 520 |
This is same as L<DBIx::Custom>'s C<type_rule>'s <from>. |
| 487 | 521 |
|
| 522 |
+=head2 C<type_rule_off> EXPERIMENTAL |
|
| 523 |
+ |
|
| 524 |
+ $result = $result->type_rule_off; |
|
| 525 |
+ |
|
| 526 |
+Turn C<from1> and C<from2> type rule off. |
|
| 527 |
+By default, type rule is on. |
|
| 528 |
+ |
|
| 529 |
+=head2 C<type_rule_on> EXPERIMENTAL |
|
| 530 |
+ |
|
| 531 |
+ $result = $result->type_rule_on; |
|
| 532 |
+ |
|
| 533 |
+Turn C<from1> and C<from2> type rule on. |
|
| 534 |
+By default, type rule is on. |
|
| 535 |
+ |
|
| 536 |
+=head2 C<type_rule1_off> EXPERIMENTAL |
|
| 537 |
+ |
|
| 538 |
+ $result = $result->type_rule1_off; |
|
| 539 |
+ |
|
| 540 |
+Turn C<from1> type rule off. |
|
| 541 |
+By default, type rule is on. |
|
| 542 |
+ |
|
| 543 |
+=head2 C<type_rule1_on> EXPERIMENTAL |
|
| 544 |
+ |
|
| 545 |
+ $result = $result->type_rule1_on; |
|
| 546 |
+ |
|
| 547 |
+Turn C<from1> type rule on. |
|
| 548 |
+By default, type rule is on. |
|
| 549 |
+ |
|
| 550 |
+=head2 C<type_rule2_off> EXPERIMENTAL |
|
| 551 |
+ |
|
| 552 |
+ $result = $result->type_rule2_off; |
|
| 553 |
+ |
|
| 554 |
+Turn C<from2> type rule off. |
|
| 555 |
+By default, type rule is on. |
|
| 556 |
+ |
|
| 557 |
+=head2 C<type_rule2_on> EXPERIMENTAL |
|
| 558 |
+ |
|
| 559 |
+ $result = $result->type_rule2_on; |
|
| 560 |
+ |
|
| 561 |
+Turn C<from2> type rule on. |
|
| 562 |
+By default, type rule is on. |
|
| 563 |
+ |
|
| 488 | 564 |
=cut |
| ... | ... |
@@ -2792,7 +2792,7 @@ $dbi->type_rule( |
| 2792 | 2792 |
); |
| 2793 | 2793 |
$dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
|
| 2794 | 2794 |
$result = $dbi->select(table => 'table1', type_rule_off => 1); |
| 2795 |
-is($result->type_rule_off(1)->fetch->[0], 2); |
|
| 2795 |
+is($result->type_rule_off->fetch->[0], 2); |
|
| 2796 | 2796 |
|
| 2797 | 2797 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
| 2798 | 2798 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
| ... | ... |
@@ -2887,7 +2887,7 @@ $dbi->type_rule( |
| 2887 | 2887 |
); |
| 2888 | 2888 |
$dbi->insert({key1 => 2}, table => 'table1');
|
| 2889 | 2889 |
$result = $dbi->select(table => 'table1'); |
| 2890 |
-$result->type_rule_off(1); |
|
| 2890 |
+$result->type_rule_off; |
|
| 2891 | 2891 |
is($result->one->{key1}, 6);
|
| 2892 | 2892 |
|
| 2893 | 2893 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
| ... | ... |
@@ -2993,8 +2993,9 @@ $dbi->type_rule( |
| 2993 | 2993 |
); |
| 2994 | 2994 |
$dbi->insert({key1 => '1'}, table => 'table1', type_rule_off => 1);
|
| 2995 | 2995 |
$result = $dbi->select(table => 'table1'); |
| 2996 |
-$result->type_rule_off(1); |
|
| 2997 |
-is($result->fetch_first->[0], '1'); |
|
| 2996 |
+is($result->type_rule_off->fetch_first->[0], '1'); |
|
| 2997 |
+$result = $dbi->select(table => 'table1'); |
|
| 2998 |
+is($result->type_rule_on->fetch_first->[0], '1de'); |
|
| 2998 | 2999 |
|
| 2999 | 3000 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
| 3000 | 3001 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
| ... | ... |
@@ -3014,8 +3015,9 @@ $dbi->type_rule( |
| 3014 | 3015 |
); |
| 3015 | 3016 |
$dbi->insert({key1 => '1'}, table => 'table1', type_rule1_off => 1);
|
| 3016 | 3017 |
$result = $dbi->select(table => 'table1'); |
| 3017 |
-$result->type_rule1_off(1); |
|
| 3018 |
-is($result->fetch_first->[0], '1ce'); |
|
| 3018 |
+is($result->type_rule1_off->fetch_first->[0], '1ce'); |
|
| 3019 |
+$result = $dbi->select(table => 'table1'); |
|
| 3020 |
+is($result->type_rule1_on->fetch_first->[0], '1cde'); |
|
| 3019 | 3021 |
|
| 3020 | 3022 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
| 3021 | 3023 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
| ... | ... |
@@ -3035,8 +3037,9 @@ $dbi->type_rule( |
| 3035 | 3037 |
); |
| 3036 | 3038 |
$dbi->insert({key1 => '1'}, table => 'table1', type_rule2_off => 1);
|
| 3037 | 3039 |
$result = $dbi->select(table => 'table1'); |
| 3038 |
-$result->type_rule2_off(1); |
|
| 3039 |
-is($result->fetch_first->[0], '1bd'); |
|
| 3040 |
+is($result->type_rule2_off->fetch_first->[0], '1bd'); |
|
| 3041 |
+$result = $dbi->select(table => 'table1'); |
|
| 3042 |
+is($result->type_rule2_on->fetch_first->[0], '1bde'); |
|
| 3040 | 3043 |
|
| 3041 | 3044 |
test 'separator'; |
| 3042 | 3045 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
|