... | ... |
@@ -377,7 +377,7 @@ our %VALID_ARGS = map { $_ => 1 } qw/append after_build_sql allow_delete_all |
377 | 377 |
|
378 | 378 |
sub execute { |
379 | 379 |
my $self = shift; |
380 |
- my $query = shift; |
|
380 |
+ my $sql = shift; |
|
381 | 381 |
my $param; |
382 | 382 |
$param = shift if @_ % 2; |
383 | 383 |
my %args = @_; |
... | ... |
@@ -407,7 +407,7 @@ sub execute { |
407 | 407 |
if defined $id && !defined $primary_key; |
408 | 408 |
$primary_key = [$primary_key] unless ref $primary_key eq 'ARRAY'; |
409 | 409 |
my $append = delete $args{append}; |
410 |
- $query .= $append if defined $append && !ref $query; |
|
410 |
+ $sql .= $append if defined $append && !ref $sql; |
|
411 | 411 |
|
412 | 412 |
# Check argument names |
413 | 413 |
foreach my $name (keys %args) { |
... | ... |
@@ -415,7 +415,8 @@ sub execute { |
415 | 415 |
unless $VALID_ARGS{$name}; |
416 | 416 |
} |
417 | 417 |
|
418 |
- $query = $self->_create_query($query, $after_build_sql) unless ref $query; |
|
418 |
+ my $query |
|
419 |
+ = ref $sql ? $sql : $self->_create_query($sql, $after_build_sql); |
|
419 | 420 |
|
420 | 421 |
# Save query |
421 | 422 |
$self->last_sql($query->sql); |
... | ... |
@@ -2404,15 +2405,12 @@ Execute delete statement. |
2404 | 2405 |
|
2405 | 2406 |
The following opitons are available. |
2406 | 2407 |
|
2407 |
-=over 4 |
|
2408 |
- |
|
2409 |
-=item C<append> |
|
2410 |
- |
|
2411 |
-Same as C<select> method's C<append> option. |
|
2408 |
+B<OPTIONS> |
|
2412 | 2409 |
|
2413 |
-=item C<filter> |
|
2410 |
+C<delete> method use all of C<execute> method's options, |
|
2411 |
+and use the following new ones. |
|
2414 | 2412 |
|
2415 |
-Same as C<execute> method's C<filter> option. |
|
2413 |
+=over 4 |
|
2416 | 2414 |
|
2417 | 2415 |
=item C<id> |
2418 | 2416 |
|
... | ... |
@@ -2440,14 +2438,6 @@ prefix before table name section. |
2440 | 2438 |
|
2441 | 2439 |
delete some from book |
2442 | 2440 |
|
2443 |
-=item C<query> |
|
2444 |
- |
|
2445 |
-Same as C<execute> method's C<query> option. |
|
2446 |
- |
|
2447 |
-=item C<after_build_sql> |
|
2448 |
- |
|
2449 |
-Same as C<execute> method's C<after_build_sql> option. |
|
2450 |
- |
|
2451 | 2441 |
=item C<table> |
2452 | 2442 |
|
2453 | 2443 |
table => 'book' |
... | ... |
@@ -2458,30 +2448,6 @@ Table name. |
2458 | 2448 |
|
2459 | 2449 |
Same as C<select> method's C<where> option. |
2460 | 2450 |
|
2461 |
-=item C<primary_key> |
|
2462 |
- |
|
2463 |
-See C<id> option. |
|
2464 |
- |
|
2465 |
-=item C<bind_type> |
|
2466 |
- |
|
2467 |
-Same as C<execute> method's C<bind_type> option. |
|
2468 |
- |
|
2469 |
-=item C<type_rule_off> |
|
2470 |
- |
|
2471 |
-Same as C<execute> method's C<type_rule_off> option. |
|
2472 |
- |
|
2473 |
-=item C<type_rule1_off> |
|
2474 |
- |
|
2475 |
- type_rule1_off => 1 |
|
2476 |
- |
|
2477 |
-Same as C<execute> method's C<type_rule1_off> option. |
|
2478 |
- |
|
2479 |
-=item C<type_rule2_off> |
|
2480 |
- |
|
2481 |
- type_rule2_off => 1 |
|
2482 |
- |
|
2483 |
-Same as C<execute> method's C<type_rule2_off> option. |
|
2484 |
- |
|
2485 | 2451 |
=back |
2486 | 2452 |
|
2487 | 2453 |
=head2 C<delete_all> |
... | ... |
@@ -2582,10 +2548,18 @@ If you want to use colon generally, you must escape it by C<\\> |
2582 | 2548 |
|
2583 | 2549 |
select * from where title = "aa\\:bb"; |
2584 | 2550 |
|
2551 |
+B<OPTIONS> |
|
2552 |
+ |
|
2585 | 2553 |
The following opitons are available. |
2586 | 2554 |
|
2587 | 2555 |
=over 4 |
2588 | 2556 |
|
2557 |
+=item C<append> |
|
2558 |
+ |
|
2559 |
+ append => 'order by name' |
|
2560 |
+ |
|
2561 |
+Append some statement after SQL. |
|
2562 |
+ |
|
2589 | 2563 |
=item C<bind_type> |
2590 | 2564 |
|
2591 | 2565 |
Specify database bind data type. |
... | ... |
@@ -2681,7 +2655,10 @@ and don't forget to sort $row values by $row key asc order. |
2681 | 2655 |
|
2682 | 2656 |
=item C<primary_key> |
2683 | 2657 |
|
2684 |
-See C<id> option. |
|
2658 |
+ primary_key => 'id' |
|
2659 |
+ primary_key => ['id1', 'id2'] |
|
2660 |
+ |
|
2661 |
+Priamry key. This is used when C<id> option find primary key. |
|
2685 | 2662 |
|
2686 | 2663 |
=item C<after_build_sql> |
2687 | 2664 |
|
... | ... |
@@ -2805,15 +2782,11 @@ as parameter value. |
2805 | 2782 |
|
2806 | 2783 |
B<options> |
2807 | 2784 |
|
2808 |
-C<insert> method use all of C<execute> method options, |
|
2785 |
+C<insert> method use all of C<execute> method's options, |
|
2809 | 2786 |
and use the following new ones. |
2810 | 2787 |
|
2811 | 2788 |
=over 4 |
2812 | 2789 |
|
2813 |
-=item C<append> |
|
2814 |
- |
|
2815 |
-Same as C<select> method's C<append> option. |
|
2816 |
- |
|
2817 | 2790 |
=item C<id> |
2818 | 2791 |
|
2819 | 2792 |
id => 4 |
... | ... |
@@ -2850,10 +2823,6 @@ prefix before table name section |
2850 | 2823 |
|
2851 | 2824 |
Table name. |
2852 | 2825 |
|
2853 |
-=item C<type_rule_off> |
|
2854 |
- |
|
2855 |
-Same as C<execute> method's C<type_rule_off> option. |
|
2856 |
- |
|
2857 | 2826 |
=item C<timestamp> |
2858 | 2827 |
|
2859 | 2828 |
timestamp => 1 |
... | ... |
@@ -2862,18 +2831,6 @@ If this value is set to 1, |
2862 | 2831 |
automatically created timestamp column is set based on |
2863 | 2832 |
C<timestamp> attribute's C<insert> value. |
2864 | 2833 |
|
2865 |
-=item C<type_rule1_off> |
|
2866 |
- |
|
2867 |
- type_rule1_off => 1 |
|
2868 |
- |
|
2869 |
-Same as C<execute> method's C<type_rule1_off> option. |
|
2870 |
- |
|
2871 |
-=item C<type_rule2_off> |
|
2872 |
- |
|
2873 |
- type_rule2_off => 1 |
|
2874 |
- |
|
2875 |
-Same as C<execute> method's C<type_rule2_off> option. |
|
2876 |
- |
|
2877 | 2834 |
=item C<wrap> |
2878 | 2835 |
|
2879 | 2836 |
wrap => {price => sub { "max($_[0])" }} |
... | ... |
@@ -3045,20 +3002,13 @@ Register filters, used by C<filter> option of many methods. |
3045 | 3002 |
|
3046 | 3003 |
Execute select statement. |
3047 | 3004 |
|
3048 |
-The following opitons are available. |
|
3049 |
- |
|
3050 |
-=over 4 |
|
3051 |
- |
|
3052 |
-=item C<append> |
|
3053 |
- |
|
3054 |
- append => 'order by title' |
|
3005 |
+B<OPTIONS> |
|
3055 | 3006 |
|
3056 |
-Append statement to last of SQL. |
|
3007 |
+C<select> method use all of C<execute> method's options, |
|
3008 |
+and use the following new ones. |
|
3057 | 3009 |
|
3058 |
-=item C<bind_type> |
|
3010 |
+=over 4 |
|
3059 | 3011 |
|
3060 |
-Same as C<execute> method's C<bind_type> option. |
|
3061 |
- |
|
3062 | 3012 |
=item C<column> |
3063 | 3013 |
|
3064 | 3014 |
column => 'author' |
... | ... |
@@ -3120,7 +3070,7 @@ The above is same as the followin one. |
3120 | 3070 |
table => 'book' |
3121 | 3071 |
); |
3122 | 3072 |
|
3123 |
-=item C<param> EXPERIMETNAL |
|
3073 |
+=item C<param> |
|
3124 | 3074 |
|
3125 | 3075 |
param => {'table2.key3' => 5} |
3126 | 3076 |
|
... | ... |
@@ -3183,43 +3133,12 @@ the join clause correctly. |
3183 | 3133 |
] |
3184 | 3134 |
); |
3185 | 3135 |
|
3186 |
-=item C<primary_key> |
|
3187 |
- |
|
3188 |
- primary_key => 'id' |
|
3189 |
- primary_key => ['id1', 'id2'] |
|
3190 |
- |
|
3191 |
-Primary key. This is used by C<id> option. |
|
3192 |
- |
|
3193 |
-=item C<query> |
|
3194 |
- |
|
3195 |
-Same as C<execute> method's C<query> option. |
|
3196 |
- |
|
3197 |
-=item C<after_build_sql> |
|
3198 |
- |
|
3199 |
-Same as C<execute> method's C<after_build_sql> option |
|
3200 |
- |
|
3201 | 3136 |
=item C<table> |
3202 | 3137 |
|
3203 | 3138 |
table => 'book' |
3204 | 3139 |
|
3205 | 3140 |
Table name. |
3206 | 3141 |
|
3207 |
-=item C<type_rule_off> |
|
3208 |
- |
|
3209 |
-Same as C<execute> method's C<type_rule_off> option. |
|
3210 |
- |
|
3211 |
-=item C<type_rule1_off> |
|
3212 |
- |
|
3213 |
- type_rule1_off => 1 |
|
3214 |
- |
|
3215 |
-Same as C<execute> method's C<type_rule1_off> option. |
|
3216 |
- |
|
3217 |
-=item C<type_rule2_off> |
|
3218 |
- |
|
3219 |
- type_rule2_off => 1 |
|
3220 |
- |
|
3221 |
-Same as C<execute> method's C<type_rule2_off> option. |
|
3222 |
- |
|
3223 | 3142 |
=item C<where> |
3224 | 3143 |
|
3225 | 3144 |
# Hash refrence |
... | ... |
@@ -3246,7 +3165,7 @@ Same as C<execute> method's C<type_rule2_off> option. |
3246 | 3165 |
# String |
3247 | 3166 |
where => 'title is null' |
3248 | 3167 |
|
3249 |
-Where clause. |
|
3168 |
+Where clause. See L<DBIx::Custom::Where>. |
|
3250 | 3169 |
|
3251 | 3170 |
=back |
3252 | 3171 |
|
... | ... |
@@ -3342,21 +3261,12 @@ as parameter value. |
3342 | 3261 |
|
3343 | 3262 |
{date => \"NOW()"} |
3344 | 3263 |
|
3345 |
-The following opitons are available. |
|
3346 |
- |
|
3347 |
-=over 4 |
|
3348 |
- |
|
3349 |
-=item C<append> |
|
3350 |
- |
|
3351 |
-Same as C<select> method's C<append> option. |
|
3264 |
+B<OPTIONS> |
|
3352 | 3265 |
|
3353 |
-=item C<bind_type> |
|
3354 |
- |
|
3355 |
-Same as C<execute> method's C<bind_type> option. |
|
3356 |
- |
|
3357 |
-=item C<filter> |
|
3266 |
+C<update> method use all of C<execute> method's options, |
|
3267 |
+and use the following new ones. |
|
3358 | 3268 |
|
3359 |
-Same as C<execute> method's C<filter> option. |
|
3269 |
+=over 4 |
|
3360 | 3270 |
|
3361 | 3271 |
=item C<id> |
3362 | 3272 |
|
... | ... |
@@ -3389,21 +3299,6 @@ prefix before table name section |
3389 | 3299 |
|
3390 | 3300 |
update or replace book |
3391 | 3301 |
|
3392 |
-=item C<primary_key> |
|
3393 |
- |
|
3394 |
- primary_key => 'id' |
|
3395 |
- primary_key => ['id1', 'id2'] |
|
3396 |
- |
|
3397 |
-Primary key. This is used by C<id> option. |
|
3398 |
- |
|
3399 |
-=item C<query> |
|
3400 |
- |
|
3401 |
-Same as C<execute> method's C<query> option. |
|
3402 |
- |
|
3403 |
-=item C<after_build_sql> |
|
3404 |
- |
|
3405 |
-Same as C<execute> method's C<after_build_sql> option. |
|
3406 |
- |
|
3407 | 3302 |
=item C<table> |
3408 | 3303 |
|
3409 | 3304 |
table => 'book' |
... | ... |
@@ -3418,22 +3313,6 @@ If this value is set to 1, |
3418 | 3313 |
automatically updated timestamp column is set based on |
3419 | 3314 |
C<timestamp> attribute's C<update> value. |
3420 | 3315 |
|
3421 |
-=item C<type_rule_off> |
|
3422 |
- |
|
3423 |
-Same as C<execute> method's C<type_rule_off> option. |
|
3424 |
- |
|
3425 |
-=item C<type_rule1_off> |
|
3426 |
- |
|
3427 |
- type_rule1_off => 1 |
|
3428 |
- |
|
3429 |
-Same as C<execute> method's C<type_rule1_off> option. |
|
3430 |
- |
|
3431 |
-=item C<type_rule2_off> |
|
3432 |
- |
|
3433 |
- type_rule2_off => 1 |
|
3434 |
- |
|
3435 |
-Same as C<execute> method's C<type_rule2_off> option. |
|
3436 |
- |
|
3437 | 3316 |
=item C<where> |
3438 | 3317 |
|
3439 | 3318 |
Same as C<select> method's C<where> option. |
... | ... |
@@ -3455,7 +3334,6 @@ is executed, the following SQL is executed. |
3455 | 3334 |
|
3456 | 3335 |
=back |
3457 | 3336 |
|
3458 |
- |
|
3459 | 3337 |
=head2 C<update_all> |
3460 | 3338 |
|
3461 | 3339 |
$dbi->update_all({title => 'Perl'}, table => 'book', ); |
... | ... |
@@ -2971,7 +2971,6 @@ $result = $model->select( |
2971 | 2971 |
column => {$table1 => ["$key2"]}, |
2972 | 2972 |
id => 1 |
2973 | 2973 |
); |
2974 |
-$DB::single = 1; |
|
2975 | 2974 |
is_deeply($result->all, [{"$table1.$key2" => 2}]); |
2976 | 2975 |
|
2977 | 2976 |
eval { $dbi->execute("drop table $table1") }; |