... | ... |
@@ -1,5 +1,6 @@ |
1 | 1 |
0.1706 |
2 |
- - DBIx::Custom::Query table and filters method is DEPRECATED! |
|
2 |
+ - DBIx::Custom::Query table and filters attribute method and |
|
3 |
+ filter method is DEPRECATED! |
|
3 | 4 |
because I think query object must have only the information |
4 | 5 |
for statement handle caching. |
5 | 6 |
0.1705 |
... | ... |
@@ -1110,7 +1110,7 @@ sub _create_query { |
1110 | 1110 |
# Create query |
1111 | 1111 |
if ($q) { |
1112 | 1112 |
$query = DBIx::Custom::Query->new($q); |
1113 |
- $query->filters($self->filters); |
|
1113 |
+ $query->{filters} = $self->filters; |
|
1114 | 1114 |
} |
1115 | 1115 |
} |
1116 | 1116 |
|
... | ... |
@@ -1156,7 +1156,7 @@ sub _create_query { |
1156 | 1156 |
$query->sth($sth); |
1157 | 1157 |
|
1158 | 1158 |
# Set filters |
1159 |
- $query->filters($self->filters); |
|
1159 |
+ $query->{filters} = $self->filters; |
|
1160 | 1160 |
|
1161 | 1161 |
return $query; |
1162 | 1162 |
} |
... | ... |
@@ -3113,23 +3113,28 @@ L<DBIx::Custom> |
3113 | 3113 |
|
3114 | 3114 |
L<DBIx::Custom::Model> |
3115 | 3115 |
|
3116 |
- # Attribute method |
|
3116 |
+ # Attribute methods |
|
3117 | 3117 |
filter # will be removed at 2017/1/1 |
3118 | 3118 |
name # will be removed at 2017/1/1 |
3119 | 3119 |
type # will be removed at 2017/1/1 |
3120 | 3120 |
|
3121 | 3121 |
L<DBIx::Custom::Query> |
3122 | 3122 |
|
3123 |
- # Attribute method |
|
3123 |
+ # Attribute methods |
|
3124 | 3124 |
default_filter # will be removed at 2017/1/1 |
3125 |
+ table # will be removed at 2017/1/1 |
|
3126 |
+ filters # will be removed at 2017/1/1 |
|
3127 |
+ |
|
3128 |
+ # Methods |
|
3129 |
+ filter # will be removed at 2017/1/1 |
|
3125 | 3130 |
|
3126 | 3131 |
L<DBIx::Custom::QueryBuilder> |
3127 | 3132 |
|
3128 |
- # Attribute method |
|
3133 |
+ # Attribute methods |
|
3129 | 3134 |
tags # will be removed at 2017/1/1 |
3130 | 3135 |
tag_processors # will be removed at 2017/1/1 |
3131 | 3136 |
|
3132 |
- # Method |
|
3137 |
+ # Methods |
|
3133 | 3138 |
register_tag # will be removed at 2017/1/1 |
3134 | 3139 |
register_tag_processor # will be removed at 2017/1/1 |
3135 | 3140 |
|
... | ... |
@@ -3139,7 +3144,7 @@ L<DBIx::Custom::QueryBuilder> |
3139 | 3144 |
|
3140 | 3145 |
L<DBIx::Custom::Result> |
3141 | 3146 |
|
3142 |
- # Attribute method |
|
3147 |
+ # Attribute methods |
|
3143 | 3148 |
filter_check # will be removed at 2017/1/1 |
3144 | 3149 |
|
3145 | 3150 |
# Methods |
... | ... |
@@ -4,27 +4,37 @@ use Object::Simple -base; |
4 | 4 |
use Carp 'croak'; |
5 | 5 |
use DBIx::Custom::Util '_subname'; |
6 | 6 |
|
7 |
-has [qw/sth filters/], |
|
7 |
+has 'sth', |
|
8 | 8 |
sql => '', |
9 |
- tables => sub { [] }, |
|
10 | 9 |
columns => sub { [] }; |
11 | 10 |
|
11 |
+# DEPRECATED! |
|
12 |
+has 'default_filter'; |
|
13 |
+sub filters { |
|
14 |
+ warn "DBIx::Custom::Query filters attribute method is DEPRECATED!"; |
|
15 |
+ my $self = shift; |
|
16 |
+ if (@_) { |
|
17 |
+ $self->{filters} = $_[0]; |
|
18 |
+ return $self; |
|
19 |
+ } |
|
20 |
+ return $self->{filters}; |
|
21 |
+} |
|
22 |
+has tables => sub { [] }; |
|
23 |
+ |
|
24 |
+#DEPRECATED! |
|
12 | 25 |
sub filter { |
26 |
+ warn "DBIx::Custom::Query filter method is DEPRECATED!"; |
|
13 | 27 |
my $self = shift; |
14 |
- |
|
15 | 28 |
if (@_) { |
16 | 29 |
my $filter = {}; |
17 |
- |
|
18 | 30 |
if (ref $_[0] eq 'HASH') { |
19 | 31 |
$filter = $_[0]; |
20 | 32 |
} |
21 | 33 |
else { |
22 | 34 |
my $ef = @_ > 1 ? [@_] : $_[0]; |
23 |
- |
|
24 | 35 |
for (my $i = 0; $i < @$ef; $i += 2) { |
25 | 36 |
my $column = $ef->[$i]; |
26 | 37 |
my $f = $ef->[$i + 1]; |
27 |
- |
|
28 | 38 |
if (ref $column eq 'ARRAY') { |
29 | 39 |
foreach my $c (@$column) { |
30 | 40 |
$filter->{$c} = $f; |
... | ... |
@@ -35,32 +45,24 @@ sub filter { |
35 | 45 |
} |
36 | 46 |
} |
37 | 47 |
} |
38 |
- |
|
39 | 48 |
foreach my $column (keys %$filter) { |
40 | 49 |
my $fname = $filter->{$column}; |
41 |
- |
|
42 | 50 |
if (exists $filter->{$column} |
43 | 51 |
&& defined $fname |
44 | 52 |
&& ref $fname ne 'CODE') |
45 | 53 |
{ |
46 |
- croak qq{Filter "$fname" is not registered" } . _subname |
|
47 |
- unless exists $self->filters->{$fname}; |
|
48 |
- |
|
49 |
- $filter->{$column} = $self->filters->{$fname}; |
|
54 |
+ my $filters = $self->{filters} || {}; |
|
55 |
+ croak qq{Filter "$fname" is not registered" } . _subname |
|
56 |
+ unless exists $filters->{$fname}; |
|
57 |
+ $filter->{$column} = $filters->{$fname}; |
|
50 | 58 |
} |
51 | 59 |
} |
52 |
- |
|
53 | 60 |
$self->{filter} = {%{$self->filter}, %$filter}; |
54 |
- |
|
55 | 61 |
return $self; |
56 | 62 |
} |
57 |
- |
|
58 | 63 |
return $self->{filter} ||= {}; |
59 | 64 |
} |
60 | 65 |
|
61 |
-# DEPRECATED! |
|
62 |
-has 'default_filter'; |
|
63 |
- |
|
64 | 66 |
1; |
65 | 67 |
|
66 | 68 |
=head1 NAME |
... | ... |
@@ -70,6 +72,9 @@ DBIx::Custom::Query - Query |
70 | 72 |
=head1 SYNOPSIS |
71 | 73 |
|
72 | 74 |
my $query = DBIx::Custom::Query->new; |
75 |
+ my $sth = $query->sth; |
|
76 |
+ my $sql = $query->sql; |
|
77 |
+ my $columns = $query->columns; |
|
73 | 78 |
|
74 | 79 |
=head1 ATTRIBUTES |
75 | 80 |
|
... | ... |
@@ -80,16 +85,6 @@ DBIx::Custom::Query - Query |
80 | 85 |
|
81 | 86 |
Column names. |
82 | 87 |
|
83 |
-=head2 C<filter> |
|
84 |
- |
|
85 |
- my $filter = $query->filter; |
|
86 |
- $query = $query->filter(author => 'to_something', |
|
87 |
- title => 'to_something'); |
|
88 |
- |
|
89 |
- $query = $query->filter([qw/author title/] => 'to_something'); |
|
90 |
- |
|
91 |
-Filters when parameter binding is executed. |
|
92 |
- |
|
93 | 88 |
=head2 C<sql> |
94 | 89 |
|
95 | 90 |
my $sql = $query->sql; |
... | ... |
@@ -6,7 +6,7 @@ use utf8; |
6 | 6 |
use Encode qw/encode_utf8 decode_utf8/; |
7 | 7 |
use Data::Dumper; |
8 | 8 |
|
9 |
-$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/}; |
|
9 |
+#$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/}; |
|
10 | 10 |
|
11 | 11 |
BEGIN { |
12 | 12 |
eval { require DBD::SQLite; 1 } |