... | ... |
@@ -22,7 +22,7 @@ __PACKAGE__->class_attr('query_cache_max', default => 50, |
22 | 22 |
|
23 | 23 |
__PACKAGE__->attr([qw/user password data_source/]); |
24 | 24 |
__PACKAGE__->attr([qw/database host port/]); |
25 |
-__PACKAGE__->attr([qw/default_bind_filter default_fetch_filter options/]); |
|
25 |
+__PACKAGE__->attr([qw/default_query_filter default_fetch_filter options/]); |
|
26 | 26 |
|
27 | 27 |
__PACKAGE__->dual_attr([qw/ filters formats/], |
28 | 28 |
default => sub { {} }, inherit => 'hash_copy'); |
... | ... |
@@ -210,7 +210,7 @@ sub create_query { |
210 | 210 |
$query->sth($sth); |
211 | 211 |
|
212 | 212 |
# Set bind filter |
213 |
- $query->bind_filter($self->default_bind_filter); |
|
213 |
+ $query->query_filter($self->default_query_filter); |
|
214 | 214 |
|
215 | 215 |
# Set fetch filter |
216 | 216 |
$query->fetch_filter($self->default_fetch_filter); |
... | ... |
@@ -276,7 +276,7 @@ sub query{ |
276 | 276 |
sub _build_bind_values { |
277 | 277 |
my ($self, $query, $params) = @_; |
278 | 278 |
my $key_infos = $query->key_infos; |
279 |
- my $filter = $query->bind_filter; |
|
279 |
+ my $filter = $query->query_filter; |
|
280 | 280 |
|
281 | 281 |
# binding values |
282 | 282 |
my @bind_values; |
... | ... |
@@ -855,12 +855,12 @@ This method is generally used to get a format. |
855 | 855 |
|
856 | 856 |
If you add format, use add_format method. |
857 | 857 |
|
858 |
-=head2 default_bind_filter |
|
858 |
+=head2 default_query_filter |
|
859 | 859 |
|
860 | 860 |
Binding filter |
861 | 861 |
|
862 |
- $dbi = $dbi->default_bind_filter($default_bind_filter); |
|
863 |
- $default_bind_filter = $dbi->default_bind_filter |
|
862 |
+ $dbi = $dbi->default_query_filter($default_query_filter); |
|
863 |
+ $default_query_filter = $dbi->default_query_filter |
|
864 | 864 |
|
865 | 865 |
The following is bind filter sample |
866 | 866 |
|
... | ... |
@@ -872,7 +872,7 @@ The following is bind filter sample |
872 | 872 |
return encode_utf8($value); |
873 | 873 |
}); |
874 | 874 |
|
875 |
- $dbi->default_bind_filter('encode_utf8') |
|
875 |
+ $dbi->default_query_filter('encode_utf8') |
|
876 | 876 |
|
877 | 877 |
Bind filter arguemts is |
878 | 878 |
|
... | ... |
@@ -1179,7 +1179,7 @@ You can also edit query |
1179 | 1179 |
# column, where clause, append statement, |
1180 | 1180 |
sub { |
1181 | 1181 |
my $query = shift; |
1182 |
- $query->bind_filter(sub { |
|
1182 |
+ $query->query_filter(sub { |
|
1183 | 1183 |
# ... |
1184 | 1184 |
}); |
1185 | 1185 |
} |
... | ... |
@@ -5,7 +5,7 @@ use warnings; |
5 | 5 |
|
6 | 6 |
use base 'Object::Simple'; |
7 | 7 |
|
8 |
-__PACKAGE__->attr([qw/sql key_infos bind_filter fetch_filter sth/]); |
|
8 |
+__PACKAGE__->attr([qw/sql key_infos query_filter fetch_filter sth/]); |
|
9 | 9 |
|
10 | 10 |
1; |
11 | 11 |
|
... | ... |
@@ -22,7 +22,7 @@ DBIx::Custom::Query - DBIx::Custom query |
22 | 22 |
my $query = DBIx::Custom->create_query($template); |
23 | 23 |
|
24 | 24 |
# Attributes |
25 |
- $query->bind_filter($dbi->filters->{default_bind_filter}); |
|
25 |
+ $query->query_filter($dbi->filters->{default_query_filter}); |
|
26 | 26 |
$query->fetch_filter($dbi->filters->{default_fetch_filter}); |
27 | 27 |
|
28 | 28 |
=head1 ATTRIBUTES |
... | ... |
@@ -41,12 +41,12 @@ SQL |
41 | 41 |
$query = $query->sql($sql); |
42 | 42 |
$sql = $query->sql; |
43 | 43 |
|
44 |
-=head2 bind_filter |
|
44 |
+=head2 query_filter |
|
45 | 45 |
|
46 | 46 |
Filter excuted when value is bind |
47 | 47 |
|
48 |
- $query = $query->bind_filter($bind_filter); |
|
49 |
- $bind_filter = $query->bind_filter; |
|
48 |
+ $query = $query->query_filter($query_filter); |
|
49 |
+ $query_filter = $query->query_filter; |
|
50 | 50 |
|
51 | 51 |
=head2 fetch_filter |
52 | 52 |
|
... | ... |
@@ -179,7 +179,7 @@ $dbi->do($CREATE_TABLE->{0}); |
179 | 179 |
$insert_tmpl = "insert into table1 {insert key1 key2}"; |
180 | 180 |
$dbi->query($insert_tmpl, {key1 => 1, key2 => 2}, sub { |
181 | 181 |
my $query = shift; |
182 |
- $query->bind_filter(sub { |
|
182 |
+ $query->query_filter(sub { |
|
183 | 183 |
my ($value, $table, $column, $dbi) = @_; |
184 | 184 |
if ($column eq 'key2' && $dbi->isa('DBIx::Custom')) { |
185 | 185 |
return $value + 1; |
... | ... |
@@ -197,7 +197,7 @@ $dbi->do($CREATE_TABLE->{0}); |
197 | 197 |
|
198 | 198 |
$insert_tmpl = "insert into table1 {insert key1 key2};"; |
199 | 199 |
$insert_query = $dbi->create_query($insert_tmpl); |
200 |
-$insert_query->bind_filter(sub { |
|
200 |
+$insert_query->query_filter(sub { |
|
201 | 201 |
my ($value, $table, $column, $dbi) = @_; |
202 | 202 |
|
203 | 203 |
if ($table eq '' && $column eq 'key1') |
... | ... |
@@ -221,13 +221,13 @@ $select_query->fetch_filter(sub { |
221 | 221 |
}); |
222 | 222 |
$result = $dbi->query($select_query); |
223 | 223 |
$rows = $result->fetch_hash_all; |
224 |
-is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : bind_filter fetch_filter"); |
|
224 |
+is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : query_filter fetch_filter"); |
|
225 | 225 |
|
226 | 226 |
$dbi->do($DROP_TABLE->{0}); |
227 | 227 |
$dbi->do($CREATE_TABLE->{0}); |
228 | 228 |
$insert_tmpl = "insert into table1 {insert table1.key1 table1.key2}"; |
229 | 229 |
$insert_query = $dbi->create_query($insert_tmpl); |
230 |
-$insert_query->bind_filter(sub { |
|
230 |
+$insert_query->query_filter(sub { |
|
231 | 231 |
my ($value, $table, $column, $dbi) = @_; |
232 | 232 |
|
233 | 233 |
if ($table eq 'table1' && $column eq 'key1') { |
... | ... |
@@ -247,7 +247,7 @@ $insert_query = $dbi->create_query($insert_tmpl); |
247 | 247 |
$dbi->query($insert_query, {key1 => 2, key2 => 4}); |
248 | 248 |
$select_tmpl = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}"; |
249 | 249 |
$select_query = $dbi->create_query($select_tmpl); |
250 |
-$select_query->bind_filter(sub { |
|
250 |
+$select_query->query_filter(sub { |
|
251 | 251 |
my ($value, $table, $column, $dbi) = @_; |
252 | 252 |
|
253 | 253 |
if ($table eq 'table1' && $column eq 'key1') { |
... | ... |
@@ -257,7 +257,7 @@ $select_query->bind_filter(sub { |
257 | 257 |
}); |
258 | 258 |
$result = $dbi->query($select_query, {key1 => [1,5], key2 => [2,4]}); |
259 | 259 |
$rows = $result->fetch_hash_all; |
260 |
-is_deeply($rows, [{key1 => 2, key2 => 4}], "$test : bind_filter"); |
|
260 |
+is_deeply($rows, [{key1 => 2, key2 => 4}], "$test : query_filter"); |
|
261 | 261 |
|
262 | 262 |
|
263 | 263 |
test 'DBIx::Custom::SQL::Template basic tag'; |
... | ... |
@@ -442,7 +442,7 @@ $dbi->insert('table1', {key1 => 1, key2 => 2}, |
442 | 442 |
{ |
443 | 443 |
query_edit_cb => sub { |
444 | 444 |
my $query = shift; |
445 |
- $query->bind_filter(sub { |
|
445 |
+ $query->query_filter(sub { |
|
446 | 446 |
my ($value, $table, $column, $dbi) = @_; |
447 | 447 |
if ($column eq 'key1') { |
448 | 448 |
return $value * 3; |
... | ... |
@@ -497,7 +497,7 @@ $dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
497 | 497 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
498 | 498 |
$dbi->update('table1', {key2 => 11}, {where => {key1 => 1}, query_edit_cb => sub { |
499 | 499 |
my $query = shift; |
500 |
- $query->bind_filter(sub { |
|
500 |
+ $query->query_filter(sub { |
|
501 | 501 |
my ($value, $table, $column, $dbi) = @_; |
502 | 502 |
if ($column eq 'key2') { |
503 | 503 |
return $value * 2; |
... | ... |
@@ -541,7 +541,7 @@ $dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
541 | 541 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
542 | 542 |
$dbi->update_all('table1', {key2 => 10}, {query_edit_cb => sub { |
543 | 543 |
my $query = shift; |
544 |
- $query->bind_filter(sub { |
|
544 |
+ $query->query_filter(sub { |
|
545 | 545 |
my ($value, $table, $column, $dbi) = @_; |
546 | 546 |
return $value * 2; |
547 | 547 |
}) |
... | ... |
@@ -568,7 +568,7 @@ $dbi->insert('table1', {key1 => 1, key2 => 2}); |
568 | 568 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
569 | 569 |
$dbi->delete('table1', {where => {key2 => 1}, query_edit_cb => sub { |
570 | 570 |
my $query = shift; |
571 |
- $query->bind_filter(sub { |
|
571 |
+ $query->query_filter(sub { |
|
572 | 572 |
my ($value, $table, $column, $dbi) = @_; |
573 | 573 |
return $value * 2; |
574 | 574 |
}); |
... | ... |
@@ -638,7 +638,7 @@ is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : append statement"); |
638 | 638 |
|
639 | 639 |
$rows = $dbi->select('table1', {where => {key1 => 2}, query_edit_cb =>sub { |
640 | 640 |
my $query = shift; |
641 |
- $query->bind_filter(sub { |
|
641 |
+ $query->query_filter(sub { |
|
642 | 642 |
my ($value, $table, $column, $dbi) = @_; |
643 | 643 |
if ($column eq 'key1') { |
644 | 644 |
return $value - 1; |
... | ... |
@@ -697,11 +697,11 @@ is_deeply(DBIx::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_ |
697 | 697 |
is_deeply(DBIx::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
698 | 698 |
|
699 | 699 |
$query = $dbi->create_query($tmpls[0]); |
700 |
-$query->bind_filter('aaa'); |
|
700 |
+$query->query_filter('aaa'); |
|
701 | 701 |
$query = $dbi->create_query($tmpls[0]); |
702 |
-ok(!$query->bind_filter, "$test : only cached sql and key_infos"); |
|
703 |
-$query->bind_filter('bbb'); |
|
702 |
+ok(!$query->query_filter, "$test : only cached sql and key_infos"); |
|
703 |
+$query->query_filter('bbb'); |
|
704 | 704 |
$query = $dbi->create_query($tmpls[0]); |
705 |
-ok(!$query->bind_filter, "$test : only cached sql and key_infos"); |
|
705 |
+ok(!$query->query_filter, "$test : only cached sql and key_infos"); |
|
706 | 706 |
|
707 | 707 |
|
... | ... |
@@ -17,13 +17,13 @@ test 'Accessors'; |
17 | 17 |
$query = DBIx::Custom::Query->new( |
18 | 18 |
sql => 'a', |
19 | 19 |
key_infos => 'b', |
20 |
- bind_filter => 'c', |
|
20 |
+ query_filter => 'c', |
|
21 | 21 |
sth => 'e', |
22 | 22 |
fetch_filter => 'f', |
23 | 23 |
); |
24 | 24 |
|
25 | 25 |
is($query->sql, 'a', "$test : sql"); |
26 | 26 |
is($query->key_infos, 'b', "$test : key_infos "); |
27 |
-is($query->bind_filter, 'c', "$test : bind_filter"); |
|
27 |
+is($query->query_filter, 'c', "$test : query_filter"); |
|
28 | 28 |
is($query->sth, 'e', "$test : sth"); |
29 | 29 |
|