Showing 4 changed files with 49 additions and 52 deletions
+3
Changes
... ...
@@ -1,3 +1,6 @@
1
+0.1605
2
+  changed arguments of tag processor
3
+  remaned DBIx::Custom::QueryBuilder::TagProcessors functions
1 4
 0.1604
2 5
   changed argument of tag processor(not backword compatible)
3 6
   renamed default_query_filter to default_bind_filter(not backword compatible)
+1 -1
lib/DBIx/Custom.pm
... ...
@@ -450,7 +450,7 @@ DBIx::Custom - DBI with hash parameter binding and filtering system
450 450
 
451 451
 =cut
452 452
 
453
-our $VERSION = '0.1604';
453
+our $VERSION = '0.1605';
454 454
 
455 455
 =head1 STABILITY
456 456
 
+12 -12
lib/DBIx/Custom/QueryBuilder.pm
... ...
@@ -11,17 +11,17 @@ use DBIx::Custom::QueryBuilder::TagProcessor;
11 11
 
12 12
 __PACKAGE__->dual_attr('tag_processors', default => sub { {} }, inherit => 'hash_copy');
13 13
 __PACKAGE__->register_tag_processor(
14
-    '?'      => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_placeholder_tag,
15
-    '='      => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_equal_tag,
16
-    '<>'     => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_not_equal_tag,
17
-    '>'      => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_greater_than_tag,
18
-    '<'      => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_lower_than_tag,
19
-    '>='     => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_greater_than_equal_tag,
20
-    '<='     => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_lower_than_equal_tag,
21
-    'like'   => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_like_tag,
22
-    'in'     => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_in_tag,
23
-    'insert' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_insert_tag,
24
-    'update' => \&DBIx::Custom::QueryBuilder::TagProcessors::expand_update_tag
14
+    '?'      => \&DBIx::Custom::QueryBuilder::TagProcessors::placeholder,
15
+    '='      => \&DBIx::Custom::QueryBuilder::TagProcessors::equal,
16
+    '<>'     => \&DBIx::Custom::QueryBuilder::TagProcessors::not_equal,
17
+    '>'      => \&DBIx::Custom::QueryBuilder::TagProcessors::greater_than,
18
+    '<'      => \&DBIx::Custom::QueryBuilder::TagProcessors::lower_than,
19
+    '>='     => \&DBIx::Custom::QueryBuilder::TagProcessors::greater_than_equal,
20
+    '<='     => \&DBIx::Custom::QueryBuilder::TagProcessors::lower_than_equal,
21
+    'like'   => \&DBIx::Custom::QueryBuilder::TagProcessors::like,
22
+    'in'     => \&DBIx::Custom::QueryBuilder::TagProcessors::in,
23
+    'insert' => \&DBIx::Custom::QueryBuilder::TagProcessors::insert,
24
+    'update' => \&DBIx::Custom::QueryBuilder::TagProcessors::update
25 25
 );
26 26
 
27 27
 __PACKAGE__->attr(tag_start => '{');
