| ... | ... |
@@ -3109,4 +3109,89 @@ $model = $dbi->create_model( |
| 3109 | 3109 |
$model->method(foo => sub { shift->select(@_) });
|
| 3110 | 3110 |
is_deeply($model->foo->one, {key1 => 1, key3 => 3});
|
| 3111 | 3111 |
|
| 3112 |
+test 'update_param'; |
|
| 3113 |
+$dbi = DBIx::Custom->connect; |
|
| 3114 |
+eval { $dbi->execute('drop table table1') };
|
|
| 3115 |
+$dbi->execute($create_table1_2); |
|
| 3116 |
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 3117 |
+$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 3118 |
+ |
|
| 3119 |
+$param = {key2 => 11};
|
|
| 3120 |
+$update_param = $dbi->update_param($param); |
|
| 3121 |
+$sql = <<"EOS"; |
|
| 3122 |
+update table1 $update_param |
|
| 3123 |
+where key1 = 1 |
|
| 3124 |
+EOS |
|
| 3125 |
+$dbi->execute($sql, param => $param); |
|
| 3126 |
+$result = $dbi->execute('select * from table1 order by key1;', table => 'table1');
|
|
| 3127 |
+$rows = $result->all; |
|
| 3128 |
+is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
|
| 3129 |
+ {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 3130 |
+ "basic"); |
|
| 3131 |
+ |
|
| 3132 |
+ |
|
| 3133 |
+$dbi = DBIx::Custom->connect; |
|
| 3134 |
+eval { $dbi->execute('drop table table1') };
|
|
| 3135 |
+$dbi->execute($create_table1_2); |
|
| 3136 |
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 3137 |
+$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 3138 |
+ |
|
| 3139 |
+$param = {key2 => 11, key3 => 33};
|
|
| 3140 |
+$update_param = $dbi->update_param($param); |
|
| 3141 |
+$sql = <<"EOS"; |
|
| 3142 |
+update table1 $update_param |
|
| 3143 |
+where key1 = 1 |
|
| 3144 |
+EOS |
|
| 3145 |
+$dbi->execute($sql, param => $param); |
|
| 3146 |
+$result = $dbi->execute('select * from table1 order by key1;', table => 'table1');
|
|
| 3147 |
+$rows = $result->all; |
|
| 3148 |
+is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
|
|
| 3149 |
+ {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 3150 |
+ "basic"); |
|
| 3151 |
+ |
|
| 3152 |
+$dbi = DBIx::Custom->connect; |
|
| 3153 |
+eval { $dbi->execute('drop table table1') };
|
|
| 3154 |
+$dbi->execute($create_table1_2); |
|
| 3155 |
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 3156 |
+$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 3157 |
+ |
|
| 3158 |
+$param = {key2 => 11, key3 => 33};
|
|
| 3159 |
+$update_param = $dbi->update_param($param, {no_set => 1});
|
|
| 3160 |
+$sql = <<"EOS"; |
|
| 3161 |
+update table1 set $update_param |
|
| 3162 |
+where key1 = 1 |
|
| 3163 |
+EOS |
|
| 3164 |
+$dbi->execute($sql, param => $param); |
|
| 3165 |
+$result = $dbi->execute('select * from table1 order by key1;', table => 'table1');
|
|
| 3166 |
+$rows = $result->all; |
|
| 3167 |
+is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
|
|
| 3168 |
+ {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 3169 |
+ "update param no_set"); |
|
| 3170 |
+ |
|
| 3171 |
+ |
|
| 3172 |
+eval { $dbi->update_param({";" => 1}) };
|
|
| 3173 |
+like($@, qr/not safety/); |
|
| 3174 |
+ |
|
| 3175 |
+ |
|
| 3176 |
+test 'update_param'; |
|
| 3177 |
+$dbi = DBIx::Custom->connect; |
|
| 3178 |
+eval { $dbi->execute('drop table table1') };
|
|
| 3179 |
+$dbi->execute($create_table1_2); |
|
| 3180 |
+$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 3181 |
+$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 3182 |
+ |
|
| 3183 |
+$param = {key2 => 11};
|
|
| 3184 |
+$update_param = $dbi->assign_param($param); |
|
| 3185 |
+$sql = <<"EOS"; |
|
| 3186 |
+update table1 set $update_param |
|
| 3187 |
+where key1 = 1 |
|
| 3188 |
+EOS |
|
| 3189 |
+$dbi->execute($sql, param => $param, table => 'table1'); |
|
| 3190 |
+$result = $dbi->execute('select * from table1 order by key1;');
|
|
| 3191 |
+$rows = $result->all; |
|
| 3192 |
+is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
|
| 3193 |
+ {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 3194 |
+ "basic"); |
|
| 3195 |
+ |
|
| 3196 |
+ |
|
| 3112 | 3197 |
1; |
| ... | ... |
@@ -364,89 +364,6 @@ $result = $dbi->select( |
| 364 | 364 |
is_deeply($result->all, [{'table2.key3' => 4}]);
|
| 365 | 365 |
|
| 366 | 366 |
|
| 367 |
-test 'update_param'; |
|
| 368 |
-$dbi = DBIx::Custom->connect; |
|
| 369 |
-eval { $dbi->execute('drop table table1') };
|
|
| 370 |
-$dbi->execute($create_table1_2); |
|
| 371 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 372 |
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 373 |
- |
|
| 374 |
-$param = {key2 => 11};
|
|
| 375 |
-$update_param = $dbi->update_param($param); |
|
| 376 |
-$sql = <<"EOS"; |
|
| 377 |
-update table1 $update_param |
|
| 378 |
-where key1 = 1 |
|
| 379 |
-EOS |
|
| 380 |
-$dbi->execute($sql, param => $param); |
|
| 381 |
-$result = $dbi->execute('select * from table1;', table => 'table1');
|
|
| 382 |
-$rows = $result->all; |
|
| 383 |
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
|
| 384 |
- {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 385 |
- "basic"); |
|
| 386 |
- |
|
| 387 |
- |
|
| 388 |
-$dbi = DBIx::Custom->connect; |
|
| 389 |
-eval { $dbi->execute('drop table table1') };
|
|
| 390 |
-$dbi->execute($create_table1_2); |
|
| 391 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 392 |
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 393 |
- |
|
| 394 |
-$param = {key2 => 11, key3 => 33};
|
|
| 395 |
-$update_param = $dbi->update_param($param); |
|
| 396 |
-$sql = <<"EOS"; |
|
| 397 |
-update table1 $update_param |
|
| 398 |
-where key1 = 1 |
|
| 399 |
-EOS |
|
| 400 |
-$dbi->execute($sql, param => $param); |
|
| 401 |
-$result = $dbi->execute('select * from table1;', table => 'table1');
|
|
| 402 |
-$rows = $result->all; |
|
| 403 |
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
|
|
| 404 |
- {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 405 |
- "basic"); |
|
| 406 |
- |
|
| 407 |
-$dbi = DBIx::Custom->connect; |
|
| 408 |
-eval { $dbi->execute('drop table table1') };
|
|
| 409 |
-$dbi->execute($create_table1_2); |
|
| 410 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 411 |
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 412 |
- |
|
| 413 |
-$param = {key2 => 11, key3 => 33};
|
|
| 414 |
-$update_param = $dbi->update_param($param, {no_set => 1});
|
|
| 415 |
-$sql = <<"EOS"; |
|
| 416 |
-update table1 set $update_param |
|
| 417 |
-where key1 = 1 |
|
| 418 |
-EOS |
|
| 419 |
-$dbi->execute($sql, param => $param); |
|
| 420 |
-$result = $dbi->execute('select * from table1;', table => 'table1');
|
|
| 421 |
-$rows = $result->all; |
|
| 422 |
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
|
|
| 423 |
- {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 424 |
- "update param no_set"); |
|
| 425 |
- |
|
| 426 |
- |
|
| 427 |
-eval { $dbi->update_param({";" => 1}) };
|
|
| 428 |
-like($@, qr/not safety/); |
|
| 429 |
- |
|
| 430 |
- |
|
| 431 |
-test 'update_param'; |
|
| 432 |
-$dbi = DBIx::Custom->connect; |
|
| 433 |
-eval { $dbi->execute('drop table table1') };
|
|
| 434 |
-$dbi->execute($create_table1_2); |
|
| 435 |
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
| 436 |
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
| 437 |
- |
|
| 438 |
-$param = {key2 => 11};
|
|
| 439 |
-$update_param = $dbi->assign_param($param); |
|
| 440 |
-$sql = <<"EOS"; |
|
| 441 |
-update table1 set $update_param |
|
| 442 |
-where key1 = 1 |
|
| 443 |
-EOS |
|
| 444 |
-$dbi->execute($sql, param => $param, table => 'table1'); |
|
| 445 |
-$result = $dbi->execute('select * from table1;');
|
|
| 446 |
-$rows = $result->all; |
|
| 447 |
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
|
| 448 |
- {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
|
| 449 |
- "basic"); |
|
| 450 | 367 |
|
| 451 | 368 |
|
| 452 | 369 |
test 'type option'; # DEPRECATED! |