... ...
@@ -159,7 +159,7 @@ sub _build_query {
159 159
               unless ref $tag_processor eq 'CODE';
160 160
             
161 161
             # Expand tag using tag processor
162
-            my ($expand, $columns) = @{$tag_processor->($tag_args)};
162
+            my ($expand, $columns) = @{$tag_processor->(@$tag_args)};
163 163
             
164 164
             # Check tag processor return value
165 165
             croak qq{Tag processor "$tag_name" must return [\$expand, \$columns]}
+33 -39
lib/DBIx/Custom/QueryBuilder/TagProcessor.pm
... ...
@@ -5,11 +5,8 @@ use warnings;
5 5
 
6 6
 use Carp 'croak';
7 7
 
8
-sub expand_basic_tag {
9
-    my ($name, $args) = @_;
10
-    
11
-    # Column
12
-    my $column = $args->[0];
8
+sub _basic {
9
+    my ($name, $column) = @_;
13 10
     
14 11
     # Check arguments
15 12
     croak qq{Column must be specified in tag "{$name }"}
... ...
@@ -18,19 +15,16 @@ sub expand_basic_tag {
18 15
     return ["$column $name ?", [$column]];
19 16
 }
20 17
 
21
-sub expand_equal_tag              { expand_basic_tag('=', @_) }
22
-sub expand_not_equal_tag          { expand_basic_tag('<>', @_) }
23
-sub expand_greater_than_tag       { expand_basic_tag('>', @_) }
24
-sub expand_lower_than_tag         { expand_basic_tag('<', @_) }
25
-sub expand_greater_than_equal_tag { expand_basic_tag('>=', @_) }
26
-sub expand_lower_than_equal_tag   { expand_basic_tag('<=', @_) }
27
-sub expand_like_tag               { expand_basic_tag('like', @_) }
18
+sub equal              { _basic('=',    @_) }
19
+sub not_equal          { _basic('<>',   @_) }
20
+sub greater_than       { _basic('>',    @_) }
21
+sub lower_than         { _basic('<',    @_) }
22
+sub greater_than_equal { _basic('>=',   @_) }
23
+sub lower_than_equal   { _basic('<=',   @_) }
24
+sub like               { _basic('like', @_) }
28 25
 
29
-sub expand_placeholder_tag {
30
-    my $tag_args = shift;
31
-    
32
-    # Column
33
-    my $column = $tag_args->[0];
26
+sub placeholder {
27
+    my $column = shift;
34 28
     
35 29
     # Check arguments
36 30
     croak qq{Column must be specified in tag "{? }"}
... ...
@@ -39,8 +33,8 @@ sub expand_placeholder_tag {
39 33
     return ['?', [$column]];
40 34
 }
41 35
 
42
-sub expand_in_tag {
43
-    my ($column, $count) = @{$_[0]};
36
+sub in {
37
+    my ($column, $count) = @_;
44 38
     
45 39
     # Check arguments
46 40
     croak qq{Column and count of values must be specified in tag "{in }"}
... ...
@@ -61,31 +55,31 @@ sub expand_in_tag {
61 55
     return [$expand, $columns];
62 56
 }
63 57
 
64
-sub expand_insert_tag {
65
-    my $columns = shift;
58
+sub insert {
59
+    my @columns = @_;
66 60
     
67 61
     # Insert
68 62
     my $expand = '(';
69
-    $expand .= "$_, " for @$columns;
63
+    $expand .= "$_, " for @columns;
70 64
     $expand =~ s/, $//;
71 65
     $expand .= ') ';
72 66
     $expand .= 'values (';
73
-    $expand .= "?, " for @$columns;
67
+    $expand .= "?, " for @columns;
74 68
     $expand =~ s/, $//;
75 69
     $expand .= ')';
76 70
     
77
-    return [$expand, [@$columns]];
71
+    return [$expand, \@columns];
78 72
 }
79 73
 
80
-sub expand_update_tag {
81
-    my $columns = shift;
74
+sub update {
75
+    my @columns = @_;
82 76
     
83 77
     # Update
84 78
     my $expand = 'set ';
85
-    $expand .= "$_ = ?, " for @$columns;
79
+    $expand .= "$_ = ?, " for @columns;
86 80
     $expand =~ s/, $//;
87 81
     
88
-    return [$expand, [@$columns]];
82
+    return [$expand, \@columns];
89 83
 }
90 84
 
91 85
 1;
... ...
@@ -96,25 +90,25 @@ DBIx::Custom::SQLBuilder::TagProcessors - Tag processor
96 90
 
97 91
 =head1 FUNCTIONS
98 92
 
99
-=head2 C<expand_basic_tag>
93
+=head2 C<placeholder>
100 94
 
101
-=head2 C<expand_equal_tag>
95
+=head2 C<equal>
102 96
 
103
-=head2 C<expand_not_equal_tag>
97
+=head2 C<not_equal>
104 98
 
105
-=head2 C<expand_greater_than_tag>
99
+=head2 C<greater_than>
106 100
 
107
-=head2 C<expand_lower_than_tag>
101
+=head2 C<lower_than>
108 102
 
109
-=head2 C<expand_greater_than_equal_tag>
103
+=head2 C<greater_than_equal>
110 104
 
111
-=head2 C<expand_lower_than_equal_tag>
105
+=head2 C<lower_than_equal>
112 106
 
113
-=head2 C<expand_like_tag>
107
+=head2 C<like>
114 108
 
115
-=head2 C<expand_in_tag>
109
+=head2 C<in>
116 110
 
117
-=head2 C<expand_insert_tag>
111
+=head2 C<insert>
118 112
 
119
-=head2 C<expand_update_tag>
113
+=head2 C<update>
120 114