Showing 12 changed files with 4196 additions and 4241 deletions
+572 -572
Changes
... ...
@@ -1,754 +1,754 @@
1 1
 0.2106
2
-    - renamed DBIx::Custom::Result::fetch_hash_first to fethc_hash_one
3
-      because first is misleading name. fethc_hash_first is DEPRECATED!
4
-    - renamed DBIx::Custom::Result::fetch_first to fetch_one,
5
-      because first is misleading name. fetch_first is DEPRECATED!
2
+  - renamed DBIx::Custom::Result::fetch_hash_first to fethc_hash_one
3
+    because first is misleading name. fethc_hash_first is DEPRECATED!
4
+  - renamed DBIx::Custom::Result::fetch_first to fetch_one,
5
+    because first is misleading name. fetch_first is DEPRECATED!
6 6
 0.2105
7
-    - added EXPERIMENTAL DBIx::Custom::Result::value method
8
-    - added EXPERIMENTAL DBIx::Custom::Result::column method
7
+  - added EXPERIMENTAL DBIx::Custom::Result::value method
8
+  - added EXPERIMENTAL DBIx::Custom::Result::column method
9 9
 0.2104
10
-    - improved bulk_insert performance
10
+  - improved bulk_insert performance
11 11
 0.2103
12
-    - added EXPERIMENTAL insert bulk_insert option.
12
+  - added EXPERIMENTAL insert bulk_insert option.
13 13
 0.2102
14
-    - fixed bug that DBIx::Custom::Model count method don't receive model's
15
-      attribute
16
-    - insert method can receive multipule parameters, this is very fast, this is experimental
14
+  - fixed bug that DBIx::Custom::Model count method don't receive model's
15
+    attribute
16
+  - insert method can receive multipule parameters, this is very fast, this is experimental
17 17
 0.2101
18
-    - fixed small default_bind_filter bug
19
-    - micro optimization
20
-    - select method can receive odd number argument. In that case first argument
21
-      is column option.
22
-    - fixed update_or_insert bug that when parameter don't contain any key-value
23
-      this method throw exception.
18
+  - fixed small default_bind_filter bug
19
+  - micro optimization
20
+  - select method can receive odd number argument. In that case first argument
21
+    is column option.
22
+  - fixed update_or_insert bug that when parameter don't contain any key-value
23
+    this method throw exception.
24 24
 0.2100
25
-    - micro optimization
26
-    - DBIx::Custom::Query is DEPRECATED!
25
+  - micro optimization
26
+  - DBIx::Custom::Query is DEPRECATED!
27 27
 0.1747
28
-    - fixed bug DBIx::Custom::Result fetch_hash_multi throw warnings
29
-      which cannnot fetch any more
30
-    - fixed bug DBIx::Custom::Result fetch_hash_multi throw warnings
31
-      which cannnot fetch any more
28
+  - fixed bug DBIx::Custom::Result fetch_hash_multi throw warnings
29
+    which cannnot fetch any more
30
+  - fixed bug DBIx::Custom::Result fetch_hash_multi throw warnings
31
+    which cannnot fetch any more
32 32
 0.1746
33
-    - micro optimization
33
+  - micro optimization
34 34
 0.1745
35
-    - DBIx::Custom::Order prepend method receiving array reference
36
-      is DEPRECATED!
37
-    - DBIx::Custom::QueryBuilder class is DEPRECATED!
38
-    - added DBIX_CUSTOM_DISABLE_MODEL_EXECUTE environment variable
39
-    - added DBIX_CUSTOM_TAG_PARSE environment variable
40
-    - tag_parse attribute is DEPRECATED! 
41
-    - show_datatype method return lower case string
42
-    - show_typename method return lower case string
43
-    - DBIx::Custom::Result filter_on method is DEPRECATED!
44
-    - DBIx::Custom::Result filter_off method is DEPRECATED!
35
+  - DBIx::Custom::Order prepend method receiving array reference
36
+    is DEPRECATED!
37
+  - DBIx::Custom::QueryBuilder class is DEPRECATED!
38
+  - added DBIX_CUSTOM_DISABLE_MODEL_EXECUTE environment variable
39
+  - added DBIX_CUSTOM_TAG_PARSE environment variable
40
+  - tag_parse attribute is DEPRECATED! 
41
+  - show_datatype method return lower case string
42
+  - show_typename method return lower case string
43
+  - DBIx::Custom::Result filter_on method is DEPRECATED!
44
+  - DBIx::Custom::Result filter_off method is DEPRECATED!
45 45
 0.1744
46
-    - id option work if id count is lower than primary key count.
47
-    - removed EXPERIMETNAL status from update_or_insert method and
48
-      DBIx::Custom::Model's update_or_insert method
49
-    - removed EXPERIMENTAL status from reuse option
50
-    - removed EXPERIMENTAL status from update_at option and created_at option
51
-    - removed EXPERIMETNAL status from now attribute
46
+  - id option work if id count is lower than primary key count.
47
+  - removed EXPERIMETNAL status from update_or_insert method and
48
+    DBIx::Custom::Model's update_or_insert method
49
+  - removed EXPERIMENTAL status from reuse option
50
+  - removed EXPERIMENTAL status from update_at option and created_at option
51
+  - removed EXPERIMETNAL status from now attribute
52 52
 0.1743
53
-    - DBIx::Custom::Model execute method is DEPRECATED!
54
-    - fixed bug that update_all can't receive parameter as first argument
55
-    - fixed bug that delete_all can't receive parameter as first argument
56
-    - fixed where clause parsing bug when time(like 00:00:00) contain
53
+  - DBIx::Custom::Model execute method is DEPRECATED!
54
+  - fixed bug that update_all can't receive parameter as first argument
55
+  - fixed bug that delete_all can't receive parameter as first argument
56
+  - fixed where clause parsing bug when time(like 00:00:00) contain
57 57
 0.1742
58
-    - fixed update_or_insert method bug
59
-    - micro optimization
58
+  - fixed update_or_insert method bug
59
+  - micro optimization
60 60
 0.1741
61
-    - added EXPERIMENTAL update_or_insert to DBIx::Custom::Model
61
+  - added EXPERIMENTAL update_or_insert to DBIx::Custom::Model
62 62
 0.1740
63
-    - EXPERIMENTAL update_or_insert need id and primary_key option
64
-      and added option option
65
-    - insert method created_at and updated_at option can receive scalar reference
66
-    - update method updated_at option can receive scalar reference
67
-    - select column option [COLUMN => ALIAS] syntax is DEPRECATED!
68
-    - added EXPERIMENTAL q method
69
-    - execute method id option is DEPRECATED!
63
+  - EXPERIMENTAL update_or_insert need id and primary_key option
64
+    and added option option
65
+  - insert method created_at and updated_at option can receive scalar reference
66
+  - update method updated_at option can receive scalar reference
67
+  - select column option [COLUMN => ALIAS] syntax is DEPRECATED!
68
+  - added EXPERIMENTAL q method
69
+  - execute method id option is DEPRECATED!
70 70
 0.1739
71
-    - insert timestamp option is DEPRECATED!
72
-      use created_at option with now attribute
73
-    - update timestamp option is DEPRECATED!
74
-      use updated_at option wieh now attribute
75
-    - insert_timestamp method is DEPRECATED!
76
-      use now method
77
-    - update_timestamp method is DEPRECATED!
78
-      use use now method
79
-    - added EXPEREIMTNAL now method
80
-    - added EXPERIMENTAL insert created_at option
81
-    - added EXPERIMETNAL insert updated_at option
82
-    - added EXPERIMETNAL update updated_at option
83
-    - added new timestamp system using the above methods and options
71
+  - insert timestamp option is DEPRECATED!
72
+    use created_at option with now attribute
73
+  - update timestamp option is DEPRECATED!
74
+    use updated_at option wieh now attribute
75
+  - insert_timestamp method is DEPRECATED!
76
+    use now method
77
+  - update_timestamp method is DEPRECATED!
78
+    use use now method
79
+  - added EXPEREIMTNAL now method
80
+  - added EXPERIMENTAL insert created_at option
81
+  - added EXPERIMETNAL insert updated_at option
82
+  - added EXPERIMETNAL update updated_at option
83
+  - added new timestamp system using the above methods and options
84 84
 0.1738
85
-    - micro optimization
86
-    - removed example that query pass execute method in documentation
87
-      this is many bug reason much more than I have expected
88
-      and passing query to execute method is DEPRECATED!
89
-    - insert method id value is not copied to parameter
90
-      if the key exists in parameter
85
+  - micro optimization
86
+  - removed example that query pass execute method in documentation
87
+    this is many bug reason much more than I have expected
88
+    and passing query to execute method is DEPRECATED!
89
+  - insert method id value is not copied to parameter
90
+    if the key exists in parameter
91 91
 0.1737
92
-    - micro optimization
93
-    - fixed DEBUG messsage bug
92
+  - micro optimization
93
+  - fixed DEBUG messsage bug
94 94
 0.1736
95
-    - micro optimization
95
+  - micro optimization
96 96
 0.1735
97
-    - added EXPERIMENTAL reuse_query option to execute method
97
+  - added EXPERIMENTAL reuse_query option to execute method
98 98
 0.1734
99
-    - moved DBIx::Custom::Guide to wiki
99
+  - moved DBIx::Custom::Guide to wiki
100 100
 0.1733
101
-    - select method join option can receive string.
102
-    - removed DEPRECATED status of select param option
103
-    - select method where_param option is DEPRECATED!
104
-      use where => [STRING, PARAM] syntax instead
105
-    - delete method where_param option is DEPRECATED!
106
-      use where => [STRING, PARAM] syntax instead
107
-    - update method where_param option is DEPRECATED!
108
-      use where => [STRING, PARAM] syntax instead
109
-    - update method param option is DEPRECATED!
110
-    - insert method param option is DEPRECATED!
111
-    - removed argument checking logic because in database performance is more
112
-      important.
101
+  - select method join option can receive string.
102
+  - removed DEPRECATED status of select param option
103
+  - select method where_param option is DEPRECATED!
104
+    use where => [STRING, PARAM] syntax instead
105
+  - delete method where_param option is DEPRECATED!
106
+    use where => [STRING, PARAM] syntax instead
107
+  - update method where_param option is DEPRECATED!
108
+    use where => [STRING, PARAM] syntax instead
109
+  - update method param option is DEPRECATED!
110
+  - insert method param option is DEPRECATED!
111
+  - removed argument checking logic because in database performance is more
112
+    important.
113 113
 0.1732
114
-    - removed EXPERIMETNAL flag from like_value
114
+  - removed EXPERIMETNAL flag from like_value
115 115
 0.1731
116
-    - removed DEPRECATED status from insert method's id option
117
-    - renamed EXPERIMENTAL insert_or_update to update_or_insert
116
+  - removed DEPRECATED status from insert method's id option
117
+  - renamed EXPERIMENTAL insert_or_update to update_or_insert
118 118
 0.1730
119
-    - added EXPERIMENTAL insert_or_update method
120
-    - method method of DBIx::Custom::Model is renamed to helper,
121
-      method is DEPRECATED!
122
-    - method method is renamed to helper, method is DEPRECATED!
123
-    - insert method's id option is DEPRECATED!
124
-    - fixed id option bug when column name is anbiguous
119
+  - added EXPERIMENTAL insert_or_update method
120
+  - method method of DBIx::Custom::Model is renamed to helper,
121
+    method is DEPRECATED!
122
+  - method method is renamed to helper, method is DEPRECATED!
123
+  - insert method's id option is DEPRECATED!
124
+  - fixed id option bug when column name is anbiguous
125 125
 0.1729
126
-    - dbi_option attribute is renamed to option, dbi_option is DEPRECATED!
127
-    - default_dbi_option is renamed to default_option, default_dbi_option
128
-      is DEPRECATED!
126
+  - dbi_option attribute is renamed to option, dbi_option is DEPRECATED!
127
+  - default_dbi_option is renamed to default_option, default_dbi_option
128
+    is DEPRECATED!
129 129
 0.1728
130
-    - added {key => ..., value => ...} syntax to DBIx::Custom::Mapper map method
131
-      ,and argument of string and code reference is DEPRECATED!
132
-    - update_param is DEPRECATED, use assing_clause instead.
133
-    - assing_param is renamed to assing_clause, assing_param is DEPRECATED!
134
-    - insert_param is renamed to values_clause, insert_param is DEPRECATED!
130
+  - added {key => ..., value => ...} syntax to DBIx::Custom::Mapper map method
131
+    ,and argument of string and code reference is DEPRECATED!
132
+  - update_param is DEPRECATED, use assing_clause instead.
133
+  - assing_param is renamed to assing_clause, assing_param is DEPRECATED!
134
+  - insert_param is renamed to values_clause, insert_param is DEPRECATED!
135 135
 0.1727
136
-    - improved join clause parsing
136
+  - improved join clause parsing
137 137
 0.1726
138
-    - improved join clause parsing
138
+  - improved join clause parsing
139 139
 0.1725
140
-    - improved join clause parsing
140
+  - improved join clause parsing
141 141
 0.1724
142
-    - added EXPERIMENTAL like_value method to DBIx::Custom
143
-    - sqlfilter option is renamed to after_build_sql, sqlfilter is DEPRECATED!
144
-    - removed EXPERIMENTAL flag from DBIx::Custom::Mapper
145
-    - removed EXPERIMENTAL flag from the following DBIx::Custom methods
146
-    insert_timestamp, mapper, update_timestamp
147
-    - removed EXPERIMENTAL flag from the following DBIx::Custom method's option
148
-    timestamp, 
142
+  - added EXPERIMENTAL like_value method to DBIx::Custom
143
+  - sqlfilter option is renamed to after_build_sql, sqlfilter is DEPRECATED!
144
+  - removed EXPERIMENTAL flag from DBIx::Custom::Mapper
145
+  - removed EXPERIMENTAL flag from the following DBIx::Custom methods
146
+  insert_timestamp, mapper, update_timestamp
147
+  - removed EXPERIMENTAL flag from the following DBIx::Custom method's option
148
+  timestamp, 
149 149
 0.1723
150
-    - removed EXPERIMENTAL call_dbi method from DBIx::Custom::Model
151
-    - removed EXPERIMENTAL map_param method from DBIx::Custom
152
-    - removed EXPERIMENTAL the following methods from DBIx::Custom::Where
153
-      if, map
154
-    - removed EXPERIMENTAL flag from the following DBIx::Custom::Model methods
155
-      count, execute
156
-    - removed EXPERIMENTAL flag from the following DBIx::Custom::Result mehotds
157
-      filter_on, type_rule, type_rule_off, type_rule_on, type_rule1_off,
158
-      type_rule1_on, type_rule2_off, type_rule2_on
159
-    - removed EXPERIMENTAL flag from the following DBIx::Custom method's options
160
-      sqlfilter, type_rule_off, type_rule1_off, type_rule2_off,
161
-      table_alias, wrap
162
-    - removed EXPERIMENTAL flag from DBIx::Custom::Order
163
-    - removed EXPERIMETNAL flag from the following DBIx::Custom methods
164
-      exclude_table, user_column_info,
165
-      user_table_info, available_datatype, available_typename,
166
-      assign_param, count, get_column_info, get_table_info
167
-      order, show_datatype, show_typename methods, show_tables, type_rule,
168
-    - added EXPERIMENTAL update_timestamp method to DBIx::Custom
169
-    - added EXPERIMENTAL insert_timestamp method to DBIx::Custom
170
-    - removed EXPERIMENTAL timestamp attribute from DBIx::Custom
150
+  - removed EXPERIMENTAL call_dbi method from DBIx::Custom::Model
151
+  - removed EXPERIMENTAL map_param method from DBIx::Custom
152
+  - removed EXPERIMENTAL the following methods from DBIx::Custom::Where
153
+    if, map
154
+  - removed EXPERIMENTAL flag from the following DBIx::Custom::Model methods
155
+    count, execute
156
+  - removed EXPERIMENTAL flag from the following DBIx::Custom::Result mehotds
157
+    filter_on, type_rule, type_rule_off, type_rule_on, type_rule1_off,
158
+    type_rule1_on, type_rule2_off, type_rule2_on
159
+  - removed EXPERIMENTAL flag from the following DBIx::Custom method's options
160
+    sqlfilter, type_rule_off, type_rule1_off, type_rule2_off,
161
+    table_alias, wrap
162
+  - removed EXPERIMENTAL flag from DBIx::Custom::Order
163
+  - removed EXPERIMETNAL flag from the following DBIx::Custom methods
164
+    exclude_table, user_column_info,
165
+    user_table_info, available_datatype, available_typename,
166
+    assign_param, count, get_column_info, get_table_info
167
+    order, show_datatype, show_typename methods, show_tables, type_rule,
168
+  - added EXPERIMENTAL update_timestamp method to DBIx::Custom
169
+  - added EXPERIMENTAL insert_timestamp method to DBIx::Custom
170
+  - removed EXPERIMENTAL timestamp attribute from DBIx::Custom
171 171
 0.1722
172
-    - added EXPERIMENTAL timestamp option to DBIx::Custom insert
173
-      and update method.
174
-    - added EXPERIMENTAL timestamp attribute to DBIx::Custom
175
-    - added {KEY => {OPTION_KEY => OPTION_VALUE} syntax
176
-      to EXPERIMENTAL DBIx::Custom::Mapper map method
177
-    - added {KEY => sub { VALUE }} syntax
178
-      to EXPERIMETNAL DBIx::Custom::Mapper map method
179
-    - removed EXPERIMENTAL wrap option from select method
180
-    - insert_param, update_param, and assign param can
181
-      be wrapeed by DB function by C<wrap> option
182
-    - added EXPERIMENTAL pass attribute to DBIx::Custom::Mapper
183
-    - removed EXPERIMENTAL ignore attribute from DBIx::Custom::Mapper
172
+  - added EXPERIMENTAL timestamp option to DBIx::Custom insert
173
+    and update method.
174
+  - added EXPERIMENTAL timestamp attribute to DBIx::Custom
175
+  - added {KEY => {OPTION_KEY => OPTION_VALUE} syntax
176
+    to EXPERIMENTAL DBIx::Custom::Mapper map method
177
+  - added {KEY => sub { VALUE }} syntax
178
+    to EXPERIMETNAL DBIx::Custom::Mapper map method
179
+  - removed EXPERIMENTAL wrap option from select method
180
+  - insert_param, update_param, and assign param can
181
+    be wrapeed by DB function by C<wrap> option
182
+  - added EXPERIMENTAL pass attribute to DBIx::Custom::Mapper
183
+  - removed EXPERIMENTAL ignore attribute from DBIx::Custom::Mapper
184 184
 0.1721
185
-    - added EXPERIMENTAL DBIx::Custom::Mapper class
186
-    - added EXPERIMENTAL mapper method to DBIx::Custom
185
+  - added EXPERIMENTAL DBIx::Custom::Mapper class
186
+  - added EXPERIMENTAL mapper method to DBIx::Custom
187 187
 0.1720
188
-    - removed placeholder count check
189
-    - added EXPERIMENTAL execute method's id and primary key option.
190
-    - added EXPERIMENTAL DBIx::Custom::Model execute method
188
+  - removed placeholder count check
189
+  - added EXPERIMENTAL execute method's id and primary key option.
190
+  - added EXPERIMENTAL DBIx::Custom::Model execute method
191 191
 0.1719
192
-    - DBIx::Custom support Microsoft Access through DBD::ODBC
192
+  - DBIx::Custom support Microsoft Access through DBD::ODBC
193 193
 0.1718
194
-    - added EXPERIMENTAL DBIx::Custom::Model call_dbi method
195
-    - added EXPERIMENTAL count method
196
-    - added EXPERIMENTAL DBIx::Custom::Model count method
194
+  - added EXPERIMENTAL DBIx::Custom::Model call_dbi method
195
+  - added EXPERIMENTAL count method
196
+  - added EXPERIMENTAL DBIx::Custom::Model count method
197 197
 0.1717
198
-    - added EXPERIMENTAL get_table_info
199
-    - added EXPERIMETNAL user_table_info attribute
200
-      and each_table find table info in user_table_info if set.
201
-    - added EXPERIMENTAL get_column_info
202
-    - added EXPERIMENTAL user_column_info attribute
203
-      and each_column find column info in user_column_info if set.
204
-    - connector is automatically set to DBDx::Connector object
205
-      if connector is set to 1 when connect method is called.
198
+  - added EXPERIMENTAL get_table_info
199
+  - added EXPERIMETNAL user_table_info attribute
200
+    and each_table find table info in user_table_info if set.
201
+  - added EXPERIMENTAL get_column_info
202
+  - added EXPERIMENTAL user_column_info attribute
203
+    and each_column find column info in user_column_info if set.
204
+  - connector is automatically set to DBDx::Connector object
205
+    if connector is set to 1 when connect method is called.
206 206
 0.1716
207
-    - fixed bugs when using DBD::Oracle.
208
-    - added EXPERIMENTAL show_tables method.
207
+  - fixed bugs when using DBD::Oracle.
208
+  - added EXPERIMENTAL show_tables method.
209 209
 0.1715
210
-    - default quote attribute in ODBC driver is changed to "[]"
211
-    - fixed some bug in Microsoft SQL Server
212
-    - added EXPERIMENTAL execute method sqlfilter option
210
+  - default quote attribute in ODBC driver is changed to "[]"
211
+  - fixed some bug in Microsoft SQL Server
212
+  - added EXPERIMENTAL execute method sqlfilter option
213 213
 0.1714
214
-    - fixed not backword compatible change in 0.1712 query_buider
214
+  - fixed not backword compatible change in 0.1712 query_buider
215 215
 0.1713
216
-    - fixed memory leak and connection increasing bug when using model.
216
+  - fixed memory leak and connection increasing bug when using model.
217 217
 0.1712
218
-    - you can set any string as separator
219
-    - fixed memory leak and connection increasing bug, and query_buider method return new object.
220
-    - added EXPERIMENTAL exclude_table attribute
221
-    - added EXPERIMENTAL show_typename method
222
-    - added EXPERIMENTAL show_datatype method
218
+  - you can set any string as separator
219
+  - fixed memory leak and connection increasing bug, and query_buider method return new object.
220
+  - added EXPERIMENTAL exclude_table attribute
221
+  - added EXPERIMENTAL show_typename method
222
+  - added EXPERIMENTAL show_datatype method
223 223
 0.1711
224
-    - renamed EXPERIMENTAL available_type_name to available_typename
225
-    - renamed EXPERIMENTAL available_data_type to available_datatype
226
-    - added EXPERIMENTAL DBIx::Custom::Where if method
227
-    - added EXPERIMENTAL DBIx::Custom::Where map method
224
+  - renamed EXPERIMENTAL available_type_name to available_typename
225
+  - renamed EXPERIMENTAL available_data_type to available_datatype
226
+  - added EXPERIMENTAL DBIx::Custom::Where if method
227
+  - added EXPERIMENTAL DBIx::Custom::Where map method
228 228
 0.1710
229
-    - use more DBIx::Custom information in sub modules to decrease bugs
230
-      (very sorry, this change can't keep backword compatible,
231
-       but maybe no effects,
232
-       because the attributes is automatically set by DBIx::Custom, not user).
233
-    - Fixed fisrt executed where clause failed in some condition.
229
+  - use more DBIx::Custom information in sub modules to decrease bugs
230
+    (very sorry, this change can't keep backword compatible,
231
+     but maybe no effects,
232
+     because the attributes is automatically set by DBIx::Custom, not user).
233
+  - Fixed fisrt executed where clause failed in some condition.
234 234
 0.1709
235
-    - fixed named placeholder bug and added escape syntax
235
+  - fixed named placeholder bug and added escape syntax
236 236
 0.1708
237
-    - improved execute method performance
237
+  - improved execute method performance
238 238
 0.1707
239
-    - I call :title named placeholder, stoping calling it parameter
240
-    - removed some EXPERIMENTAL status
241
-    - fixed performance
239
+  - I call :title named placeholder, stoping calling it parameter
240
+  - removed some EXPERIMENTAL status
241
+  - fixed performance
242 242
 0.1706
243
-    - Added execute method's query option document
244
-      You can get more performance.
245
-    - DBIx::Custom::Query table and filters attribute method and
246
-      filter method is DEPRECATED!
247
-      because I think query object must have only the information
248
-      for statement handle caching.
243
+  - Added execute method's query option document
244
+    You can get more performance.
245
+  - DBIx::Custom::Query table and filters attribute method and
246
+    filter method is DEPRECATED!
247
+    because I think query object must have only the information
248
+    for statement handle caching.
249 249
 0.1705
250
-    - insert and update method's param can set constant value by scalara reference
251
-      such as {date => \"NOW()"} This is EXPERIMENTAL.
250
+  - insert and update method's param can set constant value by scalara reference
251
+    such as {date => \"NOW()"} This is EXPERIMENTAL.
252 252
 0.1704
253
-    - added quote method's two character support like []
254
-      for Microsoft SQL Server and Access
255
-    - added EXPERIMENTAL parameter new syntax :name{operator}
253
+  - added quote method's two character support like []
254
+    for Microsoft SQL Server and Access
255
+  - added EXPERIMENTAL parameter new syntax :name{operator}
256 256
 0.1703
257
-    - added EXPERIMENTAL join new syntax.
257
+  - added EXPERIMENTAL join new syntax.
258 258
 0.1702
259
-    - removed EXPERIMENTAL status of some methods.
260
-    - fixed some join bug
259
+  - removed EXPERIMENTAL status of some methods.
260
+  - fixed some join bug
261 261
 0.1701
262
-    - added DBIx::Cusotm::Order prepend method automatically quoted syntax
263
-    - simplified arguments check
264
-    - added EXPERIMENTAL each_table method
265
-    - select method column option [COLUMN, as => ALIAS] format is DEPRECATED!
266
-      changed to [COLUMN => ALIAS]
267
-    - added EXPERIMENTAL DBIx::Custom::Result header method
268
-    - added EXPERIMENTAL last_sql attribute method
262
+  - added DBIx::Cusotm::Order prepend method automatically quoted syntax
263
+  - simplified arguments check
264
+  - added EXPERIMENTAL each_table method
265
+  - select method column option [COLUMN, as => ALIAS] format is DEPRECATED!
266
+    changed to [COLUMN => ALIAS]
267
+  - added EXPERIMENTAL DBIx::Custom::Result header method
268
+  - added EXPERIMENTAL last_sql attribute method
269 269
 0.1700
270
-    - fixed end_filter DEPRECATED warnings bug
270
+  - fixed end_filter DEPRECATED warnings bug
271 271
 0.1699
272
-    - added tag_parse attribute.
273
-    - added EXPERIMENTAL order method
274
-    - added EXPERIMENTAL DBIx::Custom::Order module
275
-    - changed backword compatible policy
276
-      ------------------------------------------------------------------------
277
-      If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
278
-      except for attribute method.
279
-      You can check all DEPRECATED functionalities by document.
280
-      DEPRECATED functionality is removed after five years,
281
-      but if at least one person use the functionality and tell me that thing
282
-      I extend one year each time you tell me it.
272
+  - added tag_parse attribute.
273
+  - added EXPERIMENTAL order method
274
+  - added EXPERIMENTAL DBIx::Custom::Order module
275
+  - changed backword compatible policy
276
+    ------------------------------------------------------------------------
277
+    If a functionality is DEPRECATED, you can know it by DEPRECATED warnings
278
+    except for attribute method.
279
+    You can check all DEPRECATED functionalities by document.
280
+    DEPRECATED functionality is removed after five years,
281
+    but if at least one person use the functionality and tell me that thing
282
+    I extend one year each time you tell me it.
283 283
 
284
-      EXPERIMENTAL functionality will be changed without warnings.
285
-      ------------------------------------------------------------------------
284
+    EXPERIMENTAL functionality will be changed without warnings.
285
+    ------------------------------------------------------------------------
286 286
 0.1698
287
-    - fixed DBIx::Custom::Where to_string method small bug
288
-    - added EXPERIMENTAL execute method table_alias option
287
+  - fixed DBIx::Custom::Where to_string method small bug
288
+  - added EXPERIMENTAL execute method table_alias option
289 289
 0.1697
290
-    - added EXPERIMENTAL map_param method
290
+  - added EXPERIMENTAL map_param method
291 291
 0.1696
292
-    - added new argument format update, delete, select method where option
293
-    - create_query is DEPRECATED! use query option of each method instead.
294
-    - added EXPERIMENTAL insert, update, and select method prefix option
295
-    - fixed small insert, update, delete, select method id option bug
292
+  - added new argument format update, delete, select method where option
293
+  - create_query is DEPRECATED! use query option of each method instead.
294
+  - added EXPERIMENTAL insert, update, and select method prefix option
295
+  - fixed small insert, update, delete, select method id option bug
296 296
 0.1695
297
-    - changed EXPERIMENTAL DBIx::Custom::Result type_rule_off method argument
298
-    - added EXPERIMENTAL DBIx::Custom::Result type_rule_on method
299
-    - changed EXPERIMENTAL DBIx::Custom::Result type_rule1_off method argument
300
-    - added EXPERIMENTAL DBIx::Custom::Result type_rule1_on method
301
-    - changed EXPERIMENTAL DBIx::Custom::Result type_rule2_off method argument
302
-    - added EXPERIMENTAL DBIx::Custom::Result type_rule2_on method
303
-    - changed EXPERIMENTAL DBIx::Custom::Result filter_off method argument
304
-    - added EXPERIMENTAL DBIx::Custom::Result filter_on method
297
+  - changed EXPERIMENTAL DBIx::Custom::Result type_rule_off method argument
298
+  - added EXPERIMENTAL DBIx::Custom::Result type_rule_on method
299
+  - changed EXPERIMENTAL DBIx::Custom::Result type_rule1_off method argument
300
+  - added EXPERIMENTAL DBIx::Custom::Result type_rule1_on method
301
+  - changed EXPERIMENTAL DBIx::Custom::Result type_rule2_off method argument
302
+  - added EXPERIMENTAL DBIx::Custom::Result type_rule2_on method
303
+  - changed EXPERIMENTAL DBIx::Custom::Result filter_off method argument
304
+  - added EXPERIMENTAL DBIx::Custom::Result filter_on method
305 305
 0.1694
306
-    - EXPERIMENTAL type_rule argument format is changed
307
-    - DBIx::Custom::Result type_rule method on setting return self 
308
-    - reserved_word_quote is DEPRECATED! this is renamed to quote
309
-    - DBIx::Custom::Model type attribute is DEPRECATED!
310
-      this is renamed to bind_type.
306
+  - EXPERIMENTAL type_rule argument format is changed
307
+  - DBIx::Custom::Result type_rule method on setting return self 
308
+  - reserved_word_quote is DEPRECATED! this is renamed to quote
309
+  - DBIx::Custom::Model type attribute is DEPRECATED!
310
+    this is renamed to bind_type.
311 311
 0.1693
312
-    - separate DBIx::Custom type_rule from filter
313
-    - DBIx::Custom::Model filter attrribute is DEPRECATED!
314
-    - DBIx::Custom::Model name attribute is DEPRECATED!
315
-    - removed EXPERIMENTAL DBIx::Custom::Model alias_table
316
-    - added DBIx::Custom column method's table option
317
-    - separate DBIx::Custom::Result type_rule from filter again
312
+  - separate DBIx::Custom type_rule from filter
313
+  - DBIx::Custom::Model filter attrribute is DEPRECATED!
314
+  - DBIx::Custom::Model name attribute is DEPRECATED!
315
+  - removed EXPERIMENTAL DBIx::Custom::Model alias_table
316
+  - added DBIx::Custom column method's table option
317
+  - separate DBIx::Custom::Result type_rule from filter again
318 318
 0.1692
319
-    - removed EXPERIMENTAL DBIx::Model result_filter
320
-    - DBIx::Custom::Result filter override type_rule
321
-    - added EXPERIMENTAL DBIx::Custom::Result type_rule
322
-    - added EXPERIMENTAL available_type_name method 
323
-    - EXPERIMENTAL type_rule_off is not passed form execute method 
324
-      to DBIx::Custom::Result object
319
+  - removed EXPERIMENTAL DBIx::Model result_filter
320
+  - DBIx::Custom::Result filter override type_rule
321
+  - added EXPERIMENTAL DBIx::Custom::Result type_rule
322
+  - added EXPERIMENTAL available_type_name method 
323
+  - EXPERIMENTAL type_rule_off is not passed form execute method 
324
+    to DBIx::Custom::Result object
325 325
 0.1691
326
-    - DBIx::Custom::Result end_filter, remove_filter, remove_end_filter is DEPRECATED!
327
-    - apply_filter is DEPRECATED!
328
-    - EXPERIMETAL column method and table_alias think about "-" separator
329
-    - EXPERIMTANL column method think about separator
330
-    - removed EXPERIMENTAL col method.
331
-    - added EXPERIMENTAL separater method
332
-    - added EXPERIMENTAL select prefix option.
333
-    - fixed bug that data_source DEPRECATED warnings pirnt STDERR
334
-    - fixed bug that type_rule from option can't receive filter name
326
+  - DBIx::Custom::Result end_filter, remove_filter, remove_end_filter is DEPRECATED!
327
+  - apply_filter is DEPRECATED!
328
+  - EXPERIMETAL column method and table_alias think about "-" separator
329
+  - EXPERIMTANL column method think about separator
330
+  - removed EXPERIMENTAL col method.
331
+  - added EXPERIMENTAL separater method
332
+  - added EXPERIMENTAL select prefix option.
333
+  - fixed bug that data_source DEPRECATED warnings pirnt STDERR
334
+  - fixed bug that type_rule from option can't receive filter name
335 335
 0.1690
336
-    - use latest Object::Simple features
336
+  - use latest Object::Simple features
337 337
 0.1689
338
-    - added EXPERIMENTAL available_data_type
339
-    - simplified type_rule
340
-    - changed type_rule arguments format
341
-    - added EXPERIMENTAL DBIx::Custom::Model result_filter attribute
342
-    - added EXPERIMETNAL DBIx::Custom::Result filter_off method
343
-    - EXPERIMENTAL type_rule can receive filter name
338
+  - added EXPERIMENTAL available_data_type
339
+  - simplified type_rule
340
+  - changed type_rule arguments format
341
+  - added EXPERIMENTAL DBIx::Custom::Model result_filter attribute
342
+  - added EXPERIMETNAL DBIx::Custom::Result filter_off method
343
+  - EXPERIMENTAL type_rule can receive filter name
344 344
 0.1688
345
-    - fixed bug that model insert, update, delete select can't
346
-      odd number arguments
347
-    - improved type_rule method
345
+  - fixed bug that model insert, update, delete select can't
346
+    odd number arguments
347
+  - improved type_rule method
348 348
 0.1687
349
-    - added EXPERIMENTAL type_rule method
350
-    - added EXPERIMENTAL execute() type_rule_off option
351
-    - execute method can second argument as parameter
349
+  - added EXPERIMENTAL type_rule method
350
+  - added EXPERIMENTAL execute() type_rule_off option
351
+  - execute method can second argument as parameter
352 352
 0.1686
353
-    - select() column option can receive array reference in array.
354
-      This is EXPERIMENTAL
355
-    - select() EXPERIMETNAL column option hash format
356
-      return table.column, not table__column
357
-    - added EXPERIMENTAL col method.
358
-    - set reserved_word_quote automatically from driver name
353
+  - select() column option can receive array reference in array.
354
+    This is EXPERIMENTAL
355
+  - select() EXPERIMETNAL column option hash format
356
+    return table.column, not table__column
357
+  - added EXPERIMENTAL col method.
358
+  - set reserved_word_quote automatically from driver name
359 359
 0.1685
360
-    - insert_at, update_at, delete_at, select_at is DEPRECATED!
361
-      use insert, update, delete, select method and id option.
362
-    - insert, insert_at, update, update_at can receive odd number arguments,
363
-      first one is parameter.
360
+  - insert_at, update_at, delete_at, select_at is DEPRECATED!
361
+    use insert, update, delete, select method and id option.
362
+  - insert, insert_at, update, update_at can receive odd number arguments,
363
+    first one is parameter.
364 364
 0.1684
365
-    - added DBIx::Custom::Result all method, this is alias for fetch_hash_all
366
-    - added DBIx::Custom::Result one method, this is alias for fetch_hash_first
367
-    - DBIx::Custom::Result fetch_hash_first can recieve argument
368
-    - select() column option can receive hash reference. This is EXPERIMENTAL
369
-    - update_param_tag is DEPRECATED! use update_param instead.
370
-    - insert_param_tag is DEPRECATED! use insert_param instead.
371
-    - assing_param_tag is DEPRECATED! use assign_param instead.
372
-    - Tag system such as {? title}, {= title} is DEPRECATED!
373
-      and added paramter system such as :title.
365
+  - added DBIx::Custom::Result all method, this is alias for fetch_hash_all
366
+  - added DBIx::Custom::Result one method, this is alias for fetch_hash_first
367
+  - DBIx::Custom::Result fetch_hash_first can recieve argument
368
+  - select() column option can receive hash reference. This is EXPERIMENTAL
369
+  - update_param_tag is DEPRECATED! use update_param instead.
370
+  - insert_param_tag is DEPRECATED! use insert_param instead.
371
+  - assing_param_tag is DEPRECATED! use assign_param instead.
372
+  - Tag system such as {? title}, {= title} is DEPRECATED!
373
+    and added paramter system such as :title.
374 374
 0.1683
375
-    - data_source is DEPRECATED! It is renamed to dsn
375
+  - data_source is DEPRECATED! It is renamed to dsn
376 376
 0.1682
377
-    - improved debug message
378
-    - fixed merge_param bug
377
+  - improved debug message
378
+  - fixed merge_param bug
379 379
 0.1681
380
-    - added EXPERIMENTAL assign_tag() method
380
+  - added EXPERIMENTAL assign_tag() method
381 381
 0.1680
382
-    - DEPRECATED select() param option, this is renamed to where_param
383
-    - added select(), update(), and delete() where_param option
382
+  - DEPRECATED select() param option, this is renamed to where_param
383
+  - added select(), update(), and delete() where_param option
384 384
 0.1679
385
-    - added EXPERIMENTAL select() wrap option to support Oracle ROWNUM
385
+  - added EXPERIMENTAL select() wrap option to support Oracle ROWNUM
386 386
 0.1678
387
-    - DBIx::Custom::Model filter attribute can receive hash reference
388
-    - DBIx::Custom::Where clause attribute can receive clause without column name
389
-    - improved error messages
387
+  - DBIx::Custom::Model filter attribute can receive hash reference
388
+  - DBIx::Custom::Where clause attribute can receive clause without column name
389
+  - improved error messages
390 390
 0.1677
391
-    - improved table search in column and join clause
392
-    - DEPRECATED table tag. use table option.
391
+  - improved table search in column and join clause
392
+  - DEPRECATED table tag. use table option.
393 393
 0.1676
394
-    - fixed test bug
394
+  - fixed test bug
395 395
 0.1675
396
-    - removed DEPRECATED DBIx::Custom::MySQL and DBIx::Custom::SQLite
397
-      these implementations remine in https://github.com/yuki-kimoto/DBIx-Custom/wiki
398
-      for some users.
399
-    - removed EXPERIMENTAL replace().
400
-    - removed EXPERIMENTAL mark from many methods.
396
+  - removed DEPRECATED DBIx::Custom::MySQL and DBIx::Custom::SQLite
397
+    these implementations remine in https://github.com/yuki-kimoto/DBIx-Custom/wiki
398
+    for some users.
399
+  - removed EXPERIMENTAL replace().
400
+  - removed EXPERIMENTAL mark from many methods.
401 401
 0.1674
402
-    - fixed test bug
402
+  - fixed test bug
403 403
 0.1673
404
-    - fixed dbh() method bug.
404
+  - fixed dbh() method bug.
405 405
 0.1672
406
-    - removed EXPERIMENTAL Prefork server safe implementation, my implementation is very buggy.
407
-    - added EXPERIMETNAL connector() attribute.
408
-    - change retern value to array refrence of EXPERIMENTAL replace()
406
+  - removed EXPERIMENTAL Prefork server safe implementation, my implementation is very buggy.
407
+  - added EXPERIMETNAL connector() attribute.
408
+  - change retern value to array refrence of EXPERIMENTAL replace()
409 409
 0,1671
410
-    - added environment variable DBIX_CUSTOM_DEBUG
410
+  - added environment variable DBIX_CUSTOM_DEBUG
411 411
 0.1670
412
-    - removed EXPERIMETNAL select() column hash option. it's a little complex.
413
-    - added EXPERIMENTAL select() param option.
414
-    - added EXPERIMENTAL replace().
412
+  - removed EXPERIMETNAL select() column hash option. it's a little complex.
413
+  - added EXPERIMENTAL select() param option.
414
+  - added EXPERIMENTAL replace().
415 415
 0.1669
416
-    - renamed update_param to update_param_tag, update_param is DEPRECATED!
417
-    - renamed insert_param to insert_param_tag, insert_param is DEPRECATED!
416
+  - renamed update_param to update_param_tag, update_param is DEPRECATED!
417
+  - renamed insert_param to insert_param_tag, insert_param is DEPRECATED!
418 418
 0.1668
419
-    - added EXPERIMENTAL update_param no_set option.
420
-    - added EXPERIMENTAL reserved_word_quote attribute.
419
+  - added EXPERIMENTAL update_param no_set option.
420
+  - added EXPERIMENTAL reserved_word_quote attribute.
421 421
 0.1666
422
-    - removed from cache() and cache_method() document for a while and cache() value
423
-      become 0 because I find something bug.
424
-    - create_model() return model.
425
-    - added document of hash filter
426
-    - adeed EXPERIMENTAL DBIx::Custom::Model method()
422
+  - removed from cache() and cache_method() document for a while and cache() value
423
+    become 0 because I find something bug.
424
+  - create_model() return model.
425
+  - added document of hash filter
426
+  - adeed EXPERIMENTAL DBIx::Custom::Model method()
427 427
 0.1665
428
-    - removed EXPERIMETNAL flag from insert_at(), update_at(), delete_at(), select_at(), insert_param(), not_exists(), select()'s query option, update_param(), where, table tag, each column, safety_character, DBIx::Where, where().
429
-    - added EXPERIMETNAL create_model()
428
+  - removed EXPERIMETNAL flag from insert_at(), update_at(), delete_at(), select_at(), insert_param(), not_exists(), select()'s query option, update_param(), where, table tag, each column, safety_character, DBIx::Where, where().
429
+  - added EXPERIMETNAL create_model()
430 430
 0.1664
431
-    - where can recieve array refrence, which contains where cluase and paramter.
431
+  - where can recieve array refrence, which contains where cluase and paramter.
432 432
 0.1663
433
-    - added EXPERIMENTAL type() attribute to DBIx::Custom::Model
434
-    - added EXPERIMENTAL bind_param_option can set bind_param option
435
-      to insert(), update(), delete(), select(), insert_at(),
436
-      update_at(), delete_at(), select_at(), delete_all(), update_all()
433
+  - added EXPERIMENTAL type() attribute to DBIx::Custom::Model
434
+  - added EXPERIMENTAL bind_param_option can set bind_param option
435
+    to insert(), update(), delete(), select(), insert_at(),
436
+    update_at(), delete_at(), select_at(), delete_all(), update_all()
437 437
 0.1662
438
-    - removed EXPERIMENTAL DBIx::Custom::Model column_clause
439
-    - added EXPERIMENTAL column()
440
-    - added EXPERIMENTAL mycolumn()
438
+  - removed EXPERIMENTAL DBIx::Custom::Model column_clause
439
+  - added EXPERIMENTAL column()
440
+  - added EXPERIMENTAL mycolumn()
441 441
 0.1661
442
-    - added EXPERIMENTAL DBIx::Custom::Model table_alias attribute
443
-    - added EXPERIMENTAL DBIx::Custom::Model mycolumn()
444
-    - added EXPERIMENTAL DBIx::Custom::Model column()
445
-    - fixed autoloading bug
446
-    - added EXPERIMETNAL select() prepend table option
447
-    - added EXPERIMETNAL select() column table option
448
-    - added EXPERIMETNAL select() column all option
449
-    - removed EXPERIMETNAL select() all_column option
450
-    - removed EXPERIMENTAL view()
442
+  - added EXPERIMENTAL DBIx::Custom::Model table_alias attribute
443
+  - added EXPERIMENTAL DBIx::Custom::Model mycolumn()
444
+  - added EXPERIMENTAL DBIx::Custom::Model column()
445
+  - fixed autoloading bug
446
+  - added EXPERIMETNAL select() prepend table option
447
+  - added EXPERIMETNAL select() column table option
448
+  - added EXPERIMETNAL select() column all option
449
+  - removed EXPERIMETNAL select() all_column option
450
+  - removed EXPERIMENTAL view()
451 451
 0.1660
452
-    - added EXPERIMENTAL DBIx::Custom::Model view()
453
-    - added EXPERIMENTAL view()
454
-    - DBIx::Custom::Model inherit DBIx::Custom
455
-    - removed EXPERIMETNAL DBIx::Custom::Model method()
456
-    - added table choice feature to select() EXPERIMENTAL all_column option 
457
-    - removed EXPERIMENTAL DBIx::Custom::Model column attribute for side effect
452
+  - added EXPERIMENTAL DBIx::Custom::Model view()
453
+  - added EXPERIMENTAL view()
454
+  - DBIx::Custom::Model inherit DBIx::Custom
455
+  - removed EXPERIMETNAL DBIx::Custom::Model method()
456
+  - added table choice feature to select() EXPERIMENTAL all_column option 
457
+  - removed EXPERIMENTAL DBIx::Custom::Model column attribute for side effect
458 458
 0.1659
459
-    - EXPERIMETAL fork safety implementaion.
460
-    - removed EXPERIMENTAL selection
461
-    - added select() all_column option
459
+  - EXPERIMETAL fork safety implementaion.
460
+  - removed EXPERIMENTAL selection
461
+  - added select() all_column option
462 462
 0.1658
463
-    - added EXPERIMENTAL DBIx::Custom::Model column() prefix option.
464
-    - fixed select_at join column invalid bug
465
-    - added DBIx::Custom::Model column() attribute 
463
+  - added EXPERIMENTAL DBIx::Custom::Model column() prefix option.
464
+  - fixed select_at join column invalid bug
465
+  - added DBIx::Custom::Model column() attribute 
466 466
 0.1657
467
-    - remaned EXPERIMENTAL safty_charcter to safty_name
468
-    - safty_charcter is changed, set only one character regex.
467
+  - remaned EXPERIMENTAL safty_charcter to safty_name
468
+  - safty_charcter is changed, set only one character regex.
469 469
 0.1656
470
-    - fixed some select() join opition bug
470
+  - fixed some select() join opition bug
471 471
 0.1655
472
-    - added EXPERIMENTAL DBIx::Custom::Model join attribute
473
-    - added EXPERIMENTAL select() join option
474
-    - deprecated select() relation option
475
-    - added EXPERIMENTAL update_param and insert_param
476
-    - remove EXPERIMENTAL DBIx::Custom::Model relation
472
+  - added EXPERIMENTAL DBIx::Custom::Model join attribute
473
+  - added EXPERIMENTAL select() join option
474
+  - deprecated select() relation option
475
+  - added EXPERIMENTAL update_param and insert_param
476
+  - remove EXPERIMENTAL DBIx::Custom::Model relation
477 477
 0.1654
478
-    - selection can contain where clause.
478
+  - selection can contain where clause.
479 479
 0.1653
480
-    - added EXPERIMENTAL DBIx::Custom::Result remove_filter()
481
-    - added EXPERIMENTAL DBIx::Custom::Result remove_end_filter()
482
-    - added EXPERIMENTAL DBIx::Custom::Model insert_at()
483
-    - added EXPERIMENTAL insert_at()
484
-    - improved error message
480
+  - added EXPERIMENTAL DBIx::Custom::Result remove_filter()
481
+  - added EXPERIMENTAL DBIx::Custom::Result remove_end_filter()
482
+  - added EXPERIMENTAL DBIx::Custom::Model insert_at()
483
+  - added EXPERIMENTAL insert_at()
484
+  - improved error message
485 485
 0.1652
486
-    - all filter can receive array reference and receiving hash reference is DEPRECATED!
486
+  - all filter can receive array reference and receiving hash reference is DEPRECATED!
487 487
 0.1651
488
-    - add EXPERIMENTAL DBIx::Custom::Model filter attribute.
488
+  - add EXPERIMENTAL DBIx::Custom::Model filter attribute.
489 489
 0.1650
490
-    - add EXPERIMENTAL DBIx::Custom::Model name() attribute
490
+  - add EXPERIMENTAL DBIx::Custom::Model name() attribute
491 491
 0.1649
492
-    - add EXPERIMENTAL DBIx::Custom::Model column_clause() method.
493
-    - select method column option can receive string.
494
-    - DBIx::Custom::Model select() and select_at() think about relation attirbute
492
+  - add EXPERIMENTAL DBIx::Custom::Model column_clause() method.
493
+  - select method column option can receive string.
494
+  - DBIx::Custom::Model select() and select_at() think about relation attirbute
495 495
 0.1648
496
-    - add EXPERIMENTAL DBIx::Custom::Model relation() attribute
497
-    - add EXPERIMENTAL update_at(), delete_at(), select_at()
498
-    - add EXPERIMENTAL setup_model()
499
-    - add EXPERIMENTAL DBIx::Custom::Model columns attirbute
500
-    - add EXPERIMENTAL DBIx::Custom::Model foreign_key() attribute 
501
-    - add EXPERIMENTAL models() attribute
496
+  - add EXPERIMENTAL DBIx::Custom::Model relation() attribute
497
+  - add EXPERIMENTAL update_at(), delete_at(), select_at()
498
+  - add EXPERIMENTAL setup_model()
499
+  - add EXPERIMENTAL DBIx::Custom::Model columns attirbute
500
+  - add EXPERIMENTAL DBIx::Custom::Model foreign_key() attribute 
501
+  - add EXPERIMENTAL models() attribute
502 502
 0.1647
503
-    - add default_dbi_option()
503
+  - add default_dbi_option()
504 504
 0.1646
505
-    - add feture. all model class in namespace is included by include_model
506
-    - rename EXPERIMENTAL include_table to include_model
507
-    - rename EXPERIMENTAL table to model
508
-    - rename EXPERIMENTAL DBIx::Custom::Table to DBIx::Custom::Model
509
-    - remame EXPERIMENTAL DBIx::Custom::Table::name() to DBIx::Custom::Model::table();
505
+  - add feture. all model class in namespace is included by include_model
506
+  - rename EXPERIMENTAL include_table to include_model
507
+  - rename EXPERIMENTAL table to model
508
+  - rename EXPERIMENTAL DBIx::Custom::Table to DBIx::Custom::Model
509
+  - remame EXPERIMENTAL DBIx::Custom::Table::name() to DBIx::Custom::Model::table();
510 510
 0.1645
511
-    - removed EXPERIMENTAL base_table() for class expandability.
512
-    - EXPERIMENTAL table() can't set table object any more.
513
-    - added EXPERIMENTAL include_table().
511
+  - removed EXPERIMENTAL base_table() for class expandability.
512
+  - EXPERIMENTAL table() can't set table object any more.
513
+  - added EXPERIMENTAL include_table().
514 514
 0.1644
515
-    - update pod
515
+  - update pod
516 516
 0.1643
517
-    - add EXPERIMENTAL selection option to select()
518
-    - add EXPERIMENTAL table tag
519
-    - fix bug : filter can't overwirite undef value.
520
-    - add EXPERIMENTAL feature to apply_filter(). you can apply end filter.
521
-    - add EXPERIMENTAL feature to apply_filter(). TABLE__COLUMN is filterded now.
517
+  - add EXPERIMENTAL selection option to select()
518
+  - add EXPERIMENTAL table tag
519
+  - fix bug : filter can't overwirite undef value.
520
+  - add EXPERIMENTAL feature to apply_filter(). you can apply end filter.
521
+  - add EXPERIMENTAL feature to apply_filter(). TABLE__COLUMN is filterded now.
522 522
 0.1642
523
-    - removed EXPERIMENTAL DBIx::Custom::Table base() method
524
-    - table created by tabled method can call base_$method correponding to base_table's one
523
+  - removed EXPERIMENTAL DBIx::Custom::Table base() method
524
+  - table created by tabled method can call base_$method correponding to base_table's one
525 525
 0.1641
526
-    - select() where can't receive array reference to prevend SQL injection easily(not backward compatible. sorry. use where() instead)
527
-    - added EXPERIMENTAL safety_column_name attribute
528
-    - fix SQL injection security hole about column name
526
+  - select() where can't receive array reference to prevend SQL injection easily(not backward compatible. sorry. use where() instead)
527
+  - added EXPERIMENTAL safety_column_name attribute
528
+  - fix SQL injection security hole about column name
529 529
 0.1640
530
-    - autoload DBI method
531
-    - removed EXPERIMENTAL expand
530
+  - autoload DBI method
531
+  - removed EXPERIMENTAL expand
532 532
 0.1639
533
-    - improved delete() and update() where option. you can use DBIx::Custom::Where object
534
-    - added EXPERIMENTAL not_exists()
533
+  - improved delete() and update() where option. you can use DBIx::Custom::Where object
534
+  - added EXPERIMENTAL not_exists()
535 535
 0.1638
536
-    - table object call dbi object method if not found method.
537
-    - added EXPERIMENTAL base_table attribute and removed EXPERIMENTAL table_class attribute
538
-    - renamed helper to method.
539
-    - added EXPERIMENTAL DBIx::Custom::Result::stash()
540
-    - renamed EXPERIMENTAL DBIx::Custom::Table helper to method
536
+  - table object call dbi object method if not found method.
537
+  - added EXPERIMENTAL base_table attribute and removed EXPERIMENTAL table_class attribute
538
+  - renamed helper to method.
539
+  - added EXPERIMENTAL DBIx::Custom::Result::stash()
540
+  - renamed EXPERIMENTAL DBIx::Custom::Table helper to method
541 541
 0.1637
542
-    - renamed dbi_options to dbi_option. dbi_options is available, but deprecated.
543
-    - renamed DBIx::Custom::TagProcessor to DBIx::Custom::Tag, and function names is cleanuped.
544
-    - renamed register_tag_processor to register_tag. register_tag_processor is available, but deprecated.
545
-    - renamed tag_processors to tags. tag_prosessors is available, but deprecated.
546
-    - improved error message
547
-    - build all clause if param is undefined.
548
-    - each_column callback receive self as first argument.
549
-    - removed EXPERIMENTAL txn_scope
542
+  - renamed dbi_options to dbi_option. dbi_options is available, but deprecated.
543
+  - renamed DBIx::Custom::TagProcessor to DBIx::Custom::Tag, and function names is cleanuped.
544
+  - renamed register_tag_processor to register_tag. register_tag_processor is available, but deprecated.
545
+  - renamed tag_processors to tags. tag_prosessors is available, but deprecated.
546
+  - improved error message
547
+  - build all clause if param is undefined.
548
+  - each_column callback receive self as first argument.
549
+  - removed EXPERIMENTAL txn_scope
550 550
 0.1636
551
-    - added tests and cleanup
551
+  - added tests and cleanup
552 552
 0.1635
553
-    - renamed iterate_all_columns to each_column
553
+  - renamed iterate_all_columns to each_column
554 554
 0.1634
555
-    - became more useful where method
556
-    - changed DBIx::Custom::Where greatly
555
+  - became more useful where method
556
+  - changed DBIx::Custom::Where greatly
557 557
 0.1633
558
-    - fixed test
558
+  - fixed test
559 559
 0.1632
560
-    - added EXPERIMENTAL where method
561
-    - added EXPERIMENTAL DBIx::Custom::Where.
562
-    - removed DBIx::Custom::Or
560
+  - added EXPERIMENTAL where method
561
+  - added EXPERIMENTAL DBIx::Custom::Where.
562
+  - removed DBIx::Custom::Or
563 563
 0.1631
564
-    - added EXPERIMENTAL DBIx::Custom::Result end_filter method
565
-    - EXPERIMENTAL extended select method's where option
566
-    - fix select method empty where failed bug
567
-    - added EXPERIMENTAL suger method query option
568
-    - added EXPERIMENTAL or method
564
+  - added EXPERIMENTAL DBIx::Custom::Result end_filter method
565
+  - EXPERIMENTAL extended select method's where option
566
+  - fix select method empty where failed bug
567
+  - added EXPERIMENTAL suger method query option
568
+  - added EXPERIMENTAL or method
569 569
 0.1630
570
-    - fix test bug
570
+  - fix test bug
571 571
 0.1629
572
-    - renamed auto_filter to apply_filter
573
-    - changed apply_filter method arguments
574
-    - deprecated cache_method
572
+  - renamed auto_filter to apply_filter
573
+  - changed apply_filter method arguments
574
+  - deprecated cache_method
575 575
 0.1628
576
-    - remove DBIx::Custom::Model
577
-    - move table method and table_class attribute to DBIx::Custom
578
-    - added examples
579
-    - fixed connect method bug
576
+  - remove DBIx::Custom::Model
577
+  - move table method and table_class attribute to DBIx::Custom
578
+  - added examples
579
+  - fixed connect method bug
580 580
 0.1627
581
-    - added insert, update, update_all, delete, delete_all, select method to DBIx::Custom::Table
582
-    - added EXPERIMENTAL txn_scope
581
+  - added insert, update, update_all, delete, delete_all, select method to DBIx::Custom::Table
582
+  - added EXPERIMENTAL txn_scope
583 583
 0.1626
584
-    - simplified DBIx::Custom::Model and DBIx::Custom::Table
584
+  - simplified DBIx::Custom::Model and DBIx::Custom::Table
585 585
 0.1625
586
-    - added EXPERIMENTAL DBIx::Custom::Model and DBIx::Custom::Table
586
+  - added EXPERIMENTAL DBIx::Custom::Model and DBIx::Custom::Table
587 587
 0.1624
588
-    - added EXPERIMENTAL iterate_all_columns method.
588
+  - added EXPERIMENTAL iterate_all_columns method.
589 589
 0.1623
590
-    - added EXPERIMENTAL auto_filter method
591
-    - deprecated default_bind_filter and default_fetch_filter because these are global effect.
592
-    - changed defautl_bind_filter and default_fetch_filter attributes to methods.
593
-    - changed DBIx::Custom::Result default_filter attribute to method
594
-    - changed DBIx::Custom::Result filter attribute to method.
595
-    - filter_check is always done for usability
590
+  - added EXPERIMENTAL auto_filter method
591
+  - deprecated default_bind_filter and default_fetch_filter because these are global effect.
592
+  - changed defautl_bind_filter and default_fetch_filter attributes to methods.
593
+  - changed DBIx::Custom::Result default_filter attribute to method
594
+  - changed DBIx::Custom::Result filter attribute to method.
595
+  - filter_check is always done for usability
596 596
 0.1622
597
-    - deprecated DBIx::Custom::SQLite and DBIx::Custom::MySQL
598
-    - added dbi_options attribute
599
-    - checked attributes passed to connect method
597
+  - deprecated DBIx::Custom::SQLite and DBIx::Custom::MySQL
598
+  - added dbi_options attribute
599
+  - checked attributes passed to connect method
600 600
 0.1621
601
-    - cleanup (removed undocumented features)
601
+  - cleanup (removed undocumented features)
602 602
 0.1620
603
-    - updated document
603
+  - updated document
604 604
 0.1619
605
-    - updated document
606
-    - added EXPERIMENTAL expand method
605
+  - updated document
606
+  - added EXPERIMENTAL expand method
607 607
 0.1618
608
-    - added helper method
609
-    - added begin_work, commit, and rollback method
608
+  - added helper method
609
+  - added begin_work, commit, and rollback method
610 610
 0.1617
611
-    - L<DBIx::Custom> is now stable. APIs keep backword compatible in the feature.
611
+  - L<DBIx::Custom> is now stable. APIs keep backword compatible in the feature.
612 612
 0.1616
613
-    - removed EXPERIMENTAL register_method(), and methods attribute, because it is too magical
613
+  - removed EXPERIMENTAL register_method(), and methods attribute, because it is too magical
614 614
 0.1615
615
-    - fixed DBIx::Custom::QueryBuilder build_query() bug
616
-    - required Perl 5.008001 to use @CARP_NOT 
615
+  - fixed DBIx::Custom::QueryBuilder build_query() bug
616
+  - required Perl 5.008001 to use @CARP_NOT 
617 617
 0.1614
618
-    - removed DBIx::Custom::Query start_tag and end tag attributes
619
-    - enable escaping '{' and '}' in the source of SQL
620
-    - fixed Carp Carp trust relationship
618
+  - removed DBIx::Custom::Query start_tag and end tag attributes
619
+  - enable escaping '{' and '}' in the source of SQL
620
+  - fixed Carp Carp trust relationship
621 621
 0.1613
622
-    - added EXPERIMENTAL register_method() method
623
-    - added EXPERIMENTAL methods attribute
622
+  - added EXPERIMENTAL register_method() method
623
+  - added EXPERIMENTAL methods attribute
624 624
 0.1612
625
-    - added tests
626
-    - updated document
627
-    - removed DBIx::Custom::SQLite last_insert_rawid() mehtod(not backword compatible)
628
-    - removed DBIx::Custom::MySQL last_insert_id() method(not backword compatible)
625
+  - added tests
626
+  - updated document
627
+  - removed DBIx::Custom::SQLite last_insert_rawid() mehtod(not backword compatible)
628
+  - removed DBIx::Custom::MySQL last_insert_id() method(not backword compatible)
629 629
 0.1611
630
-    - renamed update tag to update_param
631
-    - renamed insert tag to insert_param
632
-    - renamed sql_builder to query_builder
630
+  - renamed update tag to update_param
631
+  - renamed insert tag to insert_param
632
+  - renamed sql_builder to query_builder
633 633
 0.1610
634
-    - added filter_check attribute.
634
+  - added filter_check attribute.
635 635
 0.1609
636
-    - updated document.
636
+  - updated document.
637 637
 0.1608
638
-    - update document
639
-    - renamed DBIx::Custom::QueryBuilder::TagProcessors functions(not backword compatible)
638
+  - update document
639
+  - renamed DBIx::Custom::QueryBuilder::TagProcessors functions(not backword compatible)
640 640
 0.1607
641
-    - where argument of select() method can specify array(string, parameters)
642
-    - renamed build_query() to create_query()(not backword compatible)
641
+  - where argument of select() method can specify array(string, parameters)
642
+  - renamed build_query() to create_query()(not backword compatible)
643 643
 0.1606
644
-    - fix testing bug
644
+  - fix testing bug
645 645
 0.1605
646
-    - remove DBIx::Custom::QueryBuilder::tag_syntax()  (not backword compatible)
647
-    - renamed DBIx::Custom::TagProcessor to DBIx::Custom::TagProcessors (not backword compatible)
648
-    - changed arguments of tag processor(not backword compatible)
649
-    - renamed DBIx::Custom::QueryBuilder::TagProcessors functions(not backword compatible)
646
+  - remove DBIx::Custom::QueryBuilder::tag_syntax()  (not backword compatible)
647
+  - renamed DBIx::Custom::TagProcessor to DBIx::Custom::TagProcessors (not backword compatible)
648
+  - changed arguments of tag processor(not backword compatible)
649
+  - renamed DBIx::Custom::QueryBuilder::TagProcessors functions(not backword compatible)
650 650
 0.1604
651
-    - changed argument of tag processor(not backword compatible)
652
-    - renamed default_query_filter to default_bind_filter(not backword compatible)
653
-    - renamed DBIx::Custom::SQLTemplate to DBIx::Custom::SQLBuilder(not backword compatible)
654
-    - renamed create_query to build_query(not backword compatible)
655
-    - renamed sql_template to sql_builder(not backword compatible)
656
-    - removed DESTROY method(not backword compatible)
657
-    - removed disconnect method(not backword compatible)
658
-    - fixed DBIx::Custom::MySQL connect_memory
651
+  - changed argument of tag processor(not backword compatible)
652
+  - renamed default_query_filter to default_bind_filter(not backword compatible)
653
+  - renamed DBIx::Custom::SQLTemplate to DBIx::Custom::SQLBuilder(not backword compatible)
654
+  - renamed create_query to build_query(not backword compatible)
655
+  - renamed sql_template to sql_builder(not backword compatible)
656
+  - removed DESTROY method(not backword compatible)
657
+  - removed disconnect method(not backword compatible)
658
+  - fixed DBIx::Custom::MySQL connect_memory
659 659
 0.1603
660
-    - removed DBIx::Custom commit method (not backword compatible)
661
-    - removed DBIx::Custom rollback method (not backword compatible)
662
-    - removed DBIx::Custom auto_commit method (not backword compatible)
660
+  - removed DBIx::Custom commit method (not backword compatible)
661
+  - removed DBIx::Custom rollback method (not backword compatible)
662
+  - removed DBIx::Custom auto_commit method (not backword compatible)
663 663
 0.1602
664
-    - added cache_method attribute
664
+  - added cache_method attribute
665 665
 0.1601
666
-    - added cache attribute
667
-    - select, insert, update, update_all, delete, delete_all, execute only receive hash argument(not backword compatible)
666
+  - added cache attribute
667
+  - select, insert, update, update_all, delete, delete_all, execute only receive hash argument(not backword compatible)
668 668
 0.1503
669
-    - removed reconnect method
670
-    - removed connected method
671
-    - removed reconnect_memroy method
672
-    - renamed fetch_single to fetch_first
673
-    - renamed fetch_hash_single to fetch_hash_first
674
-    - updated document
669
+  - removed reconnect method
670
+  - removed connected method
671
+  - removed reconnect_memroy method
672
+  - renamed fetch_single to fetch_first
673
+  - renamed fetch_hash_single to fetch_hash_first
674
+  - updated document
675 675
 0.1502
676
-    - added commit method
677
-    - added rollback method
678
-    - changed select argument, added relation option
679
-    - moved host attribute to DBIx::Custom::MySQL
680
-    - moved port attribute to DBIx::Custom::MySQL
681
-    - moved database attribute to DBIx::Custom::MySQL and DBIx::Custom::SQLite
676
+  - added commit method
677
+  - added rollback method
678
+  - changed select argument, added relation option
679
+  - moved host attribute to DBIx::Custom::MySQL
680
+  - moved port attribute to DBIx::Custom::MySQL
681
+  - moved database attribute to DBIx::Custom::MySQL and DBIx::Custom::SQLite
682 682
 0.1501
683
-    - removed register_format()
684
-    - removed formats()
685
-    - removed run_transaction()
686
-    - removed create_table()
687
-    - removed drop_table()
688
-    - changed select() arguments
689
-    - changed insert() arguments
690
-    - changed update() arguments
691
-    - changed update_all() arguments
692
-    - changed delete() arguments
693
-    - changed delete_all() arguments
694
-    - changed execute() arguments
683
+  - removed register_format()
684
+  - removed formats()
685
+  - removed run_transaction()
686
+  - removed create_table()
687
+  - removed drop_table()
688
+  - changed select() arguments
689
+  - changed insert() arguments
690
+  - changed update() arguments
691
+  - changed update_all() arguments
692
+  - changed delete() arguments
693
+  - changed delete_all() arguments
694
+  - changed execute() arguments
695 695
 0.1402
696
-    - remove finish(), error()
697
-    - can receive code ref to filter()
698
-    - renamed resist to register
696
+  - remove finish(), error()
697
+  - can receive code ref to filter()
698
+  - renamed resist to register
699 699
 0.1401
700
-    - renamed fetch_rows to fetch_multi
701
-    - renamed fetch_hash_rows to fetch_hash_multi
700
+  - renamed fetch_rows to fetch_multi
701
+  - renamed fetch_hash_rows to fetch_hash_multi
702 702
 0.1301
703
-    - Changed many(not backword compatible)
703
+  - Changed many(not backword compatible)
704 704
 0.1201
705
-    - Changed many(not backword compatible)
705
+  - Changed many(not backword compatible)
706 706
 0.1101
707
-    - rename DBIx::Custom::SQLite last_insert_id to last_insert_rowid
707
+  - rename DBIx::Custom::SQLite last_insert_id to last_insert_rowid
708 708
 0.1001
709
-    - remove run_transaction().
710
-    - add transaction() and DBIx::Custom::Transaction
711
-    - rename fetch_first to fetch_single
712
-    - rename fetch_hash_first to fetch_hash_single
709
+  - remove run_transaction().
710
+  - add transaction() and DBIx::Custom::Transaction
711
+  - rename fetch_first to fetch_single
712
+  - rename fetch_hash_first to fetch_hash_single
713 713
 0.0906
714
-    - fix some bug
714
+  - fix some bug
715 715
 0.0905
716
-    - catch up with Object::Simple update
716
+  - catch up with Object::Simple update
717 717
 0.0904
718
-    - cleanup
718
+  - cleanup
719 719
 0.0903
720
-    - catch up with Object::Simple update
720
+  - catch up with Object::Simple update
721 721
 0.0902
722
-    - cleanup
722
+  - cleanup
723 723
 0.0901
724
-    - DBIx::Basic filter 'encode_utf8' utf8::upgrade process is deleted
724
+  - DBIx::Basic filter 'encode_utf8' utf8::upgrade process is deleted
725 725
 0.0801
726
-    - add 'create_table', 'drop_table' methods
726
+  - add 'create_table', 'drop_table' methods
727 727
 0.0701
728
-    - rename sql_template to sql_tmpl (not backword compatible)
729
-    - rename dbi_options to options (not backword compatible)
728
+  - rename sql_template to sql_tmpl (not backword compatible)
729
+  - rename dbi_options to options (not backword compatible)
730 730
 0.0605
731
-    - fix encode_utf8 filter
731
+  - fix encode_utf8 filter
732 732
 0.0604
733
-    - fix timeformat tests
733
+  - fix timeformat tests
734 734
 0.0603
735
-    - fix cache system bug
735
+  - fix cache system bug
736 736
 0.0602
737
-    - update document
737
+  - update document
738 738
 0.0601
739
-    - bind_filter argument is changed to ($value, $key, $dbi, $infos) (not backword compatible)
740
-    - fetch_filter argument is changed to ($value, $key, $dbi, $infos) (not backword compatible)
741
-    - run_transaction argument is changed to ($dbi)
739
+  - bind_filter argument is changed to ($value, $key, $dbi, $infos) (not backword compatible)
740
+  - fetch_filter argument is changed to ($value, $key, $dbi, $infos) (not backword compatible)
741
+  - run_transaction argument is changed to ($dbi)
742 742
 0.0502
743
-    - update document
743
+  - update document
744 744
 0.0501
745
-    - packaging DBIx::Custom::Result DBIx::Custom::Query DBIx::Custom::MySQL DBIx::Custom::SQLite DBIx::Custom::SQL::Template 
745
+  - packaging DBIx::Custom::Result DBIx::Custom::Query DBIx::Custom::MySQL DBIx::Custom::SQLite DBIx::Custom::SQL::Template 
746 746
 0.0401
747
-    - catch up with DBIx::Custom::Result version up
747
+  - catch up with DBIx::Custom::Result version up
748 748
 0.0301
749
-    - exchange filter argument 'key', 'value' (not backword compatible)
749
+  - exchange filter argument 'key', 'value' (not backword compatible)
750 750
 0.0201
751
-    - rename tranzaction to transaction
752
-    - add filter_off
751
+  - rename tranzaction to transaction
752
+  - add filter_off
753 753
 0.0101
754
-    - First release
754
+  - First release
+2340 -2370
lib/DBIx/Custom.pm
... ...
@@ -21,235 +21,229 @@ use Scalar::Util qw/weaken/;
21 21
 
22 22
 
23 23
 has [qw/connector dsn password quote user exclude_table user_table_info
24
-        user_column_info safety_character/],
25
-    cache => 0,
26
-    cache_method => sub {
27
-        sub {
28
-            my $self = shift;
29
-            
30
-            $self->{_cached} ||= {};
31
-            
32
-            if (@_ > 1) {
33
-                $self->{_cached}{$_[0]} = $_[1];
34
-            }
35
-            else {
36
-                return $self->{_cached}{$_[0]};
37
-            }
38
-        }
39
-    },
40
-    option => sub { {} },
41
-    default_option => sub {
42
-        {
43
-            RaiseError => 1,
44
-            PrintError => 0,
45
-            AutoCommit => 1
46
-        }
47
-    },
48
-    filters => sub {
49
-        {
50
-            encode_utf8 => sub { encode_utf8($_[0]) },
51
-            decode_utf8 => sub { decode_utf8($_[0]) }
52
-        }
53
-    },
54
-    last_sql => '',
55
-    models => sub { {} },
56
-    now => sub {
57
-        sub {
58
-            my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
59
-            $mon++;
60
-            $year += 1900;
61
-            my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
62
-              $year, $mon, $mday, $hour, $min, $sec);
63
-            return $now;
64
-        }
65
-    },
66
-    query_builder => sub {
67
-        my $self = shift;
68
-        my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
69
-        weaken $builder->{dbi};
70
-        return $builder;
71
-    },
72
-    result_class  => 'DBIx::Custom::Result',
73
-    separator => '.',
74
-    stash => sub { {} };
24
+     user_column_info safety_character/],
25
+  cache => 0,
26
+  cache_method => sub {
27
+    sub {
28
+      my $self = shift;
29
+      $self->{_cached} ||= {};
30
+      if (@_ > 1) { $self->{_cached}{$_[0]} = $_[1] }
31
+      else { return $self->{_cached}{$_[0]} }
32
+    }
33
+  },
34
+  option => sub { {} },
35
+  default_option => sub {
36
+    {
37
+      RaiseError => 1,
38
+      PrintError => 0,
39
+      AutoCommit => 1
40
+    }
41
+  },
42
+  filters => sub {
43
+    {
44
+      encode_utf8 => sub { encode_utf8($_[0]) },
45
+      decode_utf8 => sub { decode_utf8($_[0]) }
46
+    }
47
+  },
48
+  last_sql => '',
49
+  models => sub { {} },
50
+  now => sub {
51
+    sub {
52
+      my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
53
+      $mon++;
54
+      $year += 1900;
55
+      my $now = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
56
+        $year, $mon, $mday, $hour, $min, $sec);
57
+      return $now;
58
+    }
59
+  },
60
+  query_builder => sub {
61
+    my $self = shift;
62
+    my $builder = DBIx::Custom::QueryBuilder->new(dbi => $self);
63
+    weaken $builder->{dbi};
64
+    return $builder;
65
+  },
66
+  result_class  => 'DBIx::Custom::Result',
67
+  separator => '.',
68
+  stash => sub { {} };
75 69
 
76 70
 sub available_datatype {
77
-    my $self = shift;
78
-    
79
-    my $data_types = '';
80
-    for my $i (-1000 .. 1000) {
81
-         my $type_info = $self->dbh->type_info($i);
82
-         my $data_type = $type_info->{DATA_TYPE};
83
-         my $type_name = $type_info->{TYPE_NAME};
84
-         $data_types .= "$data_type ($type_name)\n"
85
-           if defined $data_type;
86
-    }
87
-    return "Data Type maybe equal to Type Name" unless $data_types;
88
-    $data_types = "Data Type (Type name)\n" . $data_types;
89
-    return $data_types;
71
+  my $self = shift;
72
+  
73
+  my $data_types = '';
74
+  for my $i (-1000 .. 1000) {
75
+     my $type_info = $self->dbh->type_info($i);
76
+     my $data_type = $type_info->{DATA_TYPE};
77
+     my $type_name = $type_info->{TYPE_NAME};
78
+     $data_types .= "$data_type ($type_name)\n"
79
+       if defined $data_type;
80
+  }
81
+  return "Data Type maybe equal to Type Name" unless $data_types;
82
+  $data_types = "Data Type (Type name)\n" . $data_types;
83
+  return $data_types;
90 84
 }
91 85
 
92 86
 sub available_typename {
93
-    my $self = shift;
94
-    
95
-    # Type Names
96
-    my $type_names = {};
97
-    $self->each_column(sub {
98
-        my ($self, $table, $column, $column_info) = @_;
99
-        $type_names->{$column_info->{TYPE_NAME}} = 1
100
-          if $column_info->{TYPE_NAME};
101
-    });
102
-    my @output = sort keys %$type_names;
103
-    unshift @output, "Type Name";
104
-    return join "\n", @output;
87
+  my $self = shift;
88
+  
89
+  # Type Names
90
+  my $type_names = {};
91
+  $self->each_column(sub {
92
+    my ($self, $table, $column, $column_info) = @_;
93
+    $type_names->{$column_info->{TYPE_NAME}} = 1
94
+      if $column_info->{TYPE_NAME};
95
+  });
96
+  my @output = sort keys %$type_names;
97
+  unshift @output, "Type Name";
98
+  return join "\n", @output;
105 99
 }
106 100
 
107 101
 our $AUTOLOAD;
108 102
 sub AUTOLOAD {
109
-    my $self = shift;
103
+  my $self = shift;
110 104
 
111
-    # Method name
112
-    my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
105
+  # Method name
106
+  my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
113 107
 
114
-    # Call method
115
-    $self->{_methods} ||= {};
116
-    if (my $method = $self->{_methods}->{$mname}) {
117
-        return $self->$method(@_)
118
-    }
119
-    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
120
-        $self->dbh->$dbh_method(@_);
121
-    }
122
-    else {
123
-        croak qq{Can't locate object method "$mname" via "$package" }
124
-            . _subname;
125
-    }
108
+  # Call method
109
+  $self->{_methods} ||= {};
110
+  if (my $method = $self->{_methods}->{$mname}) {
111
+    return $self->$method(@_)
112
+  }
113
+  elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
114
+    $self->dbh->$dbh_method(@_);
115
+  }
116
+  else {
117
+    croak qq{Can't locate object method "$mname" via "$package" }
118
+      . _subname;
119
+  }
126 120
 }
127 121
 
128 122
 sub assign_clause {
129
-    my ($self, $param, $opts) = @_;
130
-    
131
-    my $wrap = $opts->{wrap} || {};
132
-    my ($q, $p) = split //, $self->q('');
133
-    
134
-    # Assign clause (performance is important)
135
-    join(
136
-      ', ',
137
-      map {
138
-          ref $param->{$_} eq 'SCALAR' ? "$q$_$p = " . ${$param->{$_}}
139
-          : $wrap->{$_} ? "$q$_$p = " . $wrap->{$_}->(":$_")
140
-          : "$q$_$p = :$_";
141
-      } sort keys %$param
142
-    );
123
+  my ($self, $param, $opts) = @_;
124
+  
125
+  my $wrap = $opts->{wrap} || {};
126
+  my ($q, $p) = split //, $self->q('');
127
+  
128
+  # Assign clause (performance is important)
129
+  join(
130
+    ', ',
131
+    map {
132
+      ref $param->{$_} eq 'SCALAR' ? "$q$_$p = " . ${$param->{$_}}
133
+      : $wrap->{$_} ? "$q$_$p = " . $wrap->{$_}->(":$_")
134
+      : "$q$_$p = :$_";
135
+    } sort keys %$param
136
+  );
143 137
 }
144 138
 
145 139
 sub column {
146
-    my $self = shift;
147
-    my $option = pop if ref $_[-1] eq 'HASH';
148
-    my $real_table = shift;
149
-    my $columns = shift;
150
-    my $table = $option->{alias} || $real_table;
151
-    
152
-    # Columns
153
-    unless (defined $columns) {
154
-        $columns ||= $self->model($real_table)->columns;
155
-    }
156
-    
157
-    # Separator
158
-    my $separator = $self->separator;
159
-    
160
-    # Column clause
161
-    my @column;
162
-    $columns ||= [];
163
-    push @column, $self->q($table) . "." . $self->q($_) .
164
-      " as " . $self->q("${table}${separator}$_")
165
-      for @$columns;
166
-    
167
-    return join (', ', @column);
140
+  my $self = shift;
141
+  my $option = pop if ref $_[-1] eq 'HASH';
142
+  my $real_table = shift;
143
+  my $columns = shift;
144
+  my $table = $option->{alias} || $real_table;
145
+  
146
+  # Columns
147
+  unless (defined $columns) {
148
+    $columns ||= $self->model($real_table)->columns;
149
+  }
150
+  
151
+  # Separator
152
+  my $separator = $self->separator;
153
+  
154
+  # Column clause
155
+  my @column;
156
+  $columns ||= [];
157
+  push @column, $self->q($table) . "." . $self->q($_) .
158
+    " as " . $self->q("${table}${separator}$_")
159
+    for @$columns;
160
+  
161
+  return join (', ', @column);
168 162
 }
169 163
 
170 164
 sub connect {
171
-    my $self = ref $_[0] ? shift : shift->new(@_);
172
-    
173
-    my $connector = $self->connector;
174
-    
175
-    if (!ref $connector && $connector) {
176
-        require DBIx::Connector;
177
-        
178
-        my $dsn = $self->dsn;
179
-        my $user = $self->user;
180
-        my $password = $self->password;
181
-        my $option = $self->_option;
182
-        my $connector = DBIx::Connector->new($dsn, $user, $password,
183
-          {%{$self->default_option} , %$option});
184
-        $self->connector($connector);
185
-    }
186
-    
187
-    # Connect
188
-    $self->dbh;
189
-    
190
-    return $self;
165
+  my $self = ref $_[0] ? shift : shift->new(@_);
166
+  
167
+  my $connector = $self->connector;
168
+  
169
+  if (!ref $connector && $connector) {
170
+    require DBIx::Connector;
171
+    
172
+    my $dsn = $self->dsn;
173
+    my $user = $self->user;
174
+    my $password = $self->password;
175
+    my $option = $self->_option;
176
+    my $connector = DBIx::Connector->new($dsn, $user, $password,
177
+      {%{$self->default_option} , %$option});
178
+    $self->connector($connector);
179
+  }
180
+  
181
+  # Connect
182
+  $self->dbh;
183
+  
184
+  return $self;
191 185
 }
192 186
 
193 187
 sub count { shift->select(column => 'count(*)', @_)->fetch_one->[0] }
194 188
 
195 189
 sub dbh {
196
-    my $self = shift;
190
+  my $self = shift;
191
+  
192
+  # Set
193
+  if (@_) {
194
+    $self->{dbh} = $_[0];
197 195
     
198
-    # Set
199
-    if (@_) {
200
-        $self->{dbh} = $_[0];
196
+    return $self;
197
+  }
198
+  
199
+  # Get
200
+  else {
201
+    # From Connction manager
202
+    if (my $connector = $self->connector) {
203
+      croak "connector must have dbh() method " . _subname
204
+        unless ref $connector && $connector->can('dbh');
201 205
         
202
-        return $self;
206
+      $self->{dbh} = $connector->dbh;
203 207
     }
204 208
     
205
-    # Get
206
-    else {
207
-        # From Connction manager
208
-        if (my $connector = $self->connector) {
209
-            croak "connector must have dbh() method " . _subname
210
-              unless ref $connector && $connector->can('dbh');
211
-              
212
-            $self->{dbh} = $connector->dbh;
213
-        }
214
-        
215
-        # Connect
216
-        $self->{dbh} ||= $self->_connect;
217
-        
218
-        # Quote
219
-        if (!defined $self->reserved_word_quote && !defined $self->quote) {
220
-            my $driver = $self->_driver;
221
-            my $quote =  $driver eq 'odbc' ? '[]'
222
-                       : $driver eq 'ado' ? '[]'
223
-                       : $driver eq 'mysql' ? '`'
224
-                       : '"';
225
-            $self->quote($quote);
226
-        }
227
-        
228
-        return $self->{dbh};
209
+    # Connect
210
+    $self->{dbh} ||= $self->_connect;
211
+    
212
+    # Quote
213
+    if (!defined $self->reserved_word_quote && !defined $self->quote) {
214
+      my $driver = $self->_driver;
215
+      my $quote =  $driver eq 'odbc' ? '[]'
216
+        : $driver eq 'ado' ? '[]'
217
+        : $driver eq 'mysql' ? '`'
218
+        : '"';
219
+      $self->quote($quote);
229 220
     }
221
+    
222
+    return $self->{dbh};
223
+  }
230 224
 }
231 225
 
232 226
 sub delete {
233
-    my ($self, %opt) = @_;
234
-    warn "delete method where_param option is DEPRECATED!"
235
-      if $opt{where_param};
236
-    
237
-    # Don't allow delete all rows
238
-    croak qq{delete method where or id option must be specified } . _subname
239
-      if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
240
-    
241
-    # Where
242
-    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
243
-      delete $opt{id}, $opt{primary_key}, $opt{table});
244
-
245
-    # Delete statement
246
-    my $sql = "delete ";
247
-    $sql .= "$opt{prefix} " if defined $opt{prefix};
248
-    $sql .= "from " . $self->q($opt{table}) . " $w->{clause} ";
249
-    
250
-    # Execute query
251
-    $opt{statement} = 'delete';
252
-    $self->execute($sql, $w->{param}, %opt);
227
+  my ($self, %opt) = @_;
228
+  warn "delete method where_param option is DEPRECATED!"
229
+    if $opt{where_param};
230
+  
231
+  # Don't allow delete all rows
232
+  croak qq{delete method where or id option must be specified } . _subname
233
+    if !$opt{where} && !defined $opt{id} && !$opt{allow_delete_all};
234
+  
235
+  # Where
236
+  my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
237
+    delete $opt{id}, $opt{primary_key}, $opt{table});
238
+
239
+  # Delete statement
240
+  my $sql = "delete ";
241
+  $sql .= "$opt{prefix} " if defined $opt{prefix};
242
+  $sql .= "from " . $self->q($opt{table}) . " $w->{clause} ";
243
+  
244
+  # Execute query
245
+  $opt{statement} = 'delete';
246
+  $self->execute($sql, $w->{param}, %opt);
253 247
 }
254 248
 
255 249
 sub delete_all { shift->delete(@_, allow_delete_all => 1) }
... ...
@@ -257,1523 +251,1499 @@ sub delete_all { shift->delete(@_, allow_delete_all => 1) }
257 251
 sub DESTROY {}
258 252
 
259 253
 sub create_model {
260
-    my $self = shift;
261
-    
262
-    # Options
263
-    my $opt = ref $_[0] eq 'HASH' ? $_[0] : {@_};
264
-    $opt->{dbi} = $self;
265
-    my $model_class = delete $opt->{model_class} || 'DBIx::Custom::Model';
266
-    my $model_name  = delete $opt->{name};
267
-    my $model_table = delete $opt->{table};
268
-    $model_name ||= $model_table;
269
-    
270
-    # Create model
271
-    my $model = $model_class->new($opt);
272
-    weaken $model->{dbi};
273
-    $model->name($model_name) unless $model->name;
274
-    $model->table($model_table) unless $model->table;
275
-    
276
-    # Apply filter(DEPRECATED logic)
277
-    if ($model->{filter}) {
278
-        my $filter = ref $model->filter eq 'HASH'
279
-                   ? [%{$model->filter}]
280
-                   : $model->filter;
281
-        $filter ||= [];
282
-        warn "DBIx::Custom::Model filter method is DEPRECATED!"
283
-          if @$filter;
284
-        $self->_apply_filter($model->table, @$filter);
285
-    }
286
-    
287
-    # Set model
288
-    $self->model($model->name, $model);
289
-    
290
-    return $self->model($model->name);
254
+  my $self = shift;
255
+  
256
+  # Options
257
+  my $opt = ref $_[0] eq 'HASH' ? $_[0] : {@_};
258
+  $opt->{dbi} = $self;
259
+  my $model_class = delete $opt->{model_class} || 'DBIx::Custom::Model';
260
+  my $model_name  = delete $opt->{name};
261
+  my $model_table = delete $opt->{table};
262
+  $model_name ||= $model_table;
263
+  
264
+  # Create model
265
+  my $model = $model_class->new($opt);
266
+  weaken $model->{dbi};
267
+  $model->name($model_name) unless $model->name;
268
+  $model->table($model_table) unless $model->table;
269
+  
270
+  # Apply filter(DEPRECATED logic)
271
+  if ($model->{filter}) {
272
+    my $filter = ref $model->filter eq 'HASH'
273
+      ? [%{$model->filter}]
274
+      : $model->filter;
275
+    $filter ||= [];
276
+    warn "DBIx::Custom::Model filter method is DEPRECATED!"
277
+      if @$filter;
278
+    $self->_apply_filter($model->table, @$filter);
279
+  }
280
+  
281
+  # Set model
282
+  $self->model($model->name, $model);
283
+  
284
+  return $self->model($model->name);
291 285
 }
292 286
 
293 287
 sub each_column {
294
-    my ($self, $cb, %options) = @_;
288
+  my ($self, $cb, %options) = @_;
289
+
290
+  my $user_column_info = $self->user_column_info;
291
+  
292
+  if ($user_column_info) {
293
+    $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
294
+  }
295
+  else {
296
+    my $re = $self->exclude_table || $options{exclude_table};
297
+    # Tables
298
+    my %tables;
299
+    $self->each_table(sub { $tables{$_[1]}++ });
295 300
 
296
-    my $user_column_info = $self->user_column_info;
297
-    
298
-    if ($user_column_info) {
299
-        $self->$cb($_->{table}, $_->{column}, $_->{info}) for @$user_column_info;
300
-    }
301
-    else {
302
-    
303
-        my $re = $self->exclude_table || $options{exclude_table};
304
-        # Tables
305
-        my %tables;
306
-        $self->each_table(sub { $tables{$_[1]}++ });
307
-
308
-        # Iterate all tables
309
-        my @tables = sort keys %tables;
310
-        for (my $i = 0; $i < @tables; $i++) {
311
-            my $table = $tables[$i];
312
-            
313
-            # Iterate all columns
314
-            my $sth_columns;
315
-            eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
316
-            next if $@;
317
-            while (my $column_info = $sth_columns->fetchrow_hashref) {
318
-                my $column = $column_info->{COLUMN_NAME};
319
-                $self->$cb($table, $column, $column_info);
320
-            }
321
-        }
301
+    # Iterate all tables
302
+    my @tables = sort keys %tables;
303
+    for (my $i = 0; $i < @tables; $i++) {
304
+      my $table = $tables[$i];
305
+      
306
+      # Iterate all columns
307
+      my $sth_columns;
308
+      eval {$sth_columns = $self->dbh->column_info(undef, undef, $table, '%')};
309
+      next if $@;
310
+      while (my $column_info = $sth_columns->fetchrow_hashref) {
311
+        my $column = $column_info->{COLUMN_NAME};
312
+        $self->$cb($table, $column, $column_info);
313
+      }
322 314
     }
315
+  }
323 316
 }
324 317
 
325 318
 sub each_table {
326
-    my ($self, $cb, %option) = @_;
327
-    
328
-    my $user_table_infos = $self->user_table_info;
329
-    
330
-    # Iterate tables
331
-    if ($user_table_infos) {
332
-        $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
333
-    }
334
-    else {
335
-        my $re = $self->exclude_table || $option{exclude};
336
-        my $sth_tables = $self->dbh->table_info;
337
-        while (my $table_info = $sth_tables->fetchrow_hashref) {
338
-            
339
-            # Table
340
-            my $table = $table_info->{TABLE_NAME};
341
-            next if defined $re && $table =~ /$re/;
342
-            $self->$cb($table, $table_info);
343
-        }
344
-    }
319
+  my ($self, $cb, %option) = @_;
320
+  
321
+  my $user_table_infos = $self->user_table_info;
322
+  
323
+  # Iterate tables
324
+  if ($user_table_infos) {
325
+      $self->$cb($_->{table}, $_->{info}) for @$user_table_infos;
326
+  }
327
+  else {
328
+    my $re = $self->exclude_table || $option{exclude};
329
+    my $sth_tables = $self->dbh->table_info;
330
+    while (my $table_info = $sth_tables->fetchrow_hashref) {
331
+      # Table
332
+      my $table = $table_info->{TABLE_NAME};
333
+      next if defined $re && $table =~ /$re/;
334
+      $self->$cb($table, $table_info);
335
+    }
336
+  }
345 337
 }
346 338
 
347 339
 sub execute {
348
-    my $self = shift;
349
-    my $sql = shift;
350
-
351
-    # Options
352
-    my $params;
353
-    $params = shift if @_ % 2;
354
-    my %opt = @_;
355
-    warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
356
-    $params ||= $opt{param} || {};
357
-    my $tables = $opt{table} || [];
358
-    $tables = [$tables] unless ref $tables eq 'ARRAY';
359
-    my $filter = ref $opt{filter} eq 'ARRAY' ?
360
-      _array_to_hash($opt{filter}) : $opt{filter};
361
-    
362
-    # Merge second parameter
363
-    my @cleanup;
364
-    my $saved_param;
365
-    if (($opt{statement} || '') ne 'insert' && ref $params eq 'ARRAY') {
366
-        my $params2 = $params->[1];
367
-        $params = $params->[0];
368
-        for my $column (keys %$params2) {
369
-            if (!exists $params->{$column}) {
370
-                $params->{$column} = $params2->{$column};
371
-                push @cleanup, $column;
372
-            }
373
-            else {
374
-                delete $params->{$_} for @cleanup;
375
-                @cleanup = ();
376
-                $saved_param  = $params;
377
-                $params = $self->merge_param($params, $params2);
378
-                delete $saved_param->{$_} for (@{$opt{cleanup} || []});
379
-                last;
380
-            }
381
-        }
382
-    }
383
-    $params = [$params] unless ref $params eq 'ARRAY';
384
-    
385
-    # Append
386
-    $sql .= $opt{append} if defined $opt{append} && !ref $sql;
387
-    
388
-    # Query
389
-    my $query;
390
-    if (ref $sql) {
391
-        $query = $sql;
392
-        warn "execute method receiving query object as first parameter is DEPRECATED!" .
393
-             "because this is very buggy.";
394
-    }
395
-    else {
396
-        $query = $opt{reuse}->{$sql} if $opt{reuse};
397
-        unless ($query) {
398
-            my $c = $self->{safety_character};
399
-            # Check unsafety keys
400
-            unless ((join('', keys %{$params->[0]}) || '') =~ /^[$c\.]+$/) {
401
-                for my $column (keys %{$params->[0]}) {
402
-                    croak qq{"$column" is not safety column name } . _subname
403
-                      unless $column =~ /^[$c\.]+$/;
404
-                }
405
-            }
406
-            $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter});
340
+  my $self = shift;
341
+  my $sql = shift;
342
+
343
+  # Options
344
+  my $params;
345
+  $params = shift if @_ % 2;
346
+  my %opt = @_;
347
+  warn "sqlfilter option is DEPRECATED" if $opt{sqlfilter};
348
+  $params ||= $opt{param} || {};
349
+  my $tables = $opt{table} || [];
350
+  $tables = [$tables] unless ref $tables eq 'ARRAY';
351
+  my $filter = ref $opt{filter} eq 'ARRAY' ?
352
+    _array_to_hash($opt{filter}) : $opt{filter};
353
+  
354
+  # Merge second parameter
355
+  my @cleanup;
356
+  my $saved_param;
357
+  if (($opt{statement} || '') ne 'insert' && ref $params eq 'ARRAY') {
358
+    my $params2 = $params->[1];
359
+    $params = $params->[0];
360
+    for my $column (keys %$params2) {
361
+      if (!exists $params->{$column}) {
362
+        $params->{$column} = $params2->{$column};
363
+        push @cleanup, $column;
364
+      }
365
+      else {
366
+        delete $params->{$_} for @cleanup;
367
+        @cleanup = ();
368
+        $saved_param  = $params;
369
+        $params = $self->merge_param($params, $params2);
370
+        delete $saved_param->{$_} for (@{$opt{cleanup} || []});
371
+        last;
372
+      }
373
+    }
374
+  }
375
+  $params = [$params] unless ref $params eq 'ARRAY';
376
+  
377
+  # Append
378
+  $sql .= $opt{append} if defined $opt{append} && !ref $sql;
379
+  
380
+  # Query
381
+  my $query;
382
+  if (ref $sql) {
383
+    $query = $sql;
384
+    warn "execute method receiving query object as first parameter is DEPRECATED!" .
385
+      "because this is very buggy.";
386
+  }
387
+  else {
388
+    $query = $opt{reuse}->{$sql} if $opt{reuse};
389
+    unless ($query) {
390
+      my $c = $self->{safety_character};
391
+      # Check unsafety keys
392
+      unless ((join('', keys %{$params->[0]}) || '') =~ /^[$c\.]+$/) {
393
+        for my $column (keys %{$params->[0]}) {
394
+          croak qq{"$column" is not safety column name } . _subname
395
+            unless $column =~ /^[$c\.]+$/;
407 396
         }
408
-        $query->{statement} = $opt{statement} || '';
409
-        $opt{reuse}->{$sql} = $query if $opt{reuse};
397
+      }
398
+      $query = $self->_create_query($sql,$opt{after_build_sql} || $opt{sqlfilter});
399
+    }
400
+    $query->{statement} = $opt{statement} || '';
401
+    $opt{reuse}->{$sql} = $query if $opt{reuse};
402
+  }
403
+      
404
+  # Save query
405
+  $self->{last_sql} = $query->{sql};
406
+
407
+  # Return query
408
+  if ($opt{query}) {
409
+    for my $column (@cleanup, @{$opt{cleanup} || []}) {
410
+      delete $_->{$column} for @$params;
410 411
     }
411
-        
412
-    # Save query
413
-    $self->{last_sql} = $query->{sql};
414
-
415
-    # Return query
416
-    if ($opt{query}) {
417
-        for my $column (@cleanup, @{$opt{cleanup} || []}) {
418
-            delete $_->{$column} for @$params;
419
-        }
420
-        return $query;
412
+    return $query;
413
+  };
414
+  
415
+  # Merge query filter(DEPRECATED!)
416
+  $filter ||= $query->{filter} || {};
417
+  
418
+  # Tables
419
+  unshift @$tables, @{$query->{tables} || []};
420
+  my $main_table = @{$tables}[-1];
421
+
422
+  # Merge id to parameter
423
+  if (defined $opt{id}) {
424
+    my $statement = $query->{statement};
425
+    warn "execute method id option is DEPRECATED!" unless $statement;
426
+    croak "execute id option must be specified with primary_key option"
427
+      unless $opt{primary_key};
428
+    $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
429
+    $opt{id} = [$opt{id}] unless ref $opt{id};
430
+    for (my $i = 0; $i < @{$opt{id}}; $i++) {
431
+      my $key = $opt{primary_key}->[$i];
432
+      $key = "$main_table.$key" if $statement eq 'update' ||
433
+        $statement eq 'delete' || $statement eq 'select';
434
+      next if exists $params->[0]->{$key};
435
+      $params->[0]->{$key} = $opt{id}->[$i];
436
+      push @cleanup, $key;1
437
+    }
438
+  }
439
+  
440
+  # Cleanup tables(DEPRECATED!)
441
+  $tables = $self->_remove_duplicate_table($tables, $main_table)
442
+    if @$tables > 1;
443
+  
444
+  # Type rule
445
+  my $type_filters = {};
446
+  my $type_rule_off = !$self->{_type_rule_is_called} || $opt{type_rule_off};
447
+  unless ($type_rule_off) {
448
+    my $type_rule_off_parts = {
449
+      1 => $opt{type_rule1_off},
450
+      2 => $opt{type_rule2_off}
421 451
     };
422
-    
423
-    # Merge query filter(DEPRECATED!)
424
-    $filter ||= $query->{filter} || {};
425
-    
426
-    # Tables
427
-    unshift @$tables, @{$query->{tables} || []};
428
-    my $main_table = @{$tables}[-1];
429
-
430
-    # Merge id to parameter
431
-    if (defined $opt{id}) {
432
-        my $statement = $query->{statement};
433
-        warn "execute method id option is DEPRECATED!" unless $statement;
434
-        croak "execute id option must be specified with primary_key option"
435
-          unless $opt{primary_key};
436
-        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
437
-        $opt{id} = [$opt{id}] unless ref $opt{id};
438
-        for (my $i = 0; $i < @{$opt{id}}; $i++) {
439
-           my $key = $opt{primary_key}->[$i];
440
-           $key = "$main_table.$key" if $statement eq 'update' ||
441
-             $statement eq 'delete' || $statement eq 'select';
442
-           next if exists $params->[0]->{$key};
443
-           $params->[0]->{$key} = $opt{id}->[$i];
444
-           push @cleanup, $key;1
452
+    for my $i (1, 2) {
453
+      unless ($type_rule_off_parts->{$i}) {
454
+        $type_filters->{$i} = {};
455
+        my $table_alias = $opt{table_alias} || {};
456
+        for my $alias (keys %$table_alias) {
457
+          my $table = $table_alias->{$alias};
458
+          
459
+          for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
460
+            $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
461
+          }
445 462
         }
446
-    }
447
-    
448
-    # Cleanup tables(DEPRECATED!)
449
-    $tables = $self->_remove_duplicate_table($tables, $main_table)
450
-      if @$tables > 1;
451
-    
452
-    # Type rule
453
-    my $type_filters = {};
454
-    my $type_rule_off = !$self->{_type_rule_is_called} || $opt{type_rule_off};
455
-    unless ($type_rule_off) {
456
-        my $type_rule_off_parts = {
457
-            1 => $opt{type_rule1_off},
458
-            2 => $opt{type_rule2_off}
459
-        };
460
-        for my $i (1, 2) {
461
-            unless ($type_rule_off_parts->{$i}) {
462
-                $type_filters->{$i} = {};
463
-                my $table_alias = $opt{table_alias} || {};
464
-                for my $alias (keys %$table_alias) {
465
-                    my $table = $table_alias->{$alias};
466
-                    
467
-                    for my $column (keys %{$self->{"_into$i"}{key}{$table} || {}}) {
468
-                        $type_filters->{$i}->{"$alias.$column"} = $self->{"_into$i"}{key}{$table}{$column};
469
-                    }
470
-                }
471
-                $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
472
-                  if $main_table;
473
-            }
474
-        }
475
-    }
476
-    
477
-    # Applied filter(DEPRECATED!)
478
-    if ($self->{filter}{on}) {
479
-        my $applied_filter = {};
480
-        for my $table (@$tables) {
481
-            $applied_filter = {
482
-                %$applied_filter,
483
-                %{$self->{filter}{out}->{$table} || {}}
484
-            }
485
-        }
486
-        $filter = {%$applied_filter, %$filter};
487
-    }
488
-    
489
-    # Replace filter name to code
490
-    for my $column (keys %$filter) {
491
-        my $name = $filter->{$column};
492
-        if (!defined $name) {
493
-            $filter->{$column} = undef;
494
-        }
495
-        elsif (ref $name ne 'CODE') {
496
-          croak qq{Filter "$name" is not registered" } . _subname
497
-            unless exists $self->filters->{$name};
498
-          $filter->{$column} = $self->filters->{$name};
499
-        }
500
-    }
501
-
502
-    # Execute
503
-    my $sth = $query->{sth};
504
-    my $affected;
505
-    if ((!$query->{duplicate} || $opt{bulk_insert}) && $type_rule_off
506
-      && !keys %$filter && !$self->{default_out_filter}
507
-      && !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
508
-    {
509
-        eval {
510
-            if ($opt{bulk_insert}) {
511
-                my %count;
512
-                my $param = $params->[0];
513
-                $affected = $sth->execute(map { $param->{$_}->[++$count{$_} - 1] }
514
-                  @{$query->{columns}});
515
-            }
516
-            else {
517
-                for my $param (@$params) {
518
-                    $affected = $sth->execute(map { $param->{$_} }
519
-                      @{$query->{columns}});
520
-                }
521
-            }
522
-        };
523
-    }
524
-    else {
463
+        $type_filters->{$i} = {%{$type_filters->{$i}}, %{$self->{"_into$i"}{key}{$main_table} || {}}}
464
+          if $main_table;
465
+      }
466
+    }
467
+  }
468
+  
469
+  # Applied filter(DEPRECATED!)
470
+  if ($self->{filter}{on}) {
471
+    my $applied_filter = {};
472
+    for my $table (@$tables) {
473
+      $applied_filter = {
474
+        %$applied_filter,
475
+        %{$self->{filter}{out}->{$table} || {}}
476
+      }
477
+    }
478
+    $filter = {%$applied_filter, %$filter};
479
+  }
480
+  
481
+  # Replace filter name to code
482
+  for my $column (keys %$filter) {
483
+    my $name = $filter->{$column};
484
+    if (!defined $name) {
485
+      $filter->{$column} = undef;
486
+    }
487
+    elsif (ref $name ne 'CODE') {
488
+      croak qq{Filter "$name" is not registered" } . _subname
489
+        unless exists $self->filters->{$name};
490
+      $filter->{$column} = $self->filters->{$name};
491
+    }
492
+  }
493
+
494
+  # Execute
495
+  my $sth = $query->{sth};
496
+  my $affected;
497
+  if ((!$query->{duplicate} || $opt{bulk_insert}) && $type_rule_off
498
+    && !keys %$filter && !$self->{default_out_filter}
499
+    && !$opt{bind_type} && !$opt{type} && !$ENV{DBIX_CUSTOM_DEBUG})
500
+  {
501
+    eval {
502
+      if ($opt{bulk_insert}) {
503
+        my %count;
504
+        my $param = $params->[0];
505
+        $affected = $sth->execute(map { $param->{$_}->[++$count{$_} - 1] }
506
+          @{$query->{columns}});
507
+      }
508
+      else {
525 509
         for my $param (@$params) {
526
-            # Create bind values
527
-            my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns},
528
-              $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
529
-
530
-            # Execute
531
-            eval {
532
-                if ($opt{bind_type} || $opt{type}) {
533
-                    $sth->bind_param($_ + 1, $bind->[$_],
534
-                        $bind_types->[$_] ? $bind_types->[$_] : ())
535
-                      for (0 .. @$bind - 1);
536
-                    $affected = $sth->execute;
537
-                }
538
-                else {
539
-                    $affected = $sth->execute(@$bind);
540
-                }
541
-
542
-                # DEBUG message
543
-                if ($ENV{DBIX_CUSTOM_DEBUG}) {
544
-                    warn "SQL:\n" . $query->{sql} . "\n";
545
-                    my @output;
546
-                    for my $value (@$bind) {
547
-                        $value = 'undef' unless defined $value;
548
-                        $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
549
-                          if utf8::is_utf8($value);
550
-                        push @output, $value;
551
-                    }
552
-                    warn "Bind values: " . join(', ', @output) . "\n\n";
553
-                }
554
-            };
510
+          $affected = $sth->execute(map { $param->{$_} }
511
+            @{$query->{columns}});
555 512
         }
556
-    }
557
-    
558
-    $self->_croak($@, qq{. Following SQL is executed.\n}
559
-      . qq{$query->{sql}\n} . _subname) if $@;
560
-
561
-    # Remove id from parameter
562
-    for my $column (@cleanup, @{$opt{cleanup} || []}) {
563
-        delete $_->{$column} for @$params;
564
-    }
565
-    
566
-    # Not select statement
567
-    return $affected unless $sth->{NUM_OF_FIELDS};
568
-
569
-    # Filter(DEPRECATED!)
570
-    my $infilter = {};
571
-    if ($self->{filter}{on}) {
572
-        $infilter->{in}  = {};
573
-        $infilter->{end} = {};
574
-        push @$tables, $main_table if $main_table;
575
-        for my $table (@$tables) {
576
-            for my $way (qw/in end/) {
577
-                $infilter->{$way} = {%{$infilter->{$way}},
578
-                  %{$self->{filter}{$way}{$table} || {}}};
579
-            }
513
+      }
514
+    };
515
+  }
516
+  else {
517
+    for my $param (@$params) {
518
+      # Create bind values
519
+      my ($bind, $bind_types) = $self->_create_bind_values($param, $query->{columns},
520
+        $filter, $type_filters, $opt{bind_type} || $opt{type} || {});
521
+
522
+      # Execute
523
+      eval {
524
+        if ($opt{bind_type} || $opt{type}) {
525
+          $sth->bind_param($_ + 1, $bind->[$_],
526
+              $bind_types->[$_] ? $bind_types->[$_] : ())
527
+            for (0 .. @$bind - 1);
528
+          $affected = $sth->execute;
580 529
         }
581
-    }
582
-    
583
-    # Result
584
-    $self->result_class->new(
585
-        sth => $sth,
586
-        dbi => $self,
587
-        default_filter => $self->{default_in_filter},
588
-        filter => $infilter->{in} || {},
589
-        end_filter => $infilter->{end} || {},
590
-        type_rule => {
591
-            from1 => $self->type_rule->{from1},
592
-            from2 => $self->type_rule->{from2}
593
-        },
594
-    );
530
+        else { $affected = $sth->execute(@$bind) }
531
+
532
+        # DEBUG message
533
+        if ($ENV{DBIX_CUSTOM_DEBUG}) {
534
+          warn "SQL:\n" . $query->{sql} . "\n";
535
+          my @output;
536
+          for my $value (@$bind) {
537
+            $value = 'undef' unless defined $value;
538
+            $value = encode($ENV{DBIX_CUSTOM_DEBUG_ENCODING} || 'UTF-8', $value)
539
+              if utf8::is_utf8($value);
540
+            push @output, $value;
541
+          }
542
+          warn "Bind values: " . join(', ', @output) . "\n\n";
543
+        }
544
+      };
545
+    }
546
+  }
547
+  
548
+  $self->_croak($@, qq{. Following SQL is executed.\n}
549
+    . qq{$query->{sql}\n} . _subname) if $@;
550
+
551
+  # Remove id from parameter
552
+  for my $column (@cleanup, @{$opt{cleanup} || []}) {
553
+    delete $_->{$column} for @$params;
554
+  }
555
+  
556
+  # Not select statement
557
+  return $affected unless $sth->{NUM_OF_FIELDS};
558
+
559
+  # Filter(DEPRECATED!)
560
+  my $infilter = {};
561
+  if ($self->{filter}{on}) {
562
+    $infilter->{in}  = {};
563
+    $infilter->{end} = {};
564
+    push @$tables, $main_table if $main_table;
565
+    for my $table (@$tables) {
566
+      for my $way (qw/in end/) {
567
+        $infilter->{$way} = {%{$infilter->{$way}},
568
+          %{$self->{filter}{$way}{$table} || {}}};
569
+      }
570
+    }
571
+  }
572
+  
573
+  # Result
574
+  $self->result_class->new(
575
+    sth => $sth,
576
+    dbi => $self,
577
+    default_filter => $self->{default_in_filter},
578
+    filter => $infilter->{in} || {},
579
+    end_filter => $infilter->{end} || {},
580
+    type_rule => {
581
+      from1 => $self->type_rule->{from1},
582
+      from2 => $self->type_rule->{from2}
583
+    },
584
+  );
595 585
 }
596 586
 
597 587
 sub get_table_info {
598
-    my ($self, %opt) = @_;
599
-    
600
-    my $exclude = delete $opt{exclude};
601
-    croak qq/"$_" is wrong option/ for keys %opt;
602
-    
603
-    my $table_info = [];
604
-    $self->each_table(
605
-        sub { push @$table_info, {table => $_[1], info => $_[2] } },
606
-        exclude => $exclude
607
-    );
608
-    
609
-    return [sort {$a->{table} cmp $b->{table} } @$table_info];
588
+  my ($self, %opt) = @_;
589
+  
590
+  my $exclude = delete $opt{exclude};
591
+  croak qq/"$_" is wrong option/ for keys %opt;
592
+  
593
+  my $table_info = [];
594
+  $self->each_table(
595
+    sub { push @$table_info, {table => $_[1], info => $_[2] } },
596
+    exclude => $exclude
597
+  );
598
+  
599
+  return [sort {$a->{table} cmp $b->{table} } @$table_info];
610 600
 }
611 601
 
612 602
 sub get_column_info {
613
-    my ($self, %opt) = @_;
614
-    
615
-    my $exclude_table = delete $opt{exclude_table};
616
-    croak qq/"$_" is wrong option/ for keys %opt;
617
-    
618
-    my $column_info = [];
619
-    $self->each_column(
620
-        sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
621
-        exclude_table => $exclude_table
622
-    );
623
-    
624
-    return [
625
-      sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
626
-        @$column_info];
603
+  my ($self, %opt) = @_;
604
+  
605
+  my $exclude_table = delete $opt{exclude_table};
606
+  croak qq/"$_" is wrong option/ for keys %opt;
607
+  
608
+  my $column_info = [];
609
+  $self->each_column(
610
+    sub { push @$column_info, {table => $_[1], column => $_[2], info => $_[3] } },
611
+    exclude_table => $exclude_table
612
+  );
613
+  
614
+  return [
615
+    sort {$a->{table} cmp $b->{table} || $a->{column} cmp $b->{column} }
616
+      @$column_info];
627 617
 }
628 618
 
629 619
 sub helper {
630
-    my $self = shift;
631
-    
632
-    # Register method
633
-    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
634
-    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
635
-    
636
-    return $self;
620
+  my $self = shift;
621
+  
622
+  # Register method
623
+  my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
624
+  $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
625
+  
626
+  return $self;
637 627
 }
638 628
 
639 629
 sub insert {
640
-    my $self = shift;
641
-    
642
-    # Options
643
-    my $params = @_ % 2 ? shift : undef;
644
-    my %opt = @_;
645
-    warn "insert method param option is DEPRECATED!" if $opt{param};
646
-    $params ||= delete $opt{param} || {};
647
-    
648
-    my $multi;
649
-    if (ref $params eq 'ARRAY') { $multi = 1 }
650
-    else { $params = [$params] }
651
-    
652
-    # Timestamp(DEPRECATED!)
653
-    if (!$multi && $opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
654
-        warn "insert timestamp option is DEPRECATED! use created_at with now attribute";
655
-        my $columns = $insert_timestamp->[0];
656
-        $columns = [$columns] unless ref $columns eq 'ARRAY';
657
-        my $value = $insert_timestamp->[1];
658
-        $value = $value->() if ref $value eq 'CODE';
659
-        $params->[0]->{$_} = $value for @$columns;
660
-    }
661
-
662
-    # Created time and updated time
663
-    my @timestamp_cleanup;
664
-    if (defined $opt{created_at} || defined $opt{updated_at}) {
665
-        my $now = $self->now;
666
-        $now = $now->() if ref $now eq 'CODE';
667
-        if (defined $opt{created_at}) {
668
-            $_->{$opt{created_at}} = $now for @$params;
669
-            push @timestamp_cleanup, $opt{created_at};
670
-        }
671
-        if (defined $opt{updated_at}) {
672
-            $_->{$opt{updated_at}} = $now for @$params;
673
-            push @timestamp_cleanup, $opt{updated_at};
674
-        }
630
+  my $self = shift;
631
+  
632
+  # Options
633
+  my $params = @_ % 2 ? shift : undef;
634
+  my %opt = @_;
635
+  warn "insert method param option is DEPRECATED!" if $opt{param};
636
+  $params ||= delete $opt{param} || {};
637
+  
638
+  my $multi;
639
+  if (ref $params eq 'ARRAY') { $multi = 1 }
640
+  else { $params = [$params] }
641
+  
642
+  # Timestamp(DEPRECATED!)
643
+  if (!$multi && $opt{timestamp} && (my $insert_timestamp = $self->insert_timestamp)) {
644
+    warn "insert timestamp option is DEPRECATED! use created_at with now attribute";
645
+    my $columns = $insert_timestamp->[0];
646
+    $columns = [$columns] unless ref $columns eq 'ARRAY';
647
+    my $value = $insert_timestamp->[1];
648
+    $value = $value->() if ref $value eq 'CODE';
649
+    $params->[0]->{$_} = $value for @$columns;
650
+  }
651
+
652
+  # Created time and updated time
653
+  my @timestamp_cleanup;
654
+  if (defined $opt{created_at} || defined $opt{updated_at}) {
655
+    my $now = $self->now;
656
+    $now = $now->() if ref $now eq 'CODE';
657
+    if (defined $opt{created_at}) {
658
+      $_->{$opt{created_at}} = $now for @$params;
659
+      push @timestamp_cleanup, $opt{created_at};
675 660
     }
676
-    
677
-    # Merge id to parameter
678
-    my @cleanup;
679
-    my $id_param = {};
680
-    if (defined $opt{id} && !$multi) {
681
-        croak "insert id option must be specified with primary_key option"
682
-          unless $opt{primary_key};
683
-        $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
684
-        $opt{id} = [$opt{id}] unless ref $opt{id};
685
-        for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
686
-           my $key = $opt{primary_key}->[$i];
687
-           next if exists $params->[0]->{$key};
688
-           $params->[0]->{$key} = $opt{id}->[$i];
689
-           push @cleanup, $key;
690
-        }
691
-    }
692
-    
693
-    # Insert statement
694
-    my $sql = "insert ";
695
-    $sql .= "$opt{prefix} " if defined $opt{prefix};
696
-    $sql .= "into " . $self->q($opt{table}) . " ";
697
-    if ($opt{bulk_insert}) {
698
-        $sql .= $self->_multi_values_clause($params, {wrap => $opt{wrap}}) . " ";
699
-        my $new_param = {};
700
-        $new_param->{$_} = [] for keys %{$params->[0]};
701
-        for my $param (@$params) {
702
-            push @{$new_param->{$_}}, $param->{$_} for keys %$param;
703
-        }
704
-        $params = [$new_param];
705
-    }
706
-    else {
707
-        $sql .= $self->values_clause($params->[0], {wrap => $opt{wrap}}) . " ";
708
-    }
709
-
710
-    # Remove id from parameter
711
-    delete $params->[0]->{$_} for @cleanup;
712
-    
713
-    # Execute query
714
-    $opt{statement} = 'insert';
715
-    $opt{cleanup} = \@timestamp_cleanup;
716
-    $self->execute($sql, $params, %opt);
661
+    if (defined $opt{updated_at}) {
662
+      $_->{$opt{updated_at}} = $now for @$params;
663
+      push @timestamp_cleanup, $opt{updated_at};
664
+    }
665
+  }
666
+  
667
+  # Merge id to parameter
668
+  my @cleanup;
669
+  my $id_param = {};
670
+  if (defined $opt{id} && !$multi) {
671
+    croak "insert id option must be specified with primary_key option"
672
+      unless $opt{primary_key};
673
+    $opt{primary_key} = [$opt{primary_key}] unless ref $opt{primary_key};
674
+    $opt{id} = [$opt{id}] unless ref $opt{id};
675
+    for (my $i = 0; $i < @{$opt{primary_key}}; $i++) {
676
+      my $key = $opt{primary_key}->[$i];
677
+      next if exists $params->[0]->{$key};
678
+      $params->[0]->{$key} = $opt{id}->[$i];
679
+      push @cleanup, $key;
680
+    }
681
+  }
682
+  
683
+  # Insert statement
684
+  my $sql = "insert ";
685
+  $sql .= "$opt{prefix} " if defined $opt{prefix};
686
+  $sql .= "into " . $self->q($opt{table}) . " ";
687
+  if ($opt{bulk_insert}) {
688
+    $sql .= $self->_multi_values_clause($params, {wrap => $opt{wrap}}) . " ";
689
+    my $new_param = {};
690
+    $new_param->{$_} = [] for keys %{$params->[0]};
691
+    for my $param (@$params) {
692
+      push @{$new_param->{$_}}, $param->{$_} for keys %$param;
693
+    }
694
+    $params = [$new_param];
695
+  }
696
+  else {
697
+    $sql .= $self->values_clause($params->[0], {wrap => $opt{wrap}}) . " ";
698
+  }
699
+
700
+  # Remove id from parameter
701
+  delete $params->[0]->{$_} for @cleanup;
702
+  
703
+  # Execute query
704
+  $opt{statement} = 'insert';
705
+  $opt{cleanup} = \@timestamp_cleanup;
706
+  $self->execute($sql, $params, %opt);
717 707
 }
718 708
 
719 709
 sub insert_timestamp {
720
-    my $self = shift;
710
+  my $self = shift;
711
+  
712
+  warn "insert_timestamp method is DEPRECATED! use now attribute";
713
+  
714
+  if (@_) {
715
+    $self->{insert_timestamp} = [@_];
721 716
     
722
-    warn "insert_timestamp method is DEPRECATED! use now attribute";
723
-    
724
-    if (@_) {
725
-        $self->{insert_timestamp} = [@_];
726
-        
727
-        return $self;
728
-    }
729
-    return $self->{insert_timestamp};
717
+    return $self;
718
+  }
719
+  return $self->{insert_timestamp};
730 720
 }
731 721
 
732 722
 sub include_model {
733
-    my ($self, $name_space, $model_infos) = @_;
734
-    
735
-    # Name space
736
-    $name_space ||= '';
737
-    
738
-    # Get Model infomations
739
-    unless ($model_infos) {
740
-
741
-        # Load name space module
742
-        croak qq{"$name_space" is invalid class name } . _subname
743
-          if $name_space =~ /[^\w:]/;
744
-        eval "use $name_space";
745
-        croak qq{Name space module "$name_space.pm" is needed. $@ }
746
-            . _subname
747
-          if $@;
748
-        
749
-        # Search model modules
750
-        my $path = $INC{"$name_space.pm"};
751
-        $path =~ s/\.pm$//;
752
-        opendir my $dh, $path
753
-          or croak qq{Can't open directory "$path": $! } . _subname
754
-        $model_infos = [];
755
-        while (my $module = readdir $dh) {
756
-            push @$model_infos, $module
757
-              if $module =~ s/\.pm$//;
758
-        }
759
-        close $dh;
723
+  my ($self, $name_space, $model_infos) = @_;
724
+  
725
+  # Name space
726
+  $name_space ||= '';
727
+  
728
+  # Get Model infomations
729
+  unless ($model_infos) {
730
+
731
+    # Load name space module
732
+    croak qq{"$name_space" is invalid class name } . _subname
733
+      if $name_space =~ /[^\w:]/;
734
+    eval "use $name_space";
735
+    croak qq{Name space module "$name_space.pm" is needed. $@ }
736
+        . _subname
737
+      if $@;
738
+    
739
+    # Search model modules
740
+    my $path = $INC{"$name_space.pm"};
741
+    $path =~ s/\.pm$//;
742
+    opendir my $dh, $path
743
+      or croak qq{Can't open directory "$path": $! } . _subname
744
+    $model_infos = [];
745
+    while (my $module = readdir $dh) {
746
+      push @$model_infos, $module
747
+        if $module =~ s/\.pm$//;
748
+    }
749
+    close $dh;
750
+  }
751
+  
752
+  # Include models
753
+  for my $model_info (@$model_infos) {
754
+    
755
+    # Load model
756
+    my $model_class;
757
+    my $model_name;
758
+    my $model_table;
759
+    if (ref $model_info eq 'HASH') {
760
+      $model_class = $model_info->{class};
761
+      $model_name  = $model_info->{name};
762
+      $model_table = $model_info->{table};
763
+      
764
+      $model_name  ||= $model_class;
765
+      $model_table ||= $model_name;
766
+    }
767
+    else { $model_class = $model_name = $model_table = $model_info }
768
+    my $mclass = "${name_space}::$model_class";
769
+    croak qq{"$mclass" is invalid class name } . _subname
770
+      if $mclass =~ /[^\w:]/;
771
+    unless ($mclass->can('isa')) {
772
+      eval "use $mclass";
773
+      croak "$@ " . _subname if $@;
760 774
     }
761 775
     
762
-    # Include models
763
-    for my $model_info (@$model_infos) {
764
-        
765
-        # Load model
766
-        my $model_class;
767
-        my $model_name;
768
-        my $model_table;
769
-        if (ref $model_info eq 'HASH') {
770
-            $model_class = $model_info->{class};
771
-            $model_name  = $model_info->{name};
772
-            $model_table = $model_info->{table};
773
-            
774
-            $model_name  ||= $model_class;
775
-            $model_table ||= $model_name;
776
-        }
777
-        else { $model_class = $model_name = $model_table = $model_info }
778
-        my $mclass = "${name_space}::$model_class";
779
-        croak qq{"$mclass" is invalid class name } . _subname
780
-          if $mclass =~ /[^\w:]/;
781
-        unless ($mclass->can('isa')) {
782
-            eval "use $mclass";
783
-            croak "$@ " . _subname if $@;
784
-        }
785
-        
786
-        # Create model
787
-        my $opt = {};
788
-        $opt->{model_class} = $mclass if $mclass;
789
-        $opt->{name}        = $model_name if $model_name;
790
-        $opt->{table}       = $model_table if $model_table;
791
-        $self->create_model($opt);
792
-    }
793
-    
794
-    return $self;
776
+    # Create model
777
+    my $opt = {};
778
+    $opt->{model_class} = $mclass if $mclass;
779
+    $opt->{name}        = $model_name if $model_name;
780
+    $opt->{table}       = $model_table if $model_table;
781
+    $self->create_model($opt);
782
+  }
783
+  
784
+  return $self;
795 785
 }
796 786
 
797 787
 sub like_value { sub { "%$_[0]%" } }
798 788
 
799 789
 sub mapper {
800
-    my $self = shift;
801
-    return DBIx::Custom::Mapper->new(@_);
790
+  my $self = shift;
791
+  return DBIx::Custom::Mapper->new(@_);
802 792
 }
803 793
 
804 794
 sub merge_param {
805
-    my ($self, @params) = @_;
806
-    
807
-    # Merge parameters
808
-    my $merge = {};
809
-    for my $param (@params) {
810
-        for my $column (keys %$param) {
811
-            my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
812
-            
813
-            if (exists $merge->{$column}) {
814
-                $merge->{$column} = [$merge->{$column}]
815
-                  unless ref $merge->{$column} eq 'ARRAY';
816
-                push @{$merge->{$column}},
817
-                  ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
818
-            }
819
-            else {
820
-                $merge->{$column} = $param->{$column};
821
-            }
822
-        }
823
-    }
824
-    
825
-    return $merge;
795
+  my ($self, @params) = @_;
796
+  
797
+  # Merge parameters
798
+  my $merge = {};
799
+  for my $param (@params) {
800
+    for my $column (keys %$param) {
801
+      my $param_is_array = ref $param->{$column} eq 'ARRAY' ? 1 : 0;
802
+      
803
+      if (exists $merge->{$column}) {
804
+        $merge->{$column} = [$merge->{$column}]
805
+          unless ref $merge->{$column} eq 'ARRAY';
806
+        push @{$merge->{$column}},
807
+          ref $param->{$column} ? @{$param->{$column}} : $param->{$column};
808
+      }
809
+      else { $merge->{$column} = $param->{$column} }
810
+    }
811
+  }
812
+  
813
+  return $merge;
826 814
 }
827 815
 
828 816
 sub model {
829
-    my ($self, $name, $model) = @_;
830
-    
831
-    # Set model
832
-    if ($model) {
833
-        $self->models->{$name} = $model;
834
-        return $self;
835
-    }
836
-    
837
-    # Check model existance
838
-    croak qq{Model "$name" is not included } . _subname
839
-      unless $self->models->{$name};
840
-    
841
-    # Get model
842
-    return $self->models->{$name};
817
+  my ($self, $name, $model) = @_;
818
+  
819
+  # Set model
820
+  if ($model) {
821
+    $self->models->{$name} = $model;
822
+    return $self;
823
+  }
824
+  
825
+  # Check model existance
826
+  croak qq{Model "$name" is not included } . _subname
827
+    unless $self->models->{$name};
828
+  
829
+  # Get model
830
+  return $self->models->{$name};
843 831
 }
844 832
 
845 833
 sub mycolumn {
846
-    my ($self, $table, $columns) = @_;
847
-    
848
-    # Create column clause
849
-    my @column;
850
-    $columns ||= [];
851
-    push @column, $self->q($table) . "." . $self->q($_) .
852
-      " as " . $self->q($_)
853
-      for @$columns;
854
-    
855
-    return join (', ', @column);
834
+  my ($self, $table, $columns) = @_;
835
+  
836
+  # Create column clause
837
+  my @column;
838
+  $columns ||= [];
839
+  push @column, $self->q($table) . "." . $self->q($_) . " as " . $self->q($_)
840
+    for @$columns;
841
+  
842
+  return join (', ', @column);
856 843
 }
857 844
 
858 845
 sub new {
859
-    my $self = shift->SUPER::new(@_);
860
-    
861
-    # Check attributes
862
-    my @attrs = keys %$self;
863
-    for my $attr (@attrs) {
864
-        croak qq{Invalid attribute: "$attr" } . _subname
865
-          unless $self->can($attr);
866
-    }
867
-    
868
-    $self->{safety_character} = 'a-zA-Z0-9_'
869
-      unless exists $self->{safety_character};
870
-
871
-    # DEPRECATED
872
-    $self->{_tags} = {
873
-        '?'     => \&DBIx::Custom::Tag::placeholder,
874
-        '='     => \&DBIx::Custom::Tag::equal,
875
-        '<>'    => \&DBIx::Custom::Tag::not_equal,
876
-        '>'     => \&DBIx::Custom::Tag::greater_than,
877
-        '<'     => \&DBIx::Custom::Tag::lower_than,
878
-        '>='    => \&DBIx::Custom::Tag::greater_than_equal,
879
-        '<='    => \&DBIx::Custom::Tag::lower_than_equal,
880
-        'like'  => \&DBIx::Custom::Tag::like,
881
-        'in'    => \&DBIx::Custom::Tag::in,
882
-        'insert_param' => \&DBIx::Custom::Tag::insert_param,
883
-        'update_param' => \&DBIx::Custom::Tag::update_param
884
-    };
885
-    $self->{tag_parse} = 1 unless exists $self->{tag_parse};
886
-    $self->{cache} = 0 unless exists $self->{cache};
887
-    
888
-    return $self;
846
+  my $self = shift->SUPER::new(@_);
847
+  
848
+  # Check attributes
849
+  my @attrs = keys %$self;
850
+  for my $attr (@attrs) {
851
+    croak qq{Invalid attribute: "$attr" } . _subname
852
+      unless $self->can($attr);
853
+  }
854
+  
855
+  $self->{safety_character} = 'a-zA-Z0-9_'
856
+    unless exists $self->{safety_character};
857
+
858
+  # DEPRECATED
859
+  $self->{_tags} = {
860
+    '?'     => \&DBIx::Custom::Tag::placeholder,
861
+    '='     => \&DBIx::Custom::Tag::equal,
862
+    '<>'    => \&DBIx::Custom::Tag::not_equal,
863
+    '>'     => \&DBIx::Custom::Tag::greater_than,
864
+    '<'     => \&DBIx::Custom::Tag::lower_than,
865
+    '>='    => \&DBIx::Custom::Tag::greater_than_equal,
866
+    '<='    => \&DBIx::Custom::Tag::lower_than_equal,
867
+    'like'  => \&DBIx::Custom::Tag::like,
868
+    'in'    => \&DBIx::Custom::Tag::in,
869
+    'insert_param' => \&DBIx::Custom::Tag::insert_param,
870
+    'update_param' => \&DBIx::Custom::Tag::update_param
871
+  };
872
+  $self->{tag_parse} = 1 unless exists $self->{tag_parse};
873
+  $self->{cache} = 0 unless exists $self->{cache};
874
+  
875
+  return $self;
889 876
 }
890 877
 
891 878
 sub not_exists { DBIx::Custom::NotExists->singleton }
892 879
 
893 880
 sub order {
894
-    my $self = shift;
895
-    return DBIx::Custom::Order->new(dbi => $self, @_);
881
+  my $self = shift;
882
+  return DBIx::Custom::Order->new(dbi => $self, @_);
896 883
 }
897 884
 
898 885
 sub q {
899
-    my ($self, $value, $quotemeta) = @_;
900
-    
901
-    my $quote = $self->{reserved_word_quote}
902
-      || $self->{quote} || $self->quote || '';
903
-    return "$quote$value$quote"
904
-      if !$quotemeta && ($quote eq '`' || $quote eq '"');
905
-    
906
-    my $q = substr($quote, 0, 1) || '';
907
-    my $p;
908
-    if (defined $quote && length $quote > 1) {
909
-        $p = substr($quote, 1, 1);
910
-    }
911
-    else { $p = $q }
912
-    
913
-    if ($quotemeta) {
914
-        $q = quotemeta($q);
915
-        $p = quotemeta($p);
916
-    }
917
-    
918
-    return "$q$value$p";
886
+  my ($self, $value, $quotemeta) = @_;
887
+  
888
+  my $quote = $self->{reserved_word_quote}
889
+    || $self->{quote} || $self->quote || '';
890
+  return "$quote$value$quote"
891
+    if !$quotemeta && ($quote eq '`' || $quote eq '"');
892
+  
893
+  my $q = substr($quote, 0, 1) || '';
894
+  my $p;
895
+  if (defined $quote && length $quote > 1) {
896
+    $p = substr($quote, 1, 1);
897
+  }
898
+  else { $p = $q }
899
+  
900
+  if ($quotemeta) {
901
+    $q = quotemeta($q);
902
+    $p = quotemeta($p);
903
+  }
904
+  
905
+  return "$q$value$p";
919 906
 }
920 907
 
921 908
 sub register_filter {
922
-    my $self = shift;
923
-    
924
-    # Register filter
925
-    my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
926
-    $self->filters({%{$self->filters}, %$filters});
927
-    
928
-    return $self;
909
+  my $self = shift;
910
+  
911
+  # Register filter
912
+  my $filters = ref $_[0] eq 'HASH' ? $_[0] : {@_};
913
+  $self->filters({%{$self->filters}, %$filters});
914
+  
915
+  return $self;
929 916
 }
930 917
 
931 918
 sub select {
932
-    my $self = shift;
933
-    my $column = shift if @_ % 2;
934
-    my %opt = @_;
935
-    $opt{column} = $column if defined $column;
936
-
937
-    # Options
938
-    my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
939
-               : defined $opt{table} ? [$opt{table}]
940
-               : [];
941
-    $opt{table} = $tables;
942
-    my $where_param = $opt{where_param} || delete $opt{param} || {};
943
-    warn "select method where_param option is DEPRECATED!"
944
-      if $opt{where_param};
945
-    
946
-    # Add relation tables(DEPRECATED!);
947
-    if ($opt{relation}) {
948
-        warn "select() relation option is DEPRECATED!";
949
-        $self->_add_relation_table($tables, $opt{relation});
950
-    }
951
-    
952
-    # Select statement
953
-    my $sql = 'select ';
954
-    
955
-    # Prefix
956
-    $sql .= "$opt{prefix} " if defined $opt{prefix};
957
-    
958
-    # Column
959
-    if (defined $opt{column}) {
960
-        my $columns
961
-          = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
962
-        for my $column (@$columns) {
963
-            if (ref $column eq 'HASH') {
964
-                $column = $self->column(%$column) if ref $column eq 'HASH';
965
-            }
966
-            elsif (ref $column eq 'ARRAY') {
967
-                warn "select column option [COLUMN => ALIAS] syntax is DEPRECATED!" .
968
-                  "use q method to quote the value";
969
-                if (@$column == 3 && $column->[1] eq 'as') {
970
-                    warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
971
-                    splice @$column, 1, 1;
972
-                }
973
-                
974
-                $column = join(' ', $column->[0], 'as', $self->q($column->[1]));
975
-            }
976
-            unshift @$tables, @{$self->_search_tables($column)};
977
-            $sql .= "$column, ";
978
-        }
979
-        $sql =~ s/, $/ /;
980
-    }
981
-    else { $sql .= '* ' }
982
-    
983
-    # Table
984
-    $sql .= 'from ';
985
-    if ($opt{relation}) {
986
-        my $found = {};
987
-        for my $table (@$tables) {
988
-            $sql .= $self->q($table) . ', ' unless $found->{$table};
989
-            $found->{$table} = 1;
919
+  my $self = shift;
920
+  my $column = shift if @_ % 2;
921
+  my %opt = @_;
922
+  $opt{column} = $column if defined $column;
923
+
924
+  # Options
925
+  my $tables = ref $opt{table} eq 'ARRAY' ? $opt{table}
926
+    : defined $opt{table} ? [$opt{table}]
927
+    : [];
928
+  $opt{table} = $tables;
929
+  my $where_param = $opt{where_param} || delete $opt{param} || {};
930
+  warn "select method where_param option is DEPRECATED!"
931
+    if $opt{where_param};
932
+  
933
+  # Add relation tables(DEPRECATED!);
934
+  if ($opt{relation}) {
935
+    warn "select() relation option is DEPRECATED!";
936
+    $self->_add_relation_table($tables, $opt{relation});
937
+  }
938
+  
939
+  # Select statement
940
+  my $sql = 'select ';
941
+  
942
+  # Prefix
943
+  $sql .= "$opt{prefix} " if defined $opt{prefix};
944
+  
945
+  # Column
946
+  if (defined $opt{column}) {
947
+    my $columns
948
+      = ref $opt{column} eq 'ARRAY' ? $opt{column} : [$opt{column}];
949
+    for my $column (@$columns) {
950
+      if (ref $column eq 'HASH') {
951
+        $column = $self->column(%$column) if ref $column eq 'HASH';
952
+      }
953
+      elsif (ref $column eq 'ARRAY') {
954
+        warn "select column option [COLUMN => ALIAS] syntax is DEPRECATED!" .
955
+          "use q method to quote the value";
956
+        if (@$column == 3 && $column->[1] eq 'as') {
957
+          warn "[COLUMN, as => ALIAS] is DEPRECATED! use [COLUMN => ALIAS]";
958
+          splice @$column, 1, 1;
990 959
         }
960
+        
961
+        $column = join(' ', $column->[0], 'as', $self->q($column->[1]));
962
+      }
963
+      unshift @$tables, @{$self->_search_tables($column)};
964
+      $sql .= "$column, ";
991 965
     }
992
-    else { $sql .= $self->q($tables->[-1] || '') . ' ' }
993 966
     $sql =~ s/, $/ /;
994
-    croak "select method table option must be specified " . _subname
995
-      unless defined $tables->[-1];
996
-
997
-    # Add tables in parameter
998
-    unshift @$tables,
999
-            @{$self->_search_tables(join(' ', keys %$where_param) || '')};
1000
-    
1001
-    # Where
1002
-    my $w = $self->_where_clause_and_param($opt{where}, $where_param,
1003
-      delete $opt{id}, $opt{primary_key}, $tables->[-1]);
1004
-    
1005
-    # Add table names in where clause
1006
-    unshift @$tables, @{$self->_search_tables($w->{clause})};
1007
-    
1008
-    # Join statement
1009
-    $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
1010
-    
1011
-    # Add where clause
1012
-    $sql .= "$w->{clause} ";
1013
-    
1014
-    # Relation(DEPRECATED!);
1015
-    $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
1016
-      if $opt{relation};
1017
-    
1018
-    # Execute query
1019
-    $opt{statement} = 'select';
1020
-    my $result = $self->execute($sql, $w->{param}, %opt);
1021
-    
1022
-    $result;
967
+  }
968
+  else { $sql .= '* ' }
969
+  
970
+  # Table
971
+  $sql .= 'from ';
972
+  if ($opt{relation}) {
973
+    my $found = {};
974
+    for my $table (@$tables) {
975
+      $sql .= $self->q($table) . ', ' unless $found->{$table};
976
+      $found->{$table} = 1;
977
+    }
978
+  }
979
+  else { $sql .= $self->q($tables->[-1] || '') . ' ' }
980
+  $sql =~ s/, $/ /;
981
+  croak "select method table option must be specified " . _subname
982
+    unless defined $tables->[-1];
983
+
984
+  # Add tables in parameter
985
+  unshift @$tables,
986
+    @{$self->_search_tables(join(' ', keys %$where_param) || '')};
987
+  
988
+  # Where
989
+  my $w = $self->_where_clause_and_param($opt{where}, $where_param,
990
+    delete $opt{id}, $opt{primary_key}, $tables->[-1]);
991
+  
992
+  # Add table names in where clause
993
+  unshift @$tables, @{$self->_search_tables($w->{clause})};
994
+  
995
+  # Join statement
996
+  $self->_push_join(\$sql, $opt{join}, $tables) if defined $opt{join};
997
+  
998
+  # Add where clause
999
+  $sql .= "$w->{clause} ";
1000
+  
1001
+  # Relation(DEPRECATED!);
1002
+  $self->_push_relation(\$sql, $tables, $opt{relation}, $w->{clause} eq '' ? 1 : 0)
1003
+    if $opt{relation};
1004
+  
1005
+  # Execute query
1006
+  $opt{statement} = 'select';
1007
+  my $result = $self->execute($sql, $w->{param}, %opt);
1008
+  
1009
+  $result;
1023 1010
 }
1024 1011
 
1025 1012
 sub setup_model {
1026
-    my $self = shift;
1027
-    
1028
-    # Setup model
1029
-    $self->each_column(
1030
-        sub {
1031
-            my ($self, $table, $column, $column_info) = @_;
1032
-            if (my $model = $self->models->{$table}) {
1033
-                push @{$model->columns}, $column;
1034
-            }
1035
-        }
1036
-    );
1037
-    return $self;
1013
+  my $self = shift;
1014
+  
1015
+  # Setup model
1016
+  $self->each_column(
1017
+    sub {
1018
+      my ($self, $table, $column, $column_info) = @_;
1019
+      if (my $model = $self->models->{$table}) {
1020
+        push @{$model->columns}, $column;
1021
+      }
1022
+    }
1023
+  );
1024
+  return $self;
1038 1025
 }
1039 1026
 
1040 1027
 sub show_datatype {
1041
-    my ($self, $table) = @_;
1042
-    croak "Table name must be specified" unless defined $table;
1043
-    print "$table\n";
1044
-    
1045
-    my $result = $self->select(table => $table, where => "'0' <> '0'");
1046
-    my $sth = $result->sth;
1047
-
1048
-    my $columns = $sth->{NAME};
1049
-    my $data_types = $sth->{TYPE};
1050
-    
1051
-    for (my $i = 0; $i < @$columns; $i++) {
1052
-        my $column = $columns->[$i];
1053
-        my $data_type = lc $data_types->[$i];
1054
-        print "$column: $data_type\n";
1055
-    }
1028
+  my ($self, $table) = @_;
1029
+  croak "Table name must be specified" unless defined $table;
1030
+  print "$table\n";
1031
+  
1032
+  my $result = $self->select(table => $table, where => "'0' <> '0'");
1033
+  my $sth = $result->sth;
1034
+
1035
+  my $columns = $sth->{NAME};
1036
+  my $data_types = $sth->{TYPE};
1037
+  
1038
+  for (my $i = 0; $i < @$columns; $i++) {
1039
+    my $column = $columns->[$i];
1040
+    my $data_type = lc $data_types->[$i];
1041
+    print "$column: $data_type\n";
1042
+  }
1056 1043
 }
1057 1044
 
1058 1045
 sub show_typename {
1059
-    my ($self, $t) = @_;
1060
-    croak "Table name must be specified" unless defined $t;
1061
-    print "$t\n";
1062
-    
1063
-    $self->each_column(sub {
1064
-        my ($self, $table, $column, $infos) = @_;
1065
-        return unless $table eq $t;
1066
-        my $typename = lc $infos->{TYPE_NAME};
1067
-        print "$column: $typename\n";
1068
-    });
1069
-    
1070
-    return $self;
1046
+  my ($self, $t) = @_;
1047
+  croak "Table name must be specified" unless defined $t;
1048
+  print "$t\n";
1049
+  
1050
+  $self->each_column(sub {
1051
+    my ($self, $table, $column, $infos) = @_;
1052
+    return unless $table eq $t;
1053
+    my $typename = lc $infos->{TYPE_NAME};
1054
+    print "$column: $typename\n";
1055
+  });
1056
+  
1057
+  return $self;
1071 1058
 }
1072 1059
 
1073 1060
 sub show_tables {
1074
-    my $self = shift;
1075
-    
1076
-    my %tables;
1077
-    $self->each_table(sub { $tables{$_[1]}++ });
1078
-    print join("\n", sort keys %tables) . "\n";
1079
-    return $self;
1061
+  my $self = shift;
1062
+  
1063
+  my %tables;
1064
+  $self->each_table(sub { $tables{$_[1]}++ });
1065
+  print join("\n", sort keys %tables) . "\n";
1066
+  return $self;
1080 1067
 }
1081 1068
 
1082 1069
 sub type_rule {
1083
-    my $self = shift;
1084
-
1085
-    $self->{_type_rule_is_called} = 1;
1086
-    
1087
-    if (@_) {
1088
-        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1070
+  my $self = shift;
1071
+
1072
+  $self->{_type_rule_is_called} = 1;
1073
+  
1074
+  if (@_) {
1075
+    my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1076
+    
1077
+    # Into
1078
+    for my $i (1 .. 2) {
1079
+      my $into = "into$i";
1080
+      my $exists_into = exists $type_rule->{$into};
1081
+      $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1082
+      $self->{type_rule} = $type_rule;
1083
+      $self->{"_$into"} = {};
1084
+      for my $type_name (keys %{$type_rule->{$into} || {}}) {
1085
+        croak qq{type name of $into section must be lower case}
1086
+          if $type_name =~ /[A-Z]/;
1087
+      }
1088
+      
1089
+      $self->each_column(sub {
1090
+        my ($dbi, $table, $column, $column_info) = @_;
1089 1091
         
1090
-        # Into
1091
-        for my $i (1 .. 2) {
1092
-            my $into = "into$i";
1093
-            my $exists_into = exists $type_rule->{$into};
1094
-            $type_rule->{$into} = _array_to_hash($type_rule->{$into});
1095
-            $self->{type_rule} = $type_rule;
1096
-            $self->{"_$into"} = {};
1097
-            for my $type_name (keys %{$type_rule->{$into} || {}}) {
1098
-                croak qq{type name of $into section must be lower case}
1099
-                  if $type_name =~ /[A-Z]/;
1100
-            }
1092
+        my $type_name = lc $column_info->{TYPE_NAME};
1093
+        if ($type_rule->{$into} &&
1094
+            (my $filter = $type_rule->{$into}->{$type_name}))
1095
+        {
1096
+          return unless exists $type_rule->{$into}->{$type_name};
1097
+          if (defined $filter && ref $filter ne 'CODE') 
1098
+          {
1099
+            my $fname = $filter;
1100
+            croak qq{Filter "$fname" is not registered" } . _subname
1101
+              unless exists $self->filters->{$fname};
1101 1102
             
1102
-            $self->each_column(sub {
1103
-                my ($dbi, $table, $column, $column_info) = @_;
1104
-                
1105
-                my $type_name = lc $column_info->{TYPE_NAME};
1106
-                if ($type_rule->{$into} &&
1107
-                    (my $filter = $type_rule->{$into}->{$type_name}))
1108
-                {
1109
-                    return unless exists $type_rule->{$into}->{$type_name};
1110
-                    if  (defined $filter && ref $filter ne 'CODE') 
1111
-                    {
1112
-                        my $fname = $filter;
1113
-                        croak qq{Filter "$fname" is not registered" } . _subname
1114
-                          unless exists $self->filters->{$fname};
1115
-                        
1116
-                        $filter = $self->filters->{$fname};
1117
-                    }
1118
-
1119
-                    $self->{"_$into"}{key}{$table}{$column} = $filter;
1120
-                    $self->{"_$into"}{dot}{"$table.$column"} = $filter;
1121
-                }
1122
-            });
1123
-        }
1103
+            $filter = $self->filters->{$fname};
1104
+          }
1124 1105
 
1125
-        # From
1126
-        for my $i (1 .. 2) {
1127
-            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
1128
-            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
1129
-                croak qq{data type of from$i section must be lower case or number}
1130
-                  if $data_type =~ /[A-Z]/;
1131
-                my $fname = $type_rule->{"from$i"}{$data_type};
1132
-                if (defined $fname && ref $fname ne 'CODE') {
1133
-                    croak qq{Filter "$fname" is not registered" } . _subname
1134
-                      unless exists $self->filters->{$fname};
1135
-                    
1136
-                    $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
1137
-                }
1138
-            }
1106
+          $self->{"_$into"}{key}{$table}{$column} = $filter;
1107
+          $self->{"_$into"}{dot}{"$table.$column"} = $filter;
1139 1108
         }
1140
-        
1141
-        return $self;
1109
+      });
1110
+    }
1111
+
1112
+    # From
1113
+    for my $i (1 .. 2) {
1114
+      $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
1115
+      for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
1116
+        croak qq{data type of from$i section must be lower case or number}
1117
+          if $data_type =~ /[A-Z]/;
1118
+        my $fname = $type_rule->{"from$i"}{$data_type};
1119
+        if (defined $fname && ref $fname ne 'CODE') {
1120
+          croak qq{Filter "$fname" is not registered" } . _subname
1121
+            unless exists $self->filters->{$fname};
1122
+          
1123
+          $type_rule->{"from$i"}{$data_type} = $self->filters->{$fname};
1124
+        }
1125
+      }
1142 1126
     }
1143 1127
     
1144
-    return $self->{type_rule} || {};
1128
+    return $self;
1129
+  }
1130
+  
1131
+  return $self->{type_rule} || {};
1145 1132
 }
1146 1133
 
1147 1134
 sub update {
1148
-    my $self = shift;
1149
-
1150
-    # Options
1151
-    my $param = @_ % 2 ? shift : undef;
1152
-    my %opt = @_;
1153
-    warn "update param option is DEPRECATED!" if $opt{param};
1154
-    warn "update method where_param option is DEPRECATED!"
1155
-      if $opt{where_param};
1156
-    $param ||= $opt{param} || {};
1157
-    
1158
-    # Don't allow update all rows
1159
-    croak qq{update method where option must be specified } . _subname
1160
-      if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1161
-    
1162
-    # Timestamp(DEPRECATED!)
1163
-    if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
1164
-        warn "update timestamp option is DEPRECATED! use updated_at and now method";
1165
-        my $columns = $update_timestamp->[0];
1166
-        $columns = [$columns] unless ref $columns eq 'ARRAY';
1167
-        my $value = $update_timestamp->[1];
1168
-        $value = $value->() if ref $value eq 'CODE';
1169
-        $param->{$_} = $value for @$columns;
1170
-    }
1171
-
1172
-    # Created time and updated time
1173
-    my @timestamp_cleanup;
1174
-    if (defined $opt{updated_at}) {
1175
-        my $now = $self->now;
1176
-        $now = $now->() if ref $now eq 'CODE';
1177
-        $param->{$opt{updated_at}} = $self->now->();
1178
-        push @timestamp_cleanup, $opt{updated_at};
1179
-    }
1180
-
1181
-    # Assign clause
1182
-    my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
1183
-    
1184
-    # Where
1185
-    my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1186
-      delete $opt{id}, $opt{primary_key}, $opt{table});
1187
-    
1188
-    # Update statement
1189
-    my $sql = "update ";
1190
-    $sql .= "$opt{prefix} " if defined $opt{prefix};
1191
-    $sql .= $self->q($opt{table}) . " set $assign_clause $w->{clause} ";
1192
-    
1193
-    # Execute query
1194
-    $opt{statement} = 'update';
1195
-    $opt{cleanup} = \@timestamp_cleanup;
1196
-    $self->execute($sql, [$param, $w->{param}], %opt);
1135
+  my $self = shift;
1136
+
1137
+  # Options
1138
+  my $param = @_ % 2 ? shift : undef;
1139
+  my %opt = @_;
1140
+  warn "update param option is DEPRECATED!" if $opt{param};
1141
+  warn "update method where_param option is DEPRECATED!"
1142
+    if $opt{where_param};
1143
+  $param ||= $opt{param} || {};
1144
+  
1145
+  # Don't allow update all rows
1146
+  croak qq{update method where option must be specified } . _subname
1147
+    if !$opt{where} && !defined $opt{id} && !$opt{allow_update_all};
1148
+  
1149
+  # Timestamp(DEPRECATED!)
1150
+  if ($opt{timestamp} && (my $update_timestamp = $self->update_timestamp)) {
1151
+    warn "update timestamp option is DEPRECATED! use updated_at and now method";
1152
+    my $columns = $update_timestamp->[0];
1153
+    $columns = [$columns] unless ref $columns eq 'ARRAY';
1154
+    my $value = $update_timestamp->[1];
1155
+    $value = $value->() if ref $value eq 'CODE';
1156
+    $param->{$_} = $value for @$columns;
1157
+  }
1158
+
1159
+  # Created time and updated time
1160
+  my @timestamp_cleanup;
1161
+  if (defined $opt{updated_at}) {
1162
+    my $now = $self->now;
1163
+    $now = $now->() if ref $now eq 'CODE';
1164
+    $param->{$opt{updated_at}} = $self->now->();
1165
+    push @timestamp_cleanup, $opt{updated_at};
1166
+  }
1167
+
1168
+  # Assign clause
1169
+  my $assign_clause = $self->assign_clause($param, {wrap => $opt{wrap}});
1170
+  
1171
+  # Where
1172
+  my $w = $self->_where_clause_and_param($opt{where}, $opt{where_param},
1173
+    delete $opt{id}, $opt{primary_key}, $opt{table});
1174
+  
1175
+  # Update statement
1176
+  my $sql = "update ";
1177
+  $sql .= "$opt{prefix} " if defined $opt{prefix};
1178
+  $sql .= $self->q($opt{table}) . " set $assign_clause $w->{clause} ";
1179
+  
1180
+  # Execute query
1181
+  $opt{statement} = 'update';
1182
+  $opt{cleanup} = \@timestamp_cleanup;
1183
+  $self->execute($sql, [$param, $w->{param}], %opt);
1197 1184
 }
1198 1185
 
1199 1186
 sub update_all { shift->update(@_, allow_update_all => 1) };
1200 1187
 
1201 1188
 sub update_or_insert {
1202
-    my ($self, $param, %opt) = @_;
1203
-    croak "update_or_insert method need primary_key and id option "
1204
-      unless defined $opt{id} && defined $opt{primary_key};
1205
-    my $statement_opt = $opt{option} || {};
1206
-
1207
-    my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
1208
-    if (@$rows == 0) {
1209
-        return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
1210
-    }
1211
-    elsif (@$rows == 1) {
1212
-        return 0 unless keys %$param;
1213
-        return $self->update($param, %opt, %{$statement_opt->{update} || {}});
1214
-    }
1215
-    else {
1216
-        croak "selected row must be one " . _subname;
1217
-    }
1189
+  my ($self, $param, %opt) = @_;
1190
+  croak "update_or_insert method need primary_key and id option "
1191
+    unless defined $opt{id} && defined $opt{primary_key};
1192
+  my $statement_opt = $opt{option} || {};
1193
+
1194
+  my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
1195
+  if (@$rows == 0) {
1196
+    return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
1197
+  }
1198
+  elsif (@$rows == 1) {
1199
+    return 0 unless keys %$param;
1200
+    return $self->update($param, %opt, %{$statement_opt->{update} || {}});
1201
+  }
1202
+  else { croak "selected row must be one " . _subname }
1218 1203
 }
1219 1204
 
1220 1205
 sub update_timestamp {
1221
-    my $self = shift;
1206
+  my $self = shift;
1207
+  
1208
+  warn "update_timestamp method is DEPRECATED! use now method";
1209
+  
1210
+  if (@_) {
1211
+    $self->{update_timestamp} = [@_];
1222 1212
     
1223
-    warn "update_timestamp method is DEPRECATED! use now method";
1224
-    
1225
-    if (@_) {
1226
-        $self->{update_timestamp} = [@_];
1227
-        
1228
-        return $self;
1229
-    }
1230
-    return $self->{update_timestamp};
1213
+    return $self;
1214
+  }
1215
+  return $self->{update_timestamp};
1231 1216
 }
1232 1217
 
1233 1218
 sub values_clause {
1234
-    my ($self, $param, $opts) = @_;
1235
-    
1236
-    my $wrap = $opts->{wrap} || {};
1237
-    
1238
-    # Create insert parameter tag
1239
-    my ($q, $p) = split //, $self->q('');
1240
-    
1241
-    # values clause(performance is important)
1242
-    '(' .
1243
-    join(
1244
-      ', ',
1245
-      map { "$q$_$p" } sort keys %$param
1246
-    ) .
1247
-    ') values (' .
1248
-    join(
1249
-      ', ',
1250
-      map {
1251
-          ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1252
-          $wrap->{$_} ? $wrap->{$_}->(":$_") :
1253
-          ":$_";
1254
-      } sort keys %$param
1255
-    ) .
1256
-    ')'
1219
+  my ($self, $param, $opts) = @_;
1220
+  
1221
+  my $wrap = $opts->{wrap} || {};
1222
+  
1223
+  # Create insert parameter tag
1224
+  my ($q, $p) = split //, $self->q('');
1225
+  
1226
+  # values clause(performance is important)
1227
+  '(' .
1228
+  join(
1229
+    ', ',
1230
+    map { "$q$_$p" } sort keys %$param
1231
+  ) .
1232
+  ') values (' .
1233
+  join(
1234
+    ', ',
1235
+    map {
1236
+      ref $param->{$_} eq 'SCALAR' ? ${$param->{$_}} :
1237
+      $wrap->{$_} ? $wrap->{$_}->(":$_") :
1238
+      ":$_";
1239
+    } sort keys %$param
1240
+  ) .
1241
+  ')'
1257 1242
 }
1258 1243
 
1259 1244
 sub _multi_values_clause {
1260
-    my ($self, $params, $opts) = @_;
1261
-    
1262
-    my $wrap = $opts->{wrap} || {};
1263
-    
1264
-    # Create insert parameter tag
1265
-    my ($q, $p) = split //, $self->q('');
1266
-    
1267
-    # Multi values clause
1268
-    my $clause = '(' . join(', ', map { "$q$_$p" } sort keys %{$params->[0]}) . ') values ';
1269
-    
1270
-    for (1 .. @$params) {
1271
-        $clause .= '(' . join(', ', 
1272
-          map {
1273
-              ref $params->[0]->{$_} eq 'SCALAR' ? ${$params->[0]->{$_}} :
1274
-              $wrap->{$_} ? $wrap->{$_}->(":$_") :
1275
-              ":$_";
1276
-          } sort keys %{$params->[0]}
1277
-        ) . '), '
1278
-    }
1279
-    $clause =~ s/, $//;
1280
-    return $clause;
1245
+  my ($self, $params, $opts) = @_;
1246
+  
1247
+  my $wrap = $opts->{wrap} || {};
1248
+  
1249
+  # Create insert parameter tag
1250
+  my ($q, $p) = split //, $self->q('');
1251
+  
1252
+  # Multi values clause
1253
+  my $clause = '(' . join(', ', map { "$q$_$p" } sort keys %{$params->[0]}) . ') values ';
1254
+  
1255
+  for (1 .. @$params) {
1256
+    $clause .= '(' . join(', ', 
1257
+      map {
1258
+        ref $params->[0]->{$_} eq 'SCALAR' ? ${$params->[0]->{$_}} :
1259
+        $wrap->{$_} ? $wrap->{$_}->(":$_") :
1260
+        ":$_";
1261
+      } sort keys %{$params->[0]}
1262
+    ) . '), '
1263
+  }
1264
+  $clause =~ s/, $//;
1265
+  return $clause;
1281 1266
 }
1282 1267
 
1283 1268
 sub where { DBIx::Custom::Where->new(dbi => shift, @_) }
1284 1269
 
1285 1270
 sub _create_query {
1286
-    
1287
-    my ($self, $source, $after_build_sql) = @_;
1288
-    
1289
-    # Cache
1290
-    my $cache = $self->{cache};
1291
-    
1292
-    # Query
1293
-    my $query;
1294
-    
1295
-    # Get cached query
1296
-    if ($cache) {
1297
-        
1298
-        # Get query
1299
-        my $q = $self->cache_method->($self, $source);
1300
-        
1301
-        # Create query
1302
-        if ($q) {
1303
-            $query = DBIx::Custom::Query->new($q);
1304
-            $query->{filters} = $self->filters;
1305
-        }
1306
-    }
1271
+  
1272
+  my ($self, $source, $after_build_sql) = @_;
1273
+  
1274
+  # Cache
1275
+  my $cache = $self->{cache};
1276
+  
1277
+  # Query
1278
+  my $query;
1279
+  
1280
+  # Get cached query
1281
+  if ($cache) {
1282
+    
1283
+    # Get query
1284
+    my $q = $self->cache_method->($self, $source);
1307 1285
     
1308 1286
     # Create query
1309
-    unless ($query) {
1310
-
1311
-        # Create query
1312
-        my $tag_parse = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
1313
-          ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->{tag_parse};
1314
-
1315
-        my $sql = " " . $source || '';
1316
-        if ($tag_parse && ($sql =~ /\s\{/)) {
1317
-            $query = $self->query_builder->build_query($sql);
1318
-        }
1319
-        else {
1320
-            my @columns;
1321
-            my $c = $self->{safety_character};
1322
-            my $re = $c eq 'a-zA-Z0-9_'
1323
-              ? qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/so
1324
-              : qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
1325
-            my %duplicate;
1326
-            my $duplicate;
1327
-            # Parameter regex
1328
-            $sql =~ s/([0-9]):/$1\\:/g;
1329
-            my $new_sql = '';
1330
-            while ($sql =~ /$re/) {
1331
-                push @columns, $2;
1332
-                $duplicate = 1 if ++$duplicate{$columns[-1]} > 1;
1333
-                ($new_sql, $sql) = defined $3 ?
1334
-                  ($new_sql . "$1$2 $3 ?", " $4") : ($new_sql . "$1?", " $4");
1335
-            }
1336
-            $new_sql .= $sql;
1337
-            $new_sql =~ s/\\:/:/g if index($new_sql, "\\:") != -1;
1338
-
1339
-            # Create query
1340
-            $query = {sql => $new_sql, columns => \@columns, duplicate => $duplicate};
1341
-        }
1342
-        
1343
-        # Save query to cache
1344
-        $self->cache_method->(
1345
-            $self, $source,
1346
-            {
1347
-                sql     => $query->{sql}, 
1348
-                columns => $query->{columns},
1349
-                tables  => $query->{tables} || []
1350
-            }
1351
-        ) if $cache;
1287
+    if ($q) {
1288
+      $query = DBIx::Custom::Query->new($q);
1289
+      $query->{filters} = $self->filters;
1352 1290
     }
1291
+  }
1292
+  
1293
+  # Create query
1294
+  unless ($query) {
1353 1295
 
1354
-    # Filter SQL
1355
-    $query->{sql} = $after_build_sql->($query->{sql}) if $after_build_sql;
1356
-    
1357
-    # Save sql
1358
-    $self->{last_sql} = $query->{sql};
1359
-    
1360
-    # Prepare statement handle
1361
-    my $sth;
1362
-    eval { $sth = $self->dbh->prepare($query->{sql}) };
1363
-    
1364
-    if ($@) {
1365
-        $self->_croak($@, qq{. Following SQL is executed.\n}
1366
-                        . qq{$query->{sql}\n} . _subname);
1296
+    # Create query
1297
+    my $tag_parse = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
1298
+      ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->{tag_parse};
1299
+
1300
+    my $sql = " " . $source || '';
1301
+    if ($tag_parse && ($sql =~ /\s\{/)) {
1302
+      $query = $self->query_builder->build_query($sql);
1367 1303
     }
1368
-    
1369
-    # Set statement handle
1370
-    $query->{sth} = $sth;
1371
-    
1372
-    # Set filters
1373
-    $query->{filters} = $self->{filters} || $self->filters;
1374
-    
1375
-    return $query;
1304
+    else {
1305
+      my @columns;
1306
+      my $c = $self->{safety_character};
1307
+      my $re = $c eq 'a-zA-Z0-9_'
1308
+        ? qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/so
1309
+        : qr/(.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
1310
+      my %duplicate;
1311
+      my $duplicate;
1312
+      # Parameter regex
1313
+      $sql =~ s/([0-9]):/$1\\:/g;
1314
+      my $new_sql = '';
1315
+      while ($sql =~ /$re/) {
1316
+        push @columns, $2;
1317
+        $duplicate = 1 if ++$duplicate{$columns[-1]} > 1;
1318
+        ($new_sql, $sql) = defined $3 ?
1319
+          ($new_sql . "$1$2 $3 ?", " $4") : ($new_sql . "$1?", " $4");
1320
+      }
1321
+      $new_sql .= $sql;
1322
+      $new_sql =~ s/\\:/:/g if index($new_sql, "\\:") != -1;
1323
+
1324
+      # Create query
1325
+      $query = {sql => $new_sql, columns => \@columns, duplicate => $duplicate};
1326
+    }
1327
+    
1328
+    # Save query to cache
1329
+    $self->cache_method->(
1330
+      $self, $source,
1331
+      {
1332
+        sql     => $query->{sql}, 
1333
+        columns => $query->{columns},
1334
+        tables  => $query->{tables} || []
1335
+      }
1336
+    ) if $cache;
1337
+  }
1338
+
1339
+  # Filter SQL
1340
+  $query->{sql} = $after_build_sql->($query->{sql}) if $after_build_sql;
1341
+  
1342
+  # Save sql
1343
+  $self->{last_sql} = $query->{sql};
1344
+  
1345
+  # Prepare statement handle
1346
+  my $sth;
1347
+  eval { $sth = $self->dbh->prepare($query->{sql}) };
1348
+  
1349
+  if ($@) {
1350
+    $self->_croak($@, qq{. Following SQL is executed.\n}
1351
+                    . qq{$query->{sql}\n} . _subname);
1352
+  }
1353
+  
1354
+  # Set statement handle
1355
+  $query->{sth} = $sth;
1356
+  
1357
+  # Set filters
1358
+  $query->{filters} = $self->{filters} || $self->filters;
1359
+  
1360
+  return $query;
1376 1361
 }
1377 1362
 
1378
-sub _create_bind_values {
1379
-    my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
1380
-    
1381
-    $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1382
-    
1383
-    # Create bind values
1384
-    my @bind;
1385
-    my @types;
1386
-    my %count;
1387
-    my %not_exists;
1388
-    for my $column (@$columns) {
1389
-        
1390
-        # Bind value
1391
-        if(ref $params->{$column} eq 'ARRAY') {
1392
-            my $i = $count{$column} || 0;
1393
-            $i += $not_exists{$column} || 0;
1394
-            my $found;
1395
-            for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1396
-                if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
1397
-                    $not_exists{$column}++;
1398
-                }
1399
-                else  {
1400
-                    push @bind, $params->{$column}->[$k];
1401
-                    $found = 1;
1402
-                    last
1403
-                }
1404
-            }
1405
-            next unless $found;
1406
-        }
1407
-        else { push @bind, $params->{$column} }
1408
-        
1409
-        # Filter
1410
-        if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
1411
-            $bind[-1] = $f->($bind[-1]);
1363
+sub _create_bind_values {
1364
+  my ($self, $params, $columns, $filter, $type_filters, $bind_type) = @_;
1365
+  
1366
+  $bind_type = _array_to_hash($bind_type) if ref $bind_type eq 'ARRAY';
1367
+  
1368
+  # Create bind values
1369
+  my @bind;
1370
+  my @types;
1371
+  my %count;
1372
+  my %not_exists;
1373
+  for my $column (@$columns) {
1374
+    
1375
+    # Bind value
1376
+    if(ref $params->{$column} eq 'ARRAY') {
1377
+      my $i = $count{$column} || 0;
1378
+      $i += $not_exists{$column} || 0;
1379
+      my $found;
1380
+      for (my $k = $i; $i < @{$params->{$column}}; $k++) {
1381
+        if (ref $params->{$column}->[$k] eq 'DBIx::Custom::NotExists') {
1382
+            $not_exists{$column}++;
1412 1383
         }
1413
-        
1414
-        # Type rule
1415
-        if ($self->{_type_rule_is_called}) {
1416
-            my $tf1 = $self->{"_into1"}->{dot}->{$column}
1417
-              || $type_filters->{1}->{$column};
1418
-            $bind[-1] = $tf1->($bind[-1]) if $tf1;
1419
-            my $tf2 = $self->{"_into2"}->{dot}->{$column}
1420
-              || $type_filters->{2}->{$column};
1421
-            $bind[-1] = $tf2->($bind[-1]) if $tf2;
1384
+        else  {
1385
+          push @bind, $params->{$column}->[$k];
1386
+          $found = 1;
1387
+          last
1422 1388
         }
1423
-       
1424
-        # Bind types
1425
-        push @types, $bind_type->{$column};
1426
-        
1427
-        # Count up 
1428
-        $count{$column}++;
1389
+      }
1390
+      next unless $found;
1429 1391
     }
1392
+    else { push @bind, $params->{$column} }
1430 1393
     
1431
-    return (\@bind, \@types);
1432
-}
1433
-
1434
-sub _id_to_param {
1435
-    my ($self, $id, $primary_keys, $table) = @_;
1436
-    
1437
-    # Check primary key
1438
-    croak "primary_key option " .
1439
-          "must be specified when id option is used" . _subname
1440
-      unless defined $primary_keys;
1441
-    $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
1394
+    # Filter
1395
+    if (my $f = $filter->{$column} || $self->{default_out_filter} || '') {
1396
+      $bind[-1] = $f->($bind[-1]);
1397
+    }
1442 1398
     
1443
-    # Create parameter
1444
-    my $param = {};
1445
-    if (defined $id) {
1446
-        $id = [$id] unless ref $id;
1447
-        for(my $i = 0; $i < @$id; $i++) {
1448
-           my $key = $primary_keys->[$i];
1449
-           $key = "$table." . $key if $table;
1450
-           $param->{$key} = $id->[$i];
1451
-        }
1399
+    # Type rule
1400
+    if ($self->{_type_rule_is_called}) {
1401
+      my $tf1 = $self->{"_into1"}->{dot}->{$column}
1402
+        || $type_filters->{1}->{$column};
1403
+      $bind[-1] = $tf1->($bind[-1]) if $tf1;
1404
+      my $tf2 = $self->{"_into2"}->{dot}->{$column}
1405
+        || $type_filters->{2}->{$column};
1406
+      $bind[-1] = $tf2->($bind[-1]) if $tf2;
1452 1407
     }
1408
+   
1409
+    # Bind types
1410
+    push @types, $bind_type->{$column};
1453 1411
     
1454
-    return $param;
1412
+    # Count up 
1413
+    $count{$column}++;
1414
+  }
1415
+  
1416
+  return (\@bind, \@types);
1417
+}
1418
+
1419
+sub _id_to_param {
1420
+  my ($self, $id, $primary_keys, $table) = @_;
1421
+  
1422
+  # Check primary key
1423
+  croak "primary_key option " .
1424
+        "must be specified when id option is used" . _subname
1425
+    unless defined $primary_keys;
1426
+  $primary_keys = [$primary_keys] unless ref $primary_keys eq 'ARRAY';
1427
+  
1428
+  # Create parameter
1429
+  my $param = {};
1430
+  if (defined $id) {
1431
+    $id = [$id] unless ref $id;
1432
+    for(my $i = 0; $i < @$id; $i++) {
1433
+      my $key = $primary_keys->[$i];
1434
+      $key = "$table." . $key if $table;
1435
+      $param->{$key} = $id->[$i];
1436
+    }
1437
+  }
1438
+  
1439
+  return $param;
1455 1440
 }
1456 1441
 
1457 1442
 sub _connect {
1458
-    my $self = shift;
1459
-    
1460
-    # Attributes
1461
-    my $dsn = $self->data_source;
1462
-    warn "data_source is DEPRECATED!\n"
1463
-      if $dsn;
1464
-    $dsn ||= $self->dsn;
1465
-    croak qq{"dsn" must be specified } . _subname
1466
-      unless $dsn;
1467
-    my $user        = $self->user;
1468
-    my $password    = $self->password;
1469
-    my $option = $self->_option;
1470
-    $option = {%{$self->default_option}, %$option};
1471
-    
1472
-    # Connect
1473
-    my $dbh;
1474
-    eval {
1475
-        $dbh = DBI->connect(
1476
-            $dsn,
1477
-            $user,
1478
-            $password,
1479
-            $option
1480
-        );
1481
-    };
1482
-    
1483
-    # Connect error
1484
-    croak "$@ " . _subname if $@;
1485
-    
1486
-    return $dbh;
1443
+  my $self = shift;
1444
+  
1445
+  # Attributes
1446
+  my $dsn = $self->data_source;
1447
+  warn "data_source is DEPRECATED!\n"
1448
+    if $dsn;
1449
+  $dsn ||= $self->dsn;
1450
+  croak qq{"dsn" must be specified } . _subname
1451
+    unless $dsn;
1452
+  my $user        = $self->user;
1453
+  my $password    = $self->password;
1454
+  my $option = $self->_option;
1455
+  $option = {%{$self->default_option}, %$option};
1456
+  
1457
+  # Connect
1458
+  my $dbh;
1459
+  eval { $dbh = DBI->connect($dsn, $user, $password, $option) };
1460
+  
1461
+  # Connect error
1462
+  croak "$@ " . _subname if $@;
1463
+  
1464
+  return $dbh;
1487 1465
 }
1488 1466
 
1489 1467
 sub _croak {
1490
-    my ($self, $error, $append) = @_;
1491
-    
1492
-    # Append
1493
-    $append ||= "";
1494
-    
1495
-    # Verbose
1496
-    if ($Carp::Verbose) { croak $error }
1497
-    
1498
-    # Not verbose
1499
-    else {
1500
-        
1501
-        # Remove line and module infromation
1502
-        my $at_pos = rindex($error, ' at ');
1503
-        $error = substr($error, 0, $at_pos);
1504
-        $error =~ s/\s+$//;
1505
-        croak "$error$append";
1506
-    }
1468
+  my ($self, $error, $append) = @_;
1469
+  
1470
+  # Append
1471
+  $append ||= "";
1472
+  
1473
+  # Verbose
1474
+  if ($Carp::Verbose) { croak $error }
1475
+  
1476
+  # Not verbose
1477
+  else {
1478
+    # Remove line and module infromation
1479
+    my $at_pos = rindex($error, ' at ');
1480
+    $error = substr($error, 0, $at_pos);
1481
+    $error =~ s/\s+$//;
1482
+    croak "$error$append";
1483
+  }
1507 1484
 }
1508 1485
 
1509 1486
 sub _driver { lc shift->{dbh}->{Driver}->{Name} }
1510 1487
 
1511 1488
 sub _need_tables {
1512
-    my ($self, $tree, $need_tables, $tables) = @_;
1513
-    
1514
-    # Get needed tables
1515
-    for my $table (@$tables) {
1516
-        if ($tree->{$table}) {
1517
-            $need_tables->{$table} = 1;
1518
-            $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1519
-        }
1489
+  my ($self, $tree, $need_tables, $tables) = @_;
1490
+  
1491
+  # Get needed tables
1492
+  for my $table (@$tables) {
1493
+    if ($tree->{$table}) {
1494
+      $need_tables->{$table} = 1;
1495
+      $self->_need_tables($tree, $need_tables, [$tree->{$table}{parent}])
1520 1496
     }
1497
+  }
1521 1498
 }
1522 1499
 
1523 1500
 sub _option {
1524
-    my $self = shift;
1525
-    my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1526
-    warn "dbi_options is DEPRECATED! use option instead\n"
1527
-      if keys %{$self->dbi_options};
1528
-    warn "dbi_option is DEPRECATED! use option instead\n"
1529
-      if keys %{$self->dbi_option};
1530
-    return $option;
1501
+  my $self = shift;
1502
+  my $option = {%{$self->dbi_options}, %{$self->dbi_option}, %{$self->option}};
1503
+  warn "dbi_options is DEPRECATED! use option instead\n"
1504
+    if keys %{$self->dbi_options};
1505
+  warn "dbi_option is DEPRECATED! use option instead\n"
1506
+    if keys %{$self->dbi_option};
1507
+  return $option;
1531 1508
 }
1532 1509
 
1533 1510
 sub _push_join {
1534
-    my ($self, $sql, $join, $join_tables) = @_;
1535
-    
1536
-    $join = [$join] unless ref $join eq 'ARRAY';
1537
-    
1538
-    # No join
1539
-    return unless @$join;
1540
-    
1541
-    # Push join clause
1542
-    my $tree = {};
1543
-    for (my $i = 0; $i < @$join; $i++) {
1544
-        
1545
-        # Arrange
1546
-        my $join_clause;;
1547
-        my $option;
1548
-        if (ref $join->[$i] eq 'HASH') {
1549
-            $join_clause = $join->[$i]->{clause};
1550
-            $option = {table => $join->[$i]->{table}};
1551
-        }
1552
-        else {
1553
-            $join_clause = $join->[$i];
1554
-            $option = {};
1555
-        };
1556
-
1557
-        # Find tables in join clause
1558
-        my $table1;
1559
-        my $table2;
1560
-        if (my $table = $option->{table}) {
1561
-            $table1 = $table->[0];
1562
-            $table2 = $table->[1];
1563
-        }
1564
-        else {
1565
-            my $q = $self->_quote;
1566
-            my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1567
-            $j_clause =~ s/'.+?'//g;
1568
-            my $q_re = quotemeta($q);
1569
-            $j_clause =~ s/[$q_re]//g;
1570
-            
1571
-            my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
1572
-            my $c = $self->{safety_character};
1573
-            my $join_re = qr/([$c]+)\.[$c]+[^$c].*?([$c]+)\.[$c]+/sm;
1574
-            for my $clause (@j_clauses) {
1575
-                if ($clause =~ $join_re) {
1576
-                    $table1 = $1;
1577
-                    $table2 = $2;
1578
-                    last;
1579
-                }                
1580
-            }
1581
-        }
1582
-        croak qq{join clause must have two table name after "on" keyword. } .
1583
-              qq{"$join_clause" is passed }  . _subname
1584
-          unless defined $table1 && defined $table2;
1585
-        croak qq{right side table of "$join_clause" must be unique }
1586
-            . _subname
1587
-          if exists $tree->{$table2};
1588
-        croak qq{Same table "$table1" is specified} . _subname
1589
-          if $table1 eq $table2;
1590
-        $tree->{$table2}
1591
-          = {position => $i, parent => $table1, join => $join_clause};
1511
+  my ($self, $sql, $join, $join_tables) = @_;
1512
+  
1513
+  $join = [$join] unless ref $join eq 'ARRAY';
1514
+  
1515
+  # No join
1516
+  return unless @$join;
1517
+  
1518
+  # Push join clause
1519
+  my $tree = {};
1520
+  for (my $i = 0; $i < @$join; $i++) {
1521
+    
1522
+    # Arrange
1523
+    my $join_clause;;
1524
+    my $option;
1525
+    if (ref $join->[$i] eq 'HASH') {
1526
+      $join_clause = $join->[$i]->{clause};
1527
+      $option = {table => $join->[$i]->{table}};
1592 1528
     }
1593
-    
1594
-    # Search need tables
1595
-    my $need_tables = {};
1596
-    $self->_need_tables($tree, $need_tables, $join_tables);
1597
-    my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1598
-      keys %$need_tables;
1599
-    
1600
-    # Add join clause
1601
-    $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
1529
+    else {
1530
+      $join_clause = $join->[$i];
1531
+      $option = {};
1532
+    };
1533
+
1534
+    # Find tables in join clause
1535
+    my $table1;
1536
+    my $table2;
1537
+    if (my $table = $option->{table}) {
1538
+      $table1 = $table->[0];
1539
+      $table2 = $table->[1];
1540
+    }
1541
+    else {
1542
+      my $q = $self->_quote;
1543
+      my $j_clause = (split /\s+on\s+/, $join_clause)[-1];
1544
+      $j_clause =~ s/'.+?'//g;
1545
+      my $q_re = quotemeta($q);
1546
+      $j_clause =~ s/[$q_re]//g;
1547
+      
1548
+      my @j_clauses = reverse split /\s(and|on)\s/, $j_clause;
1549
+      my $c = $self->{safety_character};
1550
+      my $join_re = qr/([$c]+)\.[$c]+[^$c].*?([$c]+)\.[$c]+/sm;
1551
+      for my $clause (@j_clauses) {
1552
+        if ($clause =~ $join_re) {
1553
+          $table1 = $1;
1554
+          $table2 = $2;
1555
+          last;
1556
+        }                
1557
+      }
1558
+    }
1559
+    croak qq{join clause must have two table name after "on" keyword. } .
1560
+        qq{"$join_clause" is passed }  . _subname
1561
+      unless defined $table1 && defined $table2;
1562
+    croak qq{right side table of "$join_clause" must be unique } . _subname
1563
+      if exists $tree->{$table2};
1564
+    croak qq{Same table "$table1" is specified} . _subname
1565
+      if $table1 eq $table2;
1566
+    $tree->{$table2}
1567
+      = {position => $i, parent => $table1, join => $join_clause};
1568
+  }
1569
+  
1570
+  # Search need tables
1571
+  my $need_tables = {};
1572
+  $self->_need_tables($tree, $need_tables, $join_tables);
1573
+  my @need_tables = sort { $tree->{$a}{position} <=> $tree->{$b}{position} }
1574
+    keys %$need_tables;
1575
+  
1576
+  # Add join clause
1577
+  $$sql .= $tree->{$_}{join} . ' ' for @need_tables;
1602 1578
 }
1603 1579
 
1604 1580
 sub _quote {
1605
-    my $self = shift;
1606
-    return $self->{reserved_word_quote} || $self->quote || '';
1581
+  my $self = shift;
1582
+  return $self->{reserved_word_quote} || $self->quote || '';
1607 1583
 }
1608 1584
 
1609 1585
 sub _remove_duplicate_table {
1610
-    my ($self, $tables, $main_table) = @_;
1611
-    
1612
-    # Remove duplicate table
1613
-    my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1614
-    delete $tables{$main_table} if $main_table;
1615
-    
1616
-    my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1617
-    if (my $q = $self->_quote) {
1618
-        $q = quotemeta($q);
1619
-        $_ =~ s/[$q]//g for @$new_tables;
1620
-    }
1586
+  my ($self, $tables, $main_table) = @_;
1587
+  
1588
+  # Remove duplicate table
1589
+  my %tables = map {defined $_ ? ($_ => 1) : ()} @$tables;
1590
+  delete $tables{$main_table} if $main_table;
1591
+  
1592
+  my $new_tables = [keys %tables, $main_table ? $main_table : ()];
1593
+  if (my $q = $self->_quote) {
1594
+    $q = quotemeta($q);
1595
+    $_ =~ s/[$q]//g for @$new_tables;
1596
+  }
1621 1597
 
1622
-    return $new_tables;
1598
+  return $new_tables;
1623 1599
 }
1624 1600
 
1625 1601
 sub _search_tables {
1626
-    my ($self, $source) = @_;
1627
-    
1628
-    # Search tables
1629
-    my $tables = [];
1630
-    my $safety_character = $self->{safety_character};
1631
-    my $q = $self->_quote;
1632
-    my $quoted_safety_character_re = $self->q("?([$safety_character]+)", 1);
1633
-    my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
1634
-                      : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
1635
-    while ($source =~ /$table_re/g) {
1636
-        push @$tables, $1;
1637
-    }
1638
-    
1639
-    return $tables;
1602
+  my ($self, $source) = @_;
1603
+  
1604
+  # Search tables
1605
+  my $tables = [];
1606
+  my $safety_character = $self->{safety_character};
1607
+  my $q = $self->_quote;
1608
+  my $quoted_safety_character_re = $self->q("?([$safety_character]+)", 1);
1609
+  my $table_re = $q ? qr/(?:^|[^$safety_character])${quoted_safety_character_re}?\./
1610
+    : qr/(?:^|[^$safety_character])([$safety_character]+)\./;
1611
+  while ($source =~ /$table_re/g) { push @$tables, $1 }
1612
+  return $tables;
1640 1613
 }
1641 1614
 
1642 1615
 sub _where_clause_and_param {
1643
-    my ($self, $where, $where_param, $id, $primary_key, $table) = @_;
1644
-
1645
-    $where ||= {};
1646
-    $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
1647
-    $where_param ||= {};
1648
-    my $w = {};
1649
-    my $where_clause = '';
1650
-
1651
-    my $obj;
1652
-    
1653
-    if (ref $where) {
1654
-        if (ref $where eq 'HASH') {
1655
-            my $clause = ['and'];
1656
-            my $column_join = '';
1657
-            for my $column (keys %$where) {
1658
-                $column_join .= $column;
1659
-                my $table;
1660
-                my $c;
1661
-                if ($column =~ /(?:(.*?)\.)?(.*)/) {
1662
-                    $table = $1;
1663
-                    $c = $2;
1664
-                }
1665
-                
1666
-                my $table_quote;
1667
-                $table_quote = $self->q($table) if defined $table;
1668
-                my $column_quote = $self->q($c);
1669
-                $column_quote = $table_quote . '.' . $column_quote
1670
-                  if defined $table_quote;
1671
-                push @$clause, "$column_quote = :$column";
1672
-            }
1673
-
1674
-            # Check unsafety column
1675
-            my $safety = $self->{safety_character};
1676
-            unless ($column_join =~ /^[$safety\.]+$/) {
1677
-                for my $column (keys %$where) {
1678
-                    croak qq{"$column" is not safety column name } . _subname
1679
-                      unless $column =~ /^[$safety\.]+$/;
1680
-                }
1681
-            }
1682
-            
1683
-            $obj = $self->where(clause => $clause, param => $where);
1684
-        }
1685
-        elsif (ref $where eq 'DBIx::Custom::Where') { $obj = $where }
1686
-        elsif (ref $where eq 'ARRAY') {
1687
-            $obj = $self->where(clause => $where->[0], param => $where->[1]);
1616
+  my ($self, $where, $where_param, $id, $primary_key, $table) = @_;
1617
+
1618
+  $where ||= {};
1619
+  $where = $self->_id_to_param($id, $primary_key, $table) if defined $id;
1620
+  $where_param ||= {};
1621
+  my $w = {};
1622
+  my $where_clause = '';
1623
+
1624
+  my $obj;
1625
+  
1626
+  if (ref $where) {
1627
+    if (ref $where eq 'HASH') {
1628
+      my $clause = ['and'];
1629
+      my $column_join = '';
1630
+      for my $column (keys %$where) {
1631
+        $column_join .= $column;
1632
+        my $table;
1633
+        my $c;
1634
+        if ($column =~ /(?:(.*?)\.)?(.*)/) {
1635
+          $table = $1;
1636
+          $c = $2;
1688 1637
         }
1689 1638
         
1690
-        # Check where argument
1691
-        croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1692
-            . qq{or array reference, which contains where clause and parameter}
1693
-            . _subname
1694
-          unless ref $obj eq 'DBIx::Custom::Where';
1695
-
1696
-        $w->{param} = keys %$where_param
1697
-                    ? $self->merge_param($where_param, $obj->param)
1698
-                    : $obj->param;
1699
-        $w->{clause} = $obj->to_string;
1700
-    }
1701
-    elsif ($where) {
1702
-        $w->{clause} = "where $where";
1703
-        $w->{param} = $where_param;
1704
-    }
1705
-    
1706
-    return $w;
1639
+        my $table_quote;
1640
+        $table_quote = $self->q($table) if defined $table;
1641
+        my $column_quote = $self->q($c);
1642
+        $column_quote = $table_quote . '.' . $column_quote
1643
+          if defined $table_quote;
1644
+        push @$clause, "$column_quote = :$column";
1645
+      }
1646
+
1647
+      # Check unsafety column
1648
+      my $safety = $self->{safety_character};
1649
+      unless ($column_join =~ /^[$safety\.]+$/) {
1650
+        for my $column (keys %$where) {
1651
+          croak qq{"$column" is not safety column name } . _subname
1652
+            unless $column =~ /^[$safety\.]+$/;
1653
+        }
1654
+      }
1655
+      
1656
+      $obj = $self->where(clause => $clause, param => $where);
1657
+    }
1658
+    elsif (ref $where eq 'DBIx::Custom::Where') { $obj = $where }
1659
+    elsif (ref $where eq 'ARRAY') {
1660
+      $obj = $self->where(clause => $where->[0], param => $where->[1]);
1661
+    }
1662
+    
1663
+    # Check where argument
1664
+    croak qq{"where" must be hash reference or DBIx::Custom::Where object}
1665
+        . qq{or array reference, which contains where clause and parameter}
1666
+        . _subname
1667
+      unless ref $obj eq 'DBIx::Custom::Where';
1668
+
1669
+    $w->{param} = keys %$where_param
1670
+      ? $self->merge_param($where_param, $obj->param)
1671
+      : $obj->param;
1672
+    $w->{clause} = $obj->to_string;
1673
+  }
1674
+  elsif ($where) {
1675
+    $w->{clause} = "where $where";
1676
+    $w->{param} = $where_param;
1677
+  }
1678
+  
1679
+  return $w;
1707 1680
 }
1708 1681
 
1709 1682
 sub _apply_filter {
1710
-    my ($self, $table, @cinfos) = @_;
1711
-
1712
-    # Initialize filters
1713
-    $self->{filter} ||= {};
1714
-    $self->{filter}{on} = 1;
1715
-    $self->{filter}{out} ||= {};
1716
-    $self->{filter}{in} ||= {};
1717
-    $self->{filter}{end} ||= {};
1683
+  my ($self, $table, @cinfos) = @_;
1684
+
1685
+  # Initialize filters
1686
+  $self->{filter} ||= {};
1687
+  $self->{filter}{on} = 1;
1688
+  $self->{filter}{out} ||= {};
1689
+  $self->{filter}{in} ||= {};
1690
+  $self->{filter}{end} ||= {};
1691
+  
1692
+  # Usage
1693
+  my $usage = "Usage: \$dbi->apply_filter(" .
1694
+    "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1695
+    "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1696
+  
1697
+  # Apply filter
1698
+  for (my $i = 0; $i < @cinfos; $i += 2) {
1718 1699
     
1719
-    # Usage
1720
-    my $usage = "Usage: \$dbi->apply_filter(" .
1721
-                "TABLE, COLUMN1, {in => INFILTER1, out => OUTFILTER1, end => ENDFILTER1}, " .
1722
-                "COLUMN2, {in => INFILTER2, out => OUTFILTER2, end => ENDFILTER2}, ...)";
1700
+    # Column
1701
+    my $column = $cinfos[$i];
1702
+    if (ref $column eq 'ARRAY') {
1703
+      for my $c (@$column) { push @cinfos, $c, $cinfos[$i + 1] }
1704
+      next;
1705
+    }
1723 1706
     
1724
-    # Apply filter
1725
-    for (my $i = 0; $i < @cinfos; $i += 2) {
1726
-        
1727
-        # Column
1728
-        my $column = $cinfos[$i];
1729
-        if (ref $column eq 'ARRAY') {
1730
-            for my $c (@$column) {
1731
-                push @cinfos, $c, $cinfos[$i + 1];
1732
-            }
1733
-            next;
1734
-        }
1735
-        
1736
-        # Filter infomation
1737
-        my $finfo = $cinfos[$i + 1] || {};
1738
-        croak "$usage (table: $table) " . _subname
1739
-          unless  ref $finfo eq 'HASH';
1740
-        for my $ftype (keys %$finfo) {
1741
-            croak "$usage (table: $table) " . _subname
1742
-              unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1743
-        }
1744
-        
1745
-        # Set filters
1746
-        for my $way (qw/in out end/) {
1747
-        
1748
-            # Filter
1749
-            my $filter = $finfo->{$way};
1750
-            
1751
-            # Filter state
1752
-            my $state = !exists $finfo->{$way} ? 'not_exists'
1753
-                      : !defined $filter        ? 'not_defined'
1754
-                      : ref $filter eq 'CODE'   ? 'code'
1755
-                      : 'name';
1756
-            
1757
-            # Filter is not exists
1758
-            next if $state eq 'not_exists';
1759
-            
1760
-            # Check filter name
1761
-            croak qq{Filter "$filter" is not registered } . _subname
1762
-              if  $state eq 'name'
1763
-               && ! exists $self->filters->{$filter};
1764
-            
1765
-            # Set filter
1766
-            my $f = $state eq 'not_defined' ? undef
1767
-                  : $state eq 'code'        ? $filter
1768
-                  : $self->filters->{$filter};
1769
-            $self->{filter}{$way}{$table}{$column} = $f;
1770
-            $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1771
-            $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1772
-            $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1773
-        }
1707
+    # Filter infomation
1708
+    my $finfo = $cinfos[$i + 1] || {};
1709
+    croak "$usage (table: $table) " . _subname
1710
+      unless  ref $finfo eq 'HASH';
1711
+    for my $ftype (keys %$finfo) {
1712
+      croak "$usage (table: $table) " . _subname
1713
+        unless $ftype eq 'in' || $ftype eq 'out' || $ftype eq 'end'; 
1774 1714
     }
1775 1715
     
1776
-    return $self;
1716
+    # Set filters
1717
+    for my $way (qw/in out end/) {
1718
+  
1719
+      # Filter
1720
+      my $filter = $finfo->{$way};
1721
+      
1722
+      # Filter state
1723
+      my $state = !exists $finfo->{$way} ? 'not_exists'
1724
+        : !defined $filter        ? 'not_defined'
1725
+        : ref $filter eq 'CODE'   ? 'code'
1726
+        : 'name';
1727
+      
1728
+      # Filter is not exists
1729
+      next if $state eq 'not_exists';
1730
+      
1731
+      # Check filter name
1732
+      croak qq{Filter "$filter" is not registered } . _subname
1733
+        if  $state eq 'name' && ! exists $self->filters->{$filter};
1734
+      
1735
+      # Set filter
1736
+      my $f = $state eq 'not_defined' ? undef
1737
+        : $state eq 'code' ? $filter
1738
+        : $self->filters->{$filter};
1739
+      $self->{filter}{$way}{$table}{$column} = $f;
1740
+      $self->{filter}{$way}{$table}{"$table.$column"} = $f;
1741
+      $self->{filter}{$way}{$table}{"${table}__$column"} = $f;
1742
+      $self->{filter}{$way}{$table}{"${table}-$column"} = $f;
1743
+    }
1744
+  }
1745
+  
1746
+  return $self;
1777 1747
 }
1778 1748
 
1779 1749
 # DEPRECATED!
... ...
@@ -1783,270 +1753,270 @@ has filter_check  => 1;
1783 1753
 has 'reserved_word_quote';
1784 1754
 has dbi_option => sub { {} };
1785 1755
 has default_dbi_option => sub {
1786
-    warn "default_dbi_option is DEPRECATED! use default_option instead";
1787
-    return shift->default_option;
1756
+  warn "default_dbi_option is DEPRECATED! use default_option instead";
1757
+  return shift->default_option;
1788 1758
 };
1789 1759
 
1790 1760
 # DEPRECATED
1791 1761
 sub tag_parse {
1792
-   my $self = shift;
1793
-   warn "tag_parse is DEPRECATED! use \$ENV{DBIX_CUSTOM_TAG_PARSE} " .
1794
-         "environment variable";
1795
-    if (@_) {
1796
-        $self->{tag_parse} = $_[0];
1797
-        return $self;
1798
-    }
1799
-    return $self->{tag_parse};
1762
+ my $self = shift;
1763
+ warn "tag_parse is DEPRECATED! use \$ENV{DBIX_CUSTOM_TAG_PARSE} " .
1764
+   "environment variable";
1765
+  if (@_) {
1766
+    $self->{tag_parse} = $_[0];
1767
+    return $self;
1768
+  }
1769
+  return $self->{tag_parse};
1800 1770
 }
1801 1771
 
1802 1772
 # DEPRECATED!
1803 1773
 sub method {
1804
-    warn "method is DEPRECATED! use helper instead";
1805
-    return shift->helper(@_);
1774
+  warn "method is DEPRECATED! use helper instead";
1775
+  return shift->helper(@_);
1806 1776
 }
1807 1777
 
1808 1778
 # DEPRECATED!
1809 1779
 sub assign_param {
1810
-    my $self = shift;
1811
-    warn "assing_param is DEPRECATED! use assign_clause instead";
1812
-    return $self->assign_clause(@_);
1780
+  my $self = shift;
1781
+  warn "assing_param is DEPRECATED! use assign_clause instead";
1782
+  return $self->assign_clause(@_);
1813 1783
 }
1814 1784
 
1815 1785
 # DEPRECATED
1816 1786
 sub update_param {
1817
-    my ($self, $param, $opts) = @_;
1818
-    
1819
-    warn "update_param is DEPRECATED! use assign_clause instead.";
1820
-    
1821
-    # Create update parameter tag
1822
-    my $tag = $self->assign_clause($param, $opts);
1823
-    $tag = "set $tag" unless $opts->{no_set};
1787
+  my ($self, $param, $opts) = @_;
1788
+  
1789
+  warn "update_param is DEPRECATED! use assign_clause instead.";
1790
+  
1791
+  # Create update parameter tag
1792
+  my $tag = $self->assign_clause($param, $opts);
1793
+  $tag = "set $tag" unless $opts->{no_set};
1824 1794
 
1825
-    return $tag;
1795
+  return $tag;
1826 1796
 }
1827 1797
 
1828 1798
 # DEPRECATED!
1829 1799
 sub create_query {
1830
-    warn "create_query is DEPRECATED! use query option of each method";
1831
-    shift->_create_query(@_);
1800
+  warn "create_query is DEPRECATED! use query option of each method";
1801
+  shift->_create_query(@_);
1832 1802
 }
1833 1803
 
1834 1804
 # DEPRECATED!
1835 1805
 sub apply_filter {
1836
-    my $self = shift;
1837
-    
1838
-    warn "apply_filter is DEPRECATED!";
1839
-    return $self->_apply_filter(@_);
1806
+  my $self = shift;
1807
+  
1808
+  warn "apply_filter is DEPRECATED!";
1809
+  return $self->_apply_filter(@_);
1840 1810
 }
1841 1811
 
1842 1812
 # DEPRECATED!
1843 1813
 sub select_at {
1844
-    my ($self, %opt) = @_;
1845
-
1846
-    warn "select_at is DEPRECATED! use select method id option instead";
1847
-
1848
-    # Options
1849
-    my $primary_keys = delete $opt{primary_key};
1850
-    my $where = delete $opt{where};
1851
-    my $param = delete $opt{param};
1852
-    
1853
-    # Table
1854
-    croak qq{"table" option must be specified } . _subname
1855
-      unless $opt{table};
1856
-    my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
1857
-    
1858
-    # Create where parameter
1859
-    my $where_param = $self->_id_to_param($where, $primary_keys);
1860
-    
1861
-    return $self->select(where => $where_param, %opt);
1814
+  my ($self, %opt) = @_;
1815
+
1816
+  warn "select_at is DEPRECATED! use select method id option instead";
1817
+
1818
+  # Options
1819
+  my $primary_keys = delete $opt{primary_key};
1820
+  my $where = delete $opt{where};
1821
+  my $param = delete $opt{param};
1822
+  
1823
+  # Table
1824
+  croak qq{"table" option must be specified } . _subname
1825
+    unless $opt{table};
1826
+  my $table = ref $opt{table} ? $opt{table}->[-1] : $opt{table};
1827
+  
1828
+  # Create where parameter
1829
+  my $where_param = $self->_id_to_param($where, $primary_keys);
1830
+  
1831
+  return $self->select(where => $where_param, %opt);
1862 1832
 }
1863 1833
 
1864 1834
 # DEPRECATED!
1865 1835
 sub delete_at {
1866
-    my ($self, %opt) = @_;
1836
+  my ($self, %opt) = @_;
1867 1837
 
1868
-    warn "delete_at is DEPRECATED! use delete method id option instead";
1869
-    
1870
-    # Options
1871
-    my $primary_keys = delete $opt{primary_key};
1872
-    my $where = delete $opt{where};
1873
-    
1874
-    # Create where parameter
1875
-    my $where_param = $self->_id_to_param($where, $primary_keys);
1876
-    
1877
-    return $self->delete(where => $where_param, %opt);
1838
+  warn "delete_at is DEPRECATED! use delete method id option instead";
1839
+  
1840
+  # Options
1841
+  my $primary_keys = delete $opt{primary_key};
1842
+  my $where = delete $opt{where};
1843
+  
1844
+  # Create where parameter
1845
+  my $where_param = $self->_id_to_param($where, $primary_keys);
1846
+  
1847
+  return $self->delete(where => $where_param, %opt);
1878 1848
 }
1879 1849
 
1880 1850
 # DEPRECATED!
1881 1851
 sub update_at {
1882
-    my $self = shift;
1883
-
1884
-    warn "update_at is DEPRECATED! use update method id option instead";
1885
-    
1886
-    # Options
1887
-    my $param;
1888
-    $param = shift if @_ % 2;
1889
-    my %opt = @_;
1890
-    my $primary_keys = delete $opt{primary_key};
1891
-    my $where = delete $opt{where};
1892
-    my $p = delete $opt{param} || {};
1893
-    $param  ||= $p;
1894
-    
1895
-    # Create where parameter
1896
-    my $where_param = $self->_id_to_param($where, $primary_keys);
1897
-    
1898
-    return $self->update(where => $where_param, param => $param, %opt);
1852
+  my $self = shift;
1853
+
1854
+  warn "update_at is DEPRECATED! use update method id option instead";
1855
+  
1856
+  # Options
1857
+  my $param;
1858
+  $param = shift if @_ % 2;
1859
+  my %opt = @_;
1860
+  my $primary_keys = delete $opt{primary_key};
1861
+  my $where = delete $opt{where};
1862
+  my $p = delete $opt{param} || {};
1863
+  $param  ||= $p;
1864
+  
1865
+  # Create where parameter
1866
+  my $where_param = $self->_id_to_param($where, $primary_keys);
1867
+  
1868
+  return $self->update(where => $where_param, param => $param, %opt);
1899 1869
 }
1900 1870
 
1901 1871
 # DEPRECATED!
1902 1872
 sub insert_at {
1903
-    my $self = shift;
1904
-    
1905
-    warn "insert_at is DEPRECATED! use insert method id option instead";
1906
-    
1907
-    # Options
1908
-    my $param;
1909
-    $param = shift if @_ % 2;
1910
-    my %opt = @_;
1911
-    my $primary_key = delete $opt{primary_key};
1912
-    $primary_key = [$primary_key] unless ref $primary_key;
1913
-    my $where = delete $opt{where};
1914
-    my $p = delete $opt{param} || {};
1915
-    $param  ||= $p;
1916
-    
1917
-    # Create where parameter
1918
-    my $where_param = $self->_id_to_param($where, $primary_key);
1919
-    $param = $self->merge_param($where_param, $param);
1920
-    
1921
-    return $self->insert(param => $param, %opt);
1873
+  my $self = shift;
1874
+  
1875
+  warn "insert_at is DEPRECATED! use insert method id option instead";
1876
+  
1877
+  # Options
1878
+  my $param;
1879
+  $param = shift if @_ % 2;
1880
+  my %opt = @_;
1881
+  my $primary_key = delete $opt{primary_key};
1882
+  $primary_key = [$primary_key] unless ref $primary_key;
1883
+  my $where = delete $opt{where};
1884
+  my $p = delete $opt{param} || {};
1885
+  $param  ||= $p;
1886
+  
1887
+  # Create where parameter
1888
+  my $where_param = $self->_id_to_param($where, $primary_key);
1889
+  $param = $self->merge_param($where_param, $param);
1890
+  
1891
+  return $self->insert(param => $param, %opt);
1922 1892
 }
1923 1893
 
1924 1894
 # DEPRECATED!
1925 1895
 sub register_tag {
1926
-    my $self = shift;
1927
-    
1928
-    warn "register_tag is DEPRECATED!";
1929
-    
1930
-    # Merge tag
1931
-    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1932
-    $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1933
-    
1934
-    return $self;
1896
+  my $self = shift;
1897
+  
1898
+  warn "register_tag is DEPRECATED!";
1899
+  
1900
+  # Merge tag
1901
+  my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1902
+  $self->{_tags} = {%{$self->{_tags} || {}}, %$tags};
1903
+  
1904
+  return $self;
1935 1905
 }
1936 1906
 
1937 1907
 # DEPRECATED!
1938 1908
 sub register_tag_processor {
1939
-    my $self = shift;
1940
-    warn "register_tag_processor is DEPRECATED!";
1941
-    # Merge tag
1942
-    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1943
-    $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1944
-    return $self;
1909
+  my $self = shift;
1910
+  warn "register_tag_processor is DEPRECATED!";
1911
+  # Merge tag
1912
+  my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
1913
+  $self->{_tags} = {%{$self->{_tags} || {}}, %{$tag_processors}};
1914
+  return $self;
1945 1915
 }
1946 1916
 
1947 1917
 # DEPRECATED!
1948 1918
 sub default_bind_filter {
1949
-    my $self = shift;
1950
-    
1951
-    warn "default_bind_filter is DEPRECATED!";
1919
+  my $self = shift;
1920
+  
1921
+  warn "default_bind_filter is DEPRECATED!";
1922
+  
1923
+  if (@_) {
1924
+    my $fname = $_[0];
1952 1925
     
1953
-    if (@_) {
1954
-        my $fname = $_[0];
1955
-        
1956
-        if (@_ && !$fname) {
1957
-            $self->{default_out_filter} = undef;
1958
-        }
1959
-        else {
1960
-            croak qq{Filter "$fname" is not registered}
1961
-              unless exists $self->filters->{$fname};
1962
-        
1963
-            $self->{default_out_filter} = $self->filters->{$fname};
1964
-        }
1965
-        return $self;
1926
+    if (@_ && !$fname) {
1927
+      $self->{default_out_filter} = undef;
1966 1928
     }
1967
-    
1968
-    return $self->{default_out_filter};
1929
+    else {
1930
+      croak qq{Filter "$fname" is not registered}
1931
+        unless exists $self->filters->{$fname};
1932
+  
1933
+      $self->{default_out_filter} = $self->filters->{$fname};
1934
+    }
1935
+    return $self;
1936
+  }
1937
+  
1938
+  return $self->{default_out_filter};
1969 1939
 }
1970 1940
 
1971 1941
 # DEPRECATED!
1972 1942
 sub default_fetch_filter {
1973
-    my $self = shift;
1943
+  my $self = shift;
1974 1944
 
1975
-    warn "default_fetch_filter is DEPRECATED!";
1976
-    
1977
-    if (@_) {
1978
-        my $fname = $_[0];
1945
+  warn "default_fetch_filter is DEPRECATED!";
1946
+  
1947
+  if (@_) {
1948
+    my $fname = $_[0];
1979 1949
 
1980
-        if (@_ && !$fname) {
1981
-            $self->{default_in_filter} = undef;
1982
-        }
1983
-        else {
1984
-            croak qq{Filter "$fname" is not registered}
1985
-              unless exists $self->filters->{$fname};
1986
-        
1987
-            $self->{default_in_filter} = $self->filters->{$fname};
1988
-        }
1989
-        
1990
-        return $self;
1950
+    if (@_ && !$fname) {
1951
+      $self->{default_in_filter} = undef;
1952
+    }
1953
+    else {
1954
+      croak qq{Filter "$fname" is not registered}
1955
+        unless exists $self->filters->{$fname};
1956
+  
1957
+      $self->{default_in_filter} = $self->filters->{$fname};
1991 1958
     }
1992 1959
     
1993
-    return $self->{default_in_filter};
1960
+    return $self;
1961
+  }
1962
+  
1963
+  return $self->{default_in_filter};
1994 1964
 }
1995 1965
 
1996 1966
 # DEPRECATED!
1997 1967
 sub insert_param {
1998
-    my $self = shift;
1999
-    warn "insert_param is DEPRECATED! use values_clause instead";
2000
-    return $self->values_clause(@_);
1968
+  my $self = shift;
1969
+  warn "insert_param is DEPRECATED! use values_clause instead";
1970
+  return $self->values_clause(@_);
2001 1971
 }
2002 1972
 
2003 1973
 # DEPRECATED!
2004 1974
 sub insert_param_tag {
2005
-    warn "insert_param_tag is DEPRECATED! " .
2006
-         "use insert_param instead!";
2007
-    return shift->insert_param(@_);
1975
+  warn "insert_param_tag is DEPRECATED! " .
1976
+    "use insert_param instead!";
1977
+  return shift->insert_param(@_);
2008 1978
 }
2009 1979
 
2010 1980
 # DEPRECATED!
2011 1981
 sub update_param_tag {
2012
-    warn "update_param_tag is DEPRECATED! " .
2013
-         "use update_param instead";
2014
-    return shift->update_param(@_);
1982
+  warn "update_param_tag is DEPRECATED! " .
1983
+    "use update_param instead";
1984
+  return shift->update_param(@_);
2015 1985
 }
2016 1986
 # DEPRECATED!
2017 1987
 sub _push_relation {
2018
-    my ($self, $sql, $tables, $relation, $need_where) = @_;
2019
-    
2020
-    if (keys %{$relation || {}}) {
2021
-        $$sql .= $need_where ? 'where ' : 'and ';
2022
-        for my $rcolumn (keys %$relation) {
2023
-            my $table1 = (split (/\./, $rcolumn))[0];
2024
-            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
2025
-            push @$tables, ($table1, $table2);
2026
-            $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
2027
-        }
1988
+  my ($self, $sql, $tables, $relation, $need_where) = @_;
1989
+  
1990
+  if (keys %{$relation || {}}) {
1991
+    $$sql .= $need_where ? 'where ' : 'and ';
1992
+    for my $rcolumn (keys %$relation) {
1993
+      my $table1 = (split (/\./, $rcolumn))[0];
1994
+      my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
1995
+      push @$tables, ($table1, $table2);
1996
+      $$sql .= "$rcolumn = " . $relation->{$rcolumn} .  'and ';
2028 1997
     }
2029
-    $$sql =~ s/and $/ /;
1998
+  }
1999
+  $$sql =~ s/and $/ /;
2030 2000
 }
2031 2001
 
2032 2002
 # DEPRECATED!
2033 2003
 sub _add_relation_table {
2034
-    my ($self, $tables, $relation) = @_;
2035
-    
2036
-    if (keys %{$relation || {}}) {
2037
-        for my $rcolumn (keys %$relation) {
2038
-            my $table1 = (split (/\./, $rcolumn))[0];
2039
-            my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
2040
-            my $table1_exists;
2041
-            my $table2_exists;
2042
-            for my $table (@$tables) {
2043
-                $table1_exists = 1 if $table eq $table1;
2044
-                $table2_exists = 1 if $table eq $table2;
2045
-            }
2046
-            unshift @$tables, $table1 unless $table1_exists;
2047
-            unshift @$tables, $table2 unless $table2_exists;
2048
-        }
2049
-    }
2004
+  my ($self, $tables, $relation) = @_;
2005
+  
2006
+  if (keys %{$relation || {}}) {
2007
+    for my $rcolumn (keys %$relation) {
2008
+      my $table1 = (split (/\./, $rcolumn))[0];
2009
+      my $table2 = (split (/\./, $relation->{$rcolumn}))[0];
2010
+      my $table1_exists;
2011
+      my $table2_exists;
2012
+      for my $table (@$tables) {
2013
+        $table1_exists = 1 if $table eq $table1;
2014
+        $table2_exists = 1 if $table eq $table2;
2015
+      }
2016
+      unshift @$tables, $table1 unless $table1_exists;
2017
+      unshift @$tables, $table2 unless $table2_exists;
2018
+    }
2019
+  }
2050 2020
 }
2051 2021
 
2052 2022
 1;
... ...
@@ -2057,58 +2027,58 @@ DBIx::Custom - DBI extension to execute insert, update, delete, and select easil
2057 2027
 
2058 2028
 =head1 SYNOPSIS
2059 2029
 
2060
-    use DBIx::Custom;
2061
-    
2062
-    # Connect
2063
-    my $dbi = DBIx::Custom->connect(
2064
-        dsn => "dbi:mysql:database=dbname",
2065
-        user => 'ken',
2066
-        password => '!LFKD%$&',
2067
-        option => {mysql_enable_utf8 => 1}
2068
-    );
2069
-
2070
-    # Insert 
2071
-    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
2072
-    
2073
-    # Update 
2074
-    $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
2075
-      where  => {id => 5});
2076
-    
2077
-    # Delete
2078
-    $dbi->delete(table  => 'book', where => {author => 'Ken'});
2079
-
2080
-    # Select
2081
-    my $result = $dbi->select(table  => 'book',
2082
-      column => ['title', 'author'], where  => {author => 'Ken'});
2083
-
2084
-    # Select, more complex
2085
-    my $result = $dbi->select(
2086
-        table  => 'book',
2087
-        column => [
2088
-            {book => [qw/title author/]},
2089
-            {company => ['name']}
2090
-        ],
2091
-        where  => {'book.author' => 'Ken'},
2092
-        join => ['left outer join company on book.company_id = company.id'],
2093
-        append => 'order by id limit 5'
2094
-    );
2095
-    
2096
-    # Fetch
2097
-    while (my $row = $result->fetch) {
2098
-        
2099
-    }
2100
-    
2101
-    # Fetch as hash
2102
-    while (my $row = $result->fetch_hash) {
2103
-        
2104
-    }
2105
-    
2106
-    # Execute SQL with parameter.
2107
-    $dbi->execute(
2108
-        "select id from book where author = :author and title like :title",
2109
-        {author => 'ken', title => '%Perl%'}
2110
-    );
2111
-    
2030
+  use DBIx::Custom;
2031
+  
2032
+  # Connect
2033
+  my $dbi = DBIx::Custom->connect(
2034
+    dsn => "dbi:mysql:database=dbname",
2035
+    user => 'ken',
2036
+    password => '!LFKD%$&',
2037
+    option => {mysql_enable_utf8 => 1}
2038
+  );
2039
+
2040
+  # Insert 
2041
+  $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
2042
+  
2043
+  # Update 
2044
+  $dbi->update({title => 'Perl', author => 'Ken'}, table  => 'book',
2045
+    where  => {id => 5});
2046
+  
2047
+  # Delete
2048
+  $dbi->delete(table  => 'book', where => {author => 'Ken'});
2049
+
2050
+  # Select
2051
+  my $result = $dbi->select(table  => 'book',
2052
+    column => ['title', 'author'], where  => {author => 'Ken'});
2053
+
2054
+  # Select, more complex
2055
+  my $result = $dbi->select(
2056
+    table  => 'book',
2057
+    column => [
2058
+      {book => [qw/title author/]},
2059
+      {company => ['name']}
2060
+    ],
2061
+    where  => {'book.author' => 'Ken'},
2062
+    join => ['left outer join company on book.company_id = company.id'],
2063
+    append => 'order by id limit 5'
2064
+  );
2065
+  
2066
+  # Fetch
2067
+  while (my $row = $result->fetch) {
2068
+      
2069
+  }
2070
+  
2071
+  # Fetch as hash
2072
+  while (my $row = $result->fetch_hash) {
2073
+      
2074
+  }
2075
+  
2076
+  # Execute SQL with parameter.
2077
+  $dbi->execute(
2078
+    "select id from book where author = :author and title like :title",
2079
+    {author => 'ken', title => '%Perl%'}
2080
+  );
2081
+  
2112 2082
 =head1 DESCRIPTION
2113 2083
 
2114 2084
 L<DBIx::Custom> is L<DBI> wrapper module to execute SQL easily.
... ...
@@ -2170,8 +2140,8 @@ L<DBIx::Custom::Order>
2170 2140
 
2171 2141
 =head2 C<connector>
2172 2142
 
2173
-    my $connector = $dbi->connector;
2174
-    $dbi = $dbi->connector($connector);
2143
+  my $connector = $dbi->connector;
2144
+  $dbi = $dbi->connector($connector);
2175 2145
 
2176 2146
 Connection manager object. if C<connector> is set, you can get C<dbh>
2177 2147
 through connection manager. Conection manager object must have C<dbh> mehtod.
... ...
@@ -2179,50 +2149,50 @@ through connection manager. Conection manager object must have C<dbh> mehtod.
2179 2149
 This is L<DBIx::Connector> example. Please pass
2180 2150
 C<default_option> to L<DBIx::Connector> C<new> method.
2181 2151
 
2182
-    my $connector = DBIx::Connector->new(
2183
-        "dbi:mysql:database=$database",
2184
-        $user,
2185
-        $password,
2186
-        DBIx::Custom->new->default_option
2187
-    );
2188
-    
2189
-    my $dbi = DBIx::Custom->connect(connector => $connector);
2152
+  my $connector = DBIx::Connector->new(
2153
+    "dbi:mysql:database=$database",
2154
+    $user,
2155
+    $password,
2156
+    DBIx::Custom->new->default_option
2157
+  );
2158
+  
2159
+  my $dbi = DBIx::Custom->connect(connector => $connector);
2190 2160
 
2191 2161
 If C<connector> is set to 1 when connect method is called,
2192 2162
 L<DBIx::Connector> is automatically set to C<connector>
2193 2163
 
2194
-    my $dbi = DBIx::Custom->connect(
2195
-      dsn => $dsn, user => $user, password => $password, connector => 1);
2196
-    
2197
-    my $connector = $dbi->connector; # DBIx::Connector
2164
+  my $dbi = DBIx::Custom->connect(
2165
+    dsn => $dsn, user => $user, password => $password, connector => 1);
2166
+  
2167
+  my $connector = $dbi->connector; # DBIx::Connector
2198 2168
 
2199 2169
 Note that L<DBIx::Connector> must be installed.
2200 2170
 
2201 2171
 =head2 C<dsn>
2202 2172
 
2203
-    my $dsn = $dbi->dsn;
2204
-    $dbi = $dbi->dsn("DBI:mysql:database=dbname");
2173
+  my $dsn = $dbi->dsn;
2174
+  $dbi = $dbi->dsn("DBI:mysql:database=dbname");
2205 2175
 
2206 2176
 Data source name, used when C<connect> method is executed.
2207 2177
 
2208 2178
 =head2 C<default_option>
2209 2179
 
2210
-    my $default_option = $dbi->default_option;
2211
-    $dbi = $dbi->default_option($default_option);
2180
+  my $default_option = $dbi->default_option;
2181
+  $dbi = $dbi->default_option($default_option);
2212 2182
 
2213 2183
 L<DBI> default option, used when C<connect> method is executed,
2214 2184
 default to the following values.
2215 2185
 
2216
-    {
2217
-        RaiseError => 1,
2218
-        PrintError => 0,
2219
-        AutoCommit => 1,
2220
-    }
2186
+  {
2187
+    RaiseError => 1,
2188
+    PrintError => 0,
2189
+    AutoCommit => 1,
2190
+  }
2221 2191
 
2222 2192
 =head2 C<exclude_table>
2223 2193
 
2224
-    my $exclude_table = $dbi->exclude_table;
2225
-    $dbi = $dbi->exclude_table(qr/pg_/);
2194
+  my $exclude_table = $dbi->exclude_table;
2195
+  $dbi = $dbi->exclude_table(qr/pg_/);
2226 2196
 
2227 2197
 Excluded table regex.
2228 2198
 C<each_column>, C<each_table>, C<type_rule>,
... ...
@@ -2230,31 +2200,31 @@ and C<setup_model> methods ignore matching tables.
2230 2200
 
2231 2201
 =head2 C<filters>
2232 2202
 
2233
-    my $filters = $dbi->filters;
2234
-    $dbi = $dbi->filters(\%filters);
2203
+  my $filters = $dbi->filters;
2204
+  $dbi = $dbi->filters(\%filters);
2235 2205
 
2236 2206
 Filters, registered by C<register_filter> method.
2237 2207
 
2238 2208
 =head2 C<last_sql>
2239 2209
 
2240
-    my $last_sql = $dbi->last_sql;
2241
-    $dbi = $dbi->last_sql($last_sql);
2210
+  my $last_sql = $dbi->last_sql;
2211
+  $dbi = $dbi->last_sql($last_sql);
2242 2212
 
2243 2213
 Get last successed SQL executed by C<execute> method.
2244 2214
 
2245 2215
 =head2 C<now>
2246 2216
 
2247
-    my $now = $dbi->now;
2248
-    $dbi = $dbi->now($now);
2217
+  my $now = $dbi->now;
2218
+  $dbi = $dbi->now($now);
2249 2219
 
2250 2220
 Code reference which return current time, default to the following code reference.
2251 2221
 
2252
-    sub {
2253
-        my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2254
-        $mon++;
2255
-        $year += 1900;
2256
-        return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2257
-    }
2222
+  sub {
2223
+    my ($sec, $min, $hour, $mday, $mon, $year) = localtime;
2224
+    $mon++;
2225
+    $year += 1900;
2226
+    return sprintf("%04d-%02d-%02d %02d:%02d:%02d");
2227
+  }
2258 2228
 
2259 2229
 This return the time like C<2011-10-14 05:05:27>.
2260 2230
 
... ...
@@ -2263,36 +2233,36 @@ and C<update> method's C<updated_at> option.
2263 2233
 
2264 2234
 =head2 C<models>
2265 2235
 
2266
-    my $models = $dbi->models;
2267
-    $dbi = $dbi->models(\%models);
2236
+  my $models = $dbi->models;
2237
+  $dbi = $dbi->models(\%models);
2268 2238
 
2269 2239
 Models, included by C<include_model> method.
2270 2240
 
2271 2241
 =head2 C<option>
2272 2242
 
2273
-    my $option = $dbi->option;
2274
-    $dbi = $dbi->option($option);
2243
+  my $option = $dbi->option;
2244
+  $dbi = $dbi->option($option);
2275 2245
 
2276 2246
 L<DBI> option, used when C<connect> method is executed.
2277 2247
 Each value in option override the value of C<default_option>.
2278 2248
 
2279 2249
 =head2 C<password>
2280 2250
 
2281
-    my $password = $dbi->password;
2282
-    $dbi = $dbi->password('lkj&le`@s');
2251
+  my $password = $dbi->password;
2252
+  $dbi = $dbi->password('lkj&le`@s');
2283 2253
 
2284 2254
 Password, used when C<connect> method is executed.
2285 2255
 
2286 2256
 =head2 C<query_builder>
2287 2257
 
2288
-    my $builder = $dbi->query_builder;
2258
+  my $builder = $dbi->query_builder;
2289 2259
 
2290 2260
 Creat query builder. This is L<DBIx::Custom::QueryBuilder>.
2291 2261
 
2292 2262
 =head2 C<quote>
2293 2263
 
2294
-     my quote = $dbi->quote;
2295
-     $dbi = $dbi->quote('"');
2264
+  my quote = $dbi->quote;
2265
+  $dbi = $dbi->quote('"');
2296 2266
 
2297 2267
 Reserved word quote.
2298 2268
 Default to double quote '"' except for mysql.
... ...
@@ -2300,27 +2270,27 @@ In mysql, default to back quote '`'
2300 2270
 
2301 2271
 You can set quote pair.
2302 2272
 
2303
-    $dbi->quote('[]');
2273
+  $dbi->quote('[]');
2304 2274
 
2305 2275
 =head2 C<result_class>
2306 2276
 
2307
-    my $result_class = $dbi->result_class;
2308
-    $dbi = $dbi->result_class('DBIx::Custom::Result');
2277
+  my $result_class = $dbi->result_class;
2278
+  $dbi = $dbi->result_class('DBIx::Custom::Result');
2309 2279
 
2310 2280
 Result class, default to L<DBIx::Custom::Result>.
2311 2281
 
2312 2282
 =head2 C<safety_character>
2313 2283
 
2314
-    my $safety_character = $dbi->safety_character;
2315
-    $dbi = $dbi->safety_character($character);
2284
+  my $safety_character = $dbi->safety_character;
2285
+  $dbi = $dbi->safety_character($character);
2316 2286
 
2317 2287
 Regex of safety character for table and column name, default to '\w'.
2318 2288
 Note that you don't have to specify like '[\w]'.
2319 2289
 
2320 2290
 =head2 C<separator>
2321 2291
 
2322
-    my $separator = $dbi->separator;
2323
-    $dbi = $dbi->separator('-');
2292
+  my $separator = $dbi->separator;
2293
+  $dbi = $dbi->separator('-');
2324 2294
 
2325 2295
 Separator which join table name and column name.
2326 2296
 This have effect to C<column> and C<mycolumn> method,
... ...
@@ -2330,56 +2300,56 @@ Default to C<.>.
2330 2300
 
2331 2301
 =head2 C<tag_parse>
2332 2302
 
2333
-    my $tag_parse = $dbi->tag_parse(0);
2334
-    $dbi = $dbi->tag_parse;
2303
+  my $tag_parse = $dbi->tag_parse(0);
2304
+  $dbi = $dbi->tag_parse;
2335 2305
 
2336 2306
 Enable DEPRECATED tag parsing functionality, default to 1.
2337 2307
 If you want to disable tag parsing functionality, set to 0.
2338 2308
 
2339 2309
 =head2 C<user>
2340 2310
 
2341
-    my $user = $dbi->user;
2342
-    $dbi = $dbi->user('Ken');
2311
+  my $user = $dbi->user;
2312
+  $dbi = $dbi->user('Ken');
2343 2313
 
2344 2314
 User name, used when C<connect> method is executed.
2345 2315
 
2346 2316
 =head2 C<user_column_info>
2347 2317
 
2348
-    my $user_column_info = $dbi->user_column_info;
2349
-    $dbi = $dbi->user_column_info($user_column_info);
2318
+  my $user_column_info = $dbi->user_column_info;
2319
+  $dbi = $dbi->user_column_info($user_column_info);
2350 2320
 
2351 2321
 You can set the date like the following one.
2352 2322
 
2353
-    [
2354
-        {table => 'book', column => 'title', info => {...}},
2355
-        {table => 'author', column => 'name', info => {...}}
2356
-    ]
2323
+  [
2324
+    {table => 'book', column => 'title', info => {...}},
2325
+    {table => 'author', column => 'name', info => {...}}
2326
+  ]
2357 2327
 
2358 2328
 Usually, you set return value of C<get_column_info>.
2359 2329
 
2360
-    my $user_column_info
2361
-      = $dbi->get_column_info(exclude_table => qr/^system/);
2362
-    $dbi->user_column_info($user_column_info);
2330
+  my $user_column_info
2331
+    = $dbi->get_column_info(exclude_table => qr/^system/);
2332
+  $dbi->user_column_info($user_column_info);
2363 2333
 
2364 2334
 If C<user_column_info> is set, C<each_column> use C<user_column_info>
2365 2335
 to find column info. this is very fast.
2366 2336
 
2367 2337
 =head2 C<user_table_info>
2368 2338
 
2369
-    my $user_table_info = $dbi->user_table_info;
2370
-    $dbi = $dbi->user_table_info($user_table_info);
2339
+  my $user_table_info = $dbi->user_table_info;
2340
+  $dbi = $dbi->user_table_info($user_table_info);
2371 2341
 
2372 2342
 You can set the following data.
2373 2343
 
2374
-    [
2375
-        {table => 'book', info => {...}},
2376
-        {table => 'author', info => {...}}
2377
-    ]
2344
+  [
2345
+    {table => 'book', info => {...}},
2346
+    {table => 'author', info => {...}}
2347
+  ]
2378 2348
 
2379 2349
 Usually, you can set return value of C<get_table_info>.
2380 2350
 
2381
-    my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2382
-    $dbi->user_table_info($user_table_info);
2351
+  my $user_table_info = $dbi->get_table_info(exclude => qr/^system/);
2352
+  $dbi->user_table_info($user_table_info);
2383 2353
 
2384 2354
 If C<user_table_info> is set, C<each_table> use C<user_table_info>
2385 2355
 to find table info.
... ...
@@ -2392,55 +2362,55 @@ and implements the following new ones.
2392 2362
 
2393 2363
 =head2 C<available_datatype>
2394 2364
 
2395
-    print $dbi->available_datatype;
2365
+  print $dbi->available_datatype;
2396 2366
 
2397 2367
 Get available data types. You can use these data types
2398 2368
 in C<type rule>'s C<from1> and C<from2> section.
2399 2369
 
2400 2370
 =head2 C<available_typename>
2401 2371
 
2402
-    print $dbi->available_typename;
2372
+  print $dbi->available_typename;
2403 2373
 
2404 2374
 Get available type names. You can use these type names in
2405 2375
 C<type_rule>'s C<into1> and C<into2> section.
2406 2376
 
2407 2377
 =head2 C<assign_clause>
2408 2378
 
2409
-    my $assign_clause = $dbi->assign_clause({title => 'a', age => 2});
2379
+  my $assign_clause = $dbi->assign_clause({title => 'a', age => 2});
2410 2380
 
2411 2381
 Create assign clause
2412 2382
 
2413
-    title = :title, author = :author
2383
+  title = :title, author = :author
2414 2384
 
2415 2385
 This is used to create update clause.
2416 2386
 
2417
-    "update book set " . $dbi->assign_clause({title => 'a', age => 2});
2387
+  "update book set " . $dbi->assign_clause({title => 'a', age => 2});
2418 2388
 
2419 2389
 =head2 C<column>
2420 2390
 
2421
-    my $column = $dbi->column(book => ['author', 'title']);
2391
+  my $column = $dbi->column(book => ['author', 'title']);
2422 2392
 
2423 2393
 Create column clause. The follwoing column clause is created.
2424 2394
 
2425
-    book.author as "book.author",
2426
-    book.title as "book.title"
2395
+  book.author as "book.author",
2396
+  book.title as "book.title"
2427 2397
 
2428 2398
 You can change separator by C<separator> attribute.
2429 2399
 
2430
-    # Separator is hyphen
2431
-    $dbi->separator('-');
2432
-    
2433
-    book.author as "book-author",
2434
-    book.title as "book-title"
2435
-    
2400
+  # Separator is hyphen
2401
+  $dbi->separator('-');
2402
+  
2403
+  book.author as "book-author",
2404
+  book.title as "book-title"
2405
+  
2436 2406
 =head2 C<connect>
2437 2407
 
2438
-    my $dbi = DBIx::Custom->connect(
2439
-        dsn => "dbi:mysql:database=dbname",
2440
-        user => 'ken',
2441
-        password => '!LFKD%$&',
2442
-        option => {mysql_enable_utf8 => 1}
2443
-    );
2408
+  my $dbi = DBIx::Custom->connect(
2409
+    dsn => "dbi:mysql:database=dbname",
2410
+    user => 'ken',
2411
+    password => '!LFKD%$&',
2412
+    option => {mysql_enable_utf8 => 1}
2413
+  );
2444 2414
 
2445 2415
 Connect to the database and create a new L<DBIx::Custom> object.
2446 2416
 
... ...
@@ -2450,7 +2420,7 @@ and C<PrintError> option is false by default.
2450 2420
 
2451 2421
 =head2 C<count>
2452 2422
 
2453
-    my $count = $dbi->count(table => 'book');
2423
+  my $count = $dbi->count(table => 'book');
2454 2424
 
2455 2425
 Get rows count.
2456 2426
 
... ...
@@ -2458,29 +2428,29 @@ Options is same as C<select> method's ones.
2458 2428
 
2459 2429
 =head2 C<create_model>
2460 2430
 
2461
-    my $model = $dbi->create_model(
2462
-        table => 'book',
2463
-        primary_key => 'id',
2464
-        join => [
2465
-            'inner join company on book.comparny_id = company.id'
2466
-        ],
2467
-    );
2431
+  my $model = $dbi->create_model(
2432
+    table => 'book',
2433
+    primary_key => 'id',
2434
+    join => [
2435
+      'inner join company on book.comparny_id = company.id'
2436
+    ],
2437
+  );
2468 2438
 
2469 2439
 Create L<DBIx::Custom::Model> object and initialize model.
2470 2440
 the module is also used from C<model> method.
2471 2441
 
2472
-   $dbi->model('book')->select(...);
2442
+ $dbi->model('book')->select(...);
2473 2443
 
2474 2444
 =head2 C<dbh>
2475 2445
 
2476
-    my $dbh = $dbi->dbh;
2446
+  my $dbh = $dbi->dbh;
2477 2447
 
2478 2448
 Get L<DBI> database handle. if C<connector> is set, you can get
2479 2449
 database handle through C<connector> object.
2480 2450
 
2481 2451
 =head2 C<delete>
2482 2452
 
2483
-    $dbi->delete(table => 'book', where => {title => 'Perl'});
2453
+  $dbi->delete(table => 'book', where => {title => 'Perl'});
2484 2454
 
2485 2455
 Execute delete statement.
2486 2456
 
... ...
@@ -2495,33 +2465,33 @@ and use the following new ones.
2495 2465
 
2496 2466
 =item C<id>
2497 2467
 
2498
-    id => 4
2499
-    id => [4, 5]
2468
+  id => 4
2469
+  id => [4, 5]
2500 2470
 
2501 2471
 ID corresponding to C<primary_key>.
2502 2472
 You can delete rows by C<id> and C<primary_key>.
2503 2473
 
2504
-    $dbi->delete(
2505
-        primary_key => ['id1', 'id2'],
2506
-        id => [4, 5],
2507
-        table => 'book',
2508
-    );
2474
+  $dbi->delete(
2475
+    primary_key => ['id1', 'id2'],
2476
+    id => [4, 5],
2477
+    table => 'book',
2478
+  );
2509 2479
 
2510 2480
 The above is same as the followin one.
2511 2481
 
2512
-    $dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book');
2482
+  $dbi->delete(where => {id1 => 4, id2 => 5}, table => 'book');
2513 2483
 
2514 2484
 =item C<prefix>
2515 2485
 
2516
-    prefix => 'some'
2486
+  prefix => 'some'
2517 2487
 
2518 2488
 prefix before table name section.
2519 2489
 
2520
-    delete some from book
2490
+  delete some from book
2521 2491
 
2522 2492
 =item C<table>
2523 2493
 
2524
-    table => 'book'
2494
+  table => 'book'
2525 2495
 
2526 2496
 Table name.
2527 2497
 
... ...
@@ -2533,24 +2503,24 @@ Same as C<select> method's C<where> option.
2533 2503
 
2534 2504
 =head2 C<delete_all>
2535 2505
 
2536
-    $dbi->delete_all(table => $table);
2506
+  $dbi->delete_all(table => $table);
2537 2507
 
2538 2508
 Execute delete statement for all rows.
2539 2509
 Options is same as C<delete>.
2540 2510
 
2541 2511
 =head2 C<each_column>
2542 2512
 
2543
-    $dbi->each_column(
2544
-        sub {
2545
-            my ($dbi, $table, $column, $column_info) = @_;
2546
-            
2547
-            my $type = $column_info->{TYPE_NAME};
2548
-            
2549
-            if ($type eq 'DATE') {
2550
-                # ...
2551
-            }
2552
-        }
2553
-    );
2513
+  $dbi->each_column(
2514
+    sub {
2515
+      my ($dbi, $table, $column, $column_info) = @_;
2516
+      
2517
+      my $type = $column_info->{TYPE_NAME};
2518
+      
2519
+      if ($type eq 'DATE') {
2520
+          # ...
2521
+      }
2522
+    }
2523
+  );
2554 2524
 
2555 2525
 Iterate all column informations in database.
2556 2526
 Argument is callback which is executed when one column is found.
... ...
@@ -2561,19 +2531,19 @@ If C<user_column_info> is set, C<each_column> method use C<user_column_info>
2561 2531
 infromation, you can improve the performance of C<each_column> in
2562 2532
 the following way.
2563 2533
 
2564
-    my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2565
-    $dbi->user_column_info($column_info);
2566
-    $dbi->each_column(sub { ... });
2534
+  my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2535
+  $dbi->user_column_info($column_info);
2536
+  $dbi->each_column(sub { ... });
2567 2537
 
2568 2538
 =head2 C<each_table>
2569 2539
 
2570
-    $dbi->each_table(
2571
-        sub {
2572
-            my ($dbi, $table, $table_info) = @_;
2573
-            
2574
-            my $table_name = $table_info->{TABLE_NAME};
2575
-        }
2576
-    );
2540
+  $dbi->each_table(
2541
+    sub {
2542
+      my ($dbi, $table, $table_info) = @_;
2543
+      
2544
+      my $table_name = $table_info->{TABLE_NAME};
2545
+    }
2546
+  );
2577 2547
 
2578 2548
 Iterate all table informationsfrom in database.
2579 2549
 Argument is callback which is executed when one table is found.
... ...
@@ -2584,21 +2554,21 @@ If C<user_table_info> is set, C<each_table> method use C<user_table_info>
2584 2554
 infromation, you can improve the performance of C<each_table> in
2585 2555
 the following way.
2586 2556
 
2587
-    my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2588
-    $dbi->user_table_info($table_info);
2589
-    $dbi->each_table(sub { ... });
2557
+  my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2558
+  $dbi->user_table_info($table_info);
2559
+  $dbi->each_table(sub { ... });
2590 2560
 
2591 2561
 =head2 C<execute>
2592 2562
 
2593
-    my $result = $dbi->execute(
2594
-      "select * from book where title = :title and author like :author",
2595
-      {title => 'Perl', author => '%Ken%'}
2596
-    );
2563
+  my $result = $dbi->execute(
2564
+    "select * from book where title = :title and author like :author",
2565
+    {title => 'Perl', author => '%Ken%'}
2566
+  );
2597 2567
 
2598
-    my $result = $dbi->execute(
2599
-      "select * from book where title = :book.title and author like :book.author",
2600
-      {'book.title' => 'Perl', 'book.author' => '%Ken%'}
2601
-    );
2568
+  my $result = $dbi->execute(
2569
+    "select * from book where title = :book.title and author like :book.author",
2570
+    {'book.title' => 'Perl', 'book.author' => '%Ken%'}
2571
+  );
2602 2572
 
2603 2573
 Execute SQL. SQL can contain column parameter such as :author and :title.
2604 2574
 You can append table name to column name such as :book.title and :book.author.
... ...
@@ -2607,27 +2577,27 @@ Return value is L<DBIx::Custom::Result> object when select statement is executed
2607 2577
 or the count of affected rows when insert, update, delete statement is executed.
2608 2578
 
2609 2579
 Named placeholder such as C<:title> is replaced by placeholder C<?>.
2610
-    
2611
-    # Original
2612
-    select * from book where title = :title and author like :author
2613
-    
2614
-    # Replaced
2615
-    select * from where title = ? and author like ?;
2580
+  
2581
+  # Original
2582
+  select * from book where title = :title and author like :author
2583
+  
2584
+  # Replaced
2585
+  select * from where title = ? and author like ?;
2616 2586
 
2617 2587
 You can specify operator with named placeholder
2618 2588
 by C<name{operator}> syntax.
2619 2589
 
2620
-    # Original
2621
-    select * from book where :title{=} and :author{like}
2622
-    
2623
-    # Replaced
2624
-    select * from where title = ? and author like ?;
2590
+  # Original
2591
+  select * from book where :title{=} and :author{like}
2592
+  
2593
+  # Replaced
2594
+  select * from where title = ? and author like ?;
2625 2595
 
2626 2596
 Note that colons in time format such as 12:13:15 is exeption,
2627 2597
 it is not parsed as named placeholder.
2628 2598
 If you want to use colon generally, you must escape it by C<\\>
2629 2599
 
2630
-    select * from where title = "aa\\:bb";
2600
+  select * from where title = "aa\\:bb";
2631 2601
 
2632 2602
 B<OPTIONS>
2633 2603
 
... ...
@@ -2639,25 +2609,25 @@ The following opitons are available.
2639 2609
 
2640 2610
 You can filter sql after the sql is build.
2641 2611
 
2642
-    after_build_sql => $code_ref
2612
+  after_build_sql => $code_ref
2643 2613
 
2644 2614
 The following one is one example.
2645 2615
 
2646
-    $dbi->select(
2647
-        table => 'book',
2648
-        column => 'distinct(name)',
2649
-        after_build_sql => sub {
2650
-            "select count(*) from ($_[0]) as t1"
2651
-        }
2652
-    );
2616
+  $dbi->select(
2617
+    table => 'book',
2618
+    column => 'distinct(name)',
2619
+    after_build_sql => sub {
2620
+      "select count(*) from ($_[0]) as t1"
2621
+    }
2622
+  );
2653 2623
 
2654 2624
 The following SQL is executed.
2655 2625
 
2656
-    select count(*) from (select distinct(name) from book) as t1;
2626
+  select count(*) from (select distinct(name) from book) as t1;
2657 2627
 
2658 2628
 =item C<append>
2659 2629
 
2660
-    append => 'order by name'
2630
+  append => 'order by name'
2661 2631
 
2662 2632
 Append some statement after SQL.
2663 2633
 
... ...
@@ -2665,30 +2635,30 @@ Append some statement after SQL.
2665 2635
 
2666 2636
 Specify database bind data type.
2667 2637
 
2668
-    bind_type => [image => DBI::SQL_BLOB]
2669
-    bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2638
+  bind_type => [image => DBI::SQL_BLOB]
2639
+  bind_type => [[qw/image audio/] => DBI::SQL_BLOB]
2670 2640
 
2671 2641
 This is used to bind parameter by C<bind_param> of statment handle.
2672 2642
 
2673
-    $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2643
+  $sth->bind_param($pos, $value, DBI::SQL_BLOB);
2674 2644
 
2675 2645
 =item C<filter>
2676
-    
2677
-    filter => {
2678
-        title  => sub { uc $_[0] }
2679
-        author => sub { uc $_[0] }
2680
-    }
2681
-
2682
-    # Filter name
2683
-    filter => {
2684
-        title  => 'upper_case',
2685
-        author => 'upper_case'
2686
-    }
2687
-        
2688
-    # At once
2689
-    filter => [
2690
-        [qw/title author/]  => sub { uc $_[0] }
2691
-    ]
2646
+  
2647
+  filter => {
2648
+    title  => sub { uc $_[0] }
2649
+    author => sub { uc $_[0] }
2650
+  }
2651
+
2652
+  # Filter name
2653
+  filter => {
2654
+    title  => 'upper_case',
2655
+    author => 'upper_case'
2656
+  }
2657
+      
2658
+  # At once
2659
+  filter => [
2660
+    [qw/title author/]  => sub { uc $_[0] }
2661
+  ]
2692 2662
 
2693 2663
 Filter. You can set subroutine or filter name
2694 2664
 registered by by C<register_filter>.
... ...
@@ -2697,52 +2667,52 @@ and before type rule filter is executed.
2697 2667
 
2698 2668
 =item C<query>
2699 2669
 
2700
-    query => 1
2670
+  query => 1
2701 2671
 
2702 2672
 C<execute> method return hash reference which contain SQL and column
2703 2673
 infromation
2704 2674
 
2705
-    my $sql = $query->{sql};
2706
-    my $columns = $query->{columns};
2707
-    
2675
+  my $sql = $query->{sql};
2676
+  my $columns = $query->{columns};
2677
+  
2708 2678
 =item C<reuse>
2709
-    
2710
-    reuse => $hash_ref
2679
+  
2680
+  reuse => $hash_ref
2711 2681
 
2712 2682
 Reuse query object if the hash reference variable is set.
2713
-    
2714
-    my $queries = {};
2715
-    $dbi->execute($sql, $param, reuse => $queries);
2683
+  
2684
+  my $queries = {};
2685
+  $dbi->execute($sql, $param, reuse => $queries);
2716 2686
 
2717 2687
 This will improved performance when you want to execute same query repeatedly
2718 2688
 because generally creating query object is slow.
2719 2689
 
2720 2690
 =item C<primary_key>
2721 2691
 
2722
-    primary_key => 'id'
2723
-    primary_key => ['id1', 'id2']
2692
+  primary_key => 'id'
2693
+  primary_key => ['id1', 'id2']
2724 2694
 
2725 2695
 Priamry key. This is used for C<id> option.
2726 2696
 
2727 2697
 =item C<table>
2728
-    
2729
-    table => 'author'
2698
+  
2699
+  table => 'author'
2730 2700
 
2731 2701
 If you want to omit table name in column name
2732 2702
 and enable C<into1> and C<into2> type filter,
2733 2703
 You must set C<table> option.
2734 2704
 
2735
-    $dbi->execute("select * from book where title = :title and author = :author",
2736
-        {title => 'Perl', author => 'Ken', table => 'book');
2705
+  $dbi->execute("select * from book where title = :title and author = :author",
2706
+    {title => 'Perl', author => 'Ken', table => 'book');
2737 2707
 
2738
-    # Same
2739
-    $dbi->execute(
2740
-      "select * from book where title = :book.title and author = :book.author",
2741
-      {title => 'Perl', author => 'Ken');
2708
+  # Same
2709
+  $dbi->execute(
2710
+    "select * from book where title = :book.title and author = :book.author",
2711
+    {title => 'Perl', author => 'Ken');
2742 2712
 
2743 2713
 =item C<table_alias>
2744 2714
 
2745
-    table_alias => {user => 'worker'}
2715
+  table_alias => {user => 'worker'}
2746 2716
 
2747 2717
 Table alias. Key is real table name, value is alias table name.
2748 2718
 If you set C<table_alias>, you can enable C<into1> and C<into2> type rule
... ...
@@ -2750,19 +2720,19 @@ on alias table name.
2750 2720
 
2751 2721
 =item C<type_rule_off>
2752 2722
 
2753
-    type_rule_off => 1
2723
+  type_rule_off => 1
2754 2724
 
2755 2725
 Turn C<into1> and C<into2> type rule off.
2756 2726
 
2757 2727
 =item C<type_rule1_off>
2758 2728
 
2759
-    type_rule1_off => 1
2729
+  type_rule1_off => 1
2760 2730
 
2761 2731
 Turn C<into1> type rule off.
2762 2732
 
2763 2733
 =item C<type_rule2_off>
2764 2734
 
2765
-    type_rule2_off => 1
2735
+  type_rule2_off => 1
2766 2736
 
2767 2737
 Turn C<into2> type rule off.
2768 2738
 
... ...
@@ -2770,46 +2740,46 @@ Turn C<into2> type rule off.
2770 2740
 
2771 2741
 =head2 C<get_column_info>
2772 2742
 
2773
-    my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2743
+  my $column_infos = $dbi->get_column_info(exclude_table => qr/^system_/);
2774 2744
 
2775 2745
 get column infomation except for one which match C<exclude_table> pattern.
2776 2746
 
2777
-    [
2778
-        {table => 'book', column => 'title', info => {...}},
2779
-        {table => 'author', column => 'name' info => {...}}
2780
-    ]
2747
+  [
2748
+    {table => 'book', column => 'title', info => {...}},
2749
+    {table => 'author', column => 'name' info => {...}}
2750
+  ]
2781 2751
 
2782 2752
 =head2 C<get_table_info>
2783 2753
 
2784
-    my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2754
+  my $table_infos = $dbi->get_table_info(exclude => qr/^system_/);
2785 2755
 
2786 2756
 get table infomation except for one which match C<exclude> pattern.
2787 2757
 
2788
-    [
2789
-        {table => 'book', info => {...}},
2790
-        {table => 'author', info => {...}}
2791
-    ]
2758
+  [
2759
+    {table => 'book', info => {...}},
2760
+    {table => 'author', info => {...}}
2761
+  ]
2792 2762
 
2793 2763
 You can set this value to C<user_table_info>.
2794 2764
 
2795 2765
 =head2 C<helper>
2796 2766
 
2797
-    $dbi->helper(
2798
-        find_or_create   => sub {
2799
-            my $self = shift;
2800
-            
2801
-            # Process
2802
-        },
2803
-        ...
2804
-    );
2767
+  $dbi->helper(
2768
+    find_or_create   => sub {
2769
+      my $self = shift;
2770
+      
2771
+      # Process
2772
+    },
2773
+    ...
2774
+  );
2805 2775
 
2806 2776
 Register helper. These helper is called directly from L<DBIx::Custom> object.
2807 2777
 
2808
-    $dbi->find_or_create;
2778
+  $dbi->find_or_create;
2809 2779
 
2810 2780
 =head2 C<insert>
2811 2781
 
2812
-    $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
2782
+  $dbi->insert({title => 'Perl', author => 'Ken'}, table  => 'book');
2813 2783
 
2814 2784
 Execute insert statement. First argument is row data. Return value is
2815 2785
 affected row count.
... ...
@@ -2817,18 +2787,18 @@ affected row count.
2817 2787
 If you want to set constant value to row data, use scalar reference
2818 2788
 as parameter value.
2819 2789
 
2820
-    {date => \"NOW()"}
2790
+  {date => \"NOW()"}
2821 2791
 
2822 2792
 You can pass multiple parameters, this is very fast.
2823 2793
 This is EXPERIMETNAL.
2824 2794
 
2825
-    $dbi->insert(
2826
-        [
2827
-            {title => 'Perl', author => 'Ken'},
2828
-            {title => 'Ruby', author => 'Tom'}
2829
-        ],
2830
-        table  => 'book'
2831
-    );
2795
+  $dbi->insert(
2796
+    [
2797
+      {title => 'Perl', author => 'Ken'},
2798
+      {title => 'Ruby', author => 'Tom'}
2799
+    ],
2800
+    table  => 'book'
2801
+  );
2832 2802
 
2833 2803
 In multiple insert, you can't use C<id> option.
2834 2804
 and only first parameter is used by creating sql.
... ...
@@ -2842,17 +2812,17 @@ and use the following new ones.
2842 2812
 b
2843 2813
 =item C<bulk_insert> EXPERIMENTAL
2844 2814
 
2845
-    bulk_insert => 1
2815
+  bulk_insert => 1
2846 2816
 
2847 2817
 bulk insert is executed if database support bulk insert and 
2848 2818
 multiple parameters is passed to C<insert>.
2849 2819
 The SQL like the following one is executed.
2850 2820
 
2851
-    insert into book (id, title) values (?, ?), (?, ?);
2821
+  insert into book (id, title) values (?, ?), (?, ?);
2852 2822
 
2853 2823
 =item C<created_at>
2854 2824
 
2855
-    created_at => 'created_datetime'
2825
+  created_at => 'created_datetime'
2856 2826
 
2857 2827
 Created timestamp column name. time when row is created is set to the column.
2858 2828
 default time format is "YYYY-mm-dd HH:MM:SS", which can be changed by
... ...
@@ -2860,37 +2830,37 @@ C<now> attribute.
2860 2830
 
2861 2831
 =item C<id>
2862 2832
 
2863
-    id => 4
2864
-    id => [4, 5]
2833
+  id => 4
2834
+  id => [4, 5]
2865 2835
 
2866 2836
 ID corresponding to C<primary_key>.
2867 2837
 You can insert a row by C<id> and C<primary_key>.
2868 2838
 
2869
-    $dbi->insert(
2870
-        {title => 'Perl', author => 'Ken'}
2871
-        primary_key => ['id1', 'id2'],
2872
-        id => [4, 5],
2873
-        table => 'book'
2874
-    );
2839
+  $dbi->insert(
2840
+    {title => 'Perl', author => 'Ken'}
2841
+    primary_key => ['id1', 'id2'],
2842
+    id => [4, 5],
2843
+    table => 'book'
2844
+  );
2875 2845
 
2876 2846
 The above is same as the followin one.
2877 2847
 
2878
-    $dbi->insert(
2879
-        {id1 => 4, id2 => 5, title => 'Perl', author => 'Ken'},
2880
-        table => 'book'
2881
-    );
2848
+  $dbi->insert(
2849
+    {id1 => 4, id2 => 5, title => 'Perl', author => 'Ken'},
2850
+    table => 'book'
2851
+  );
2882 2852
 
2883 2853
 =item C<prefix>
2884 2854
 
2885
-    prefix => 'or replace'
2855
+  prefix => 'or replace'
2886 2856
 
2887 2857
 prefix before table name section
2888 2858
 
2889
-    insert or replace into book
2859
+  insert or replace into book
2890 2860
 
2891 2861
 =item C<table>
2892 2862
 
2893
-    table => 'book'
2863
+  table => 'book'
2894 2864
 
2895 2865
 Table name.
2896 2866
 
... ...
@@ -2900,18 +2870,18 @@ This option is same as C<update> method C<updated_at> option.
2900 2870
 
2901 2871
 =item C<wrap>
2902 2872
 
2903
-    wrap => {price => sub { "max($_[0])" }}
2873
+  wrap => {price => sub { "max($_[0])" }}
2904 2874
 
2905 2875
 placeholder wrapped string.
2906 2876
 
2907 2877
 If the following statement
2908 2878
 
2909
-    $dbi->insert({price => 100}, table => 'book',
2910
-      {price => sub { "$_[0] + 5" }});
2879
+  $dbi->insert({price => 100}, table => 'book',
2880
+    {price => sub { "$_[0] + 5" }});
2911 2881
 
2912 2882
 is executed, the following SQL is executed.
2913 2883
 
2914
-    insert into book price values ( ? + 5 );
2884
+  insert into book price values ( ? + 5 );
2915 2885
 
2916 2886
 =back
2917 2887
 
... ...
@@ -2919,150 +2889,150 @@ is executed, the following SQL is executed.
2919 2889
 
2920 2890
 =head2 C<include_model>
2921 2891
 
2922
-    $dbi->include_model('MyModel');
2892
+  $dbi->include_model('MyModel');
2923 2893
 
2924 2894
 Include models from specified namespace,
2925 2895
 the following layout is needed to include models.
2926 2896
 
2927
-    lib / MyModel.pm
2928
-        / MyModel / book.pm
2929
-                  / company.pm
2897
+  lib / MyModel.pm
2898
+      / MyModel / book.pm
2899
+                / company.pm
2930 2900
 
2931 2901
 Name space module, extending L<DBIx::Custom::Model>.
2932 2902
 
2933 2903
 B<MyModel.pm>
2934 2904
 
2935
-    package MyModel;
2936
-    use DBIx::Custom::Model -base;
2937
-    
2938
-    1;
2905
+  package MyModel;
2906
+  use DBIx::Custom::Model -base;
2907
+  
2908
+  1;
2939 2909
 
2940 2910
 Model modules, extending name space module.
2941 2911
 
2942 2912
 B<MyModel/book.pm>
2943 2913
 
2944
-    package MyModel::book;
2945
-    use MyModel -base;
2946
-    
2947
-    1;
2914
+  package MyModel::book;
2915
+  use MyModel -base;
2916
+  
2917
+  1;
2948 2918
 
2949 2919
 B<MyModel/company.pm>
2950 2920
 
2951
-    package MyModel::company;
2952
-    use MyModel -base;
2953
-    
2954
-    1;
2955
-    
2921
+  package MyModel::company;
2922
+  use MyModel -base;
2923
+  
2924
+  1;
2925
+  
2956 2926
 MyModel::book and MyModel::company is included by C<include_model>.
2957 2927
 
2958 2928
 You can get model object by C<model>.
2959 2929
 
2960
-    my $book_model = $dbi->model('book');
2961
-    my $company_model = $dbi->model('company');
2930
+  my $book_model = $dbi->model('book');
2931
+  my $company_model = $dbi->model('company');
2962 2932
 
2963 2933
 See L<DBIx::Custom::Model> to know model features.
2964 2934
 
2965 2935
 =head2 C<like_value>
2966 2936
 
2967
-    my $like_value = $dbi->like_value
2937
+  my $like_value = $dbi->like_value
2968 2938
 
2969 2939
 Code reference which return a value for the like value.
2970 2940
 
2971
-    sub { "%$_[0]%" }
2941
+  sub { "%$_[0]%" }
2972 2942
 
2973 2943
 =head2 C<mapper>
2974 2944
 
2975
-    my $mapper = $dbi->mapper(param => $param);
2945
+  my $mapper = $dbi->mapper(param => $param);
2976 2946
 
2977 2947
 Create a new L<DBIx::Custom::Mapper> object.
2978 2948
 
2979 2949
 =head2 C<merge_param>
2980 2950
 
2981
-    my $param = $dbi->merge_param({key1 => 1}, {key1 => 1, key2 => 2});
2951
+  my $param = $dbi->merge_param({key1 => 1}, {key1 => 1, key2 => 2});
2982 2952
 
2983 2953
 Merge parameters. The following new parameter is created.
2984 2954
 
2985
-    {key1 => [1, 1], key2 => 2}
2955
+  {key1 => [1, 1], key2 => 2}
2986 2956
 
2987 2957
 If same keys contains, the value is converted to array reference.
2988 2958
 
2989 2959
 =head2 C<model>
2990 2960
 
2991
-    my $model = $dbi->model('book');
2961
+  my $model = $dbi->model('book');
2992 2962
 
2993 2963
 Get a L<DBIx::Custom::Model> object
2994 2964
 create by C<create_model> or C<include_model>
2995 2965
 
2996 2966
 =head2 C<mycolumn>
2997 2967
 
2998
-    my $column = $dbi->mycolumn(book => ['author', 'title']);
2968
+  my $column = $dbi->mycolumn(book => ['author', 'title']);
2999 2969
 
3000 2970
 Create column clause for myself. The follwoing column clause is created.
3001 2971
 
3002
-    book.author as author,
3003
-    book.title as title
2972
+  book.author as author,
2973
+  book.title as title
3004 2974
 
3005 2975
 =head2 C<new>
3006 2976
 
3007
-    my $dbi = DBIx::Custom->new(
3008
-        dsn => "dbi:mysql:database=dbname",
3009
-        user => 'ken',
3010
-        password => '!LFKD%$&',
3011
-        option => {mysql_enable_utf8 => 1}
3012
-    );
2977
+  my $dbi = DBIx::Custom->new(
2978
+    dsn => "dbi:mysql:database=dbname",
2979
+    user => 'ken',
2980
+    password => '!LFKD%$&',
2981
+    option => {mysql_enable_utf8 => 1}
2982
+  );
3013 2983
 
3014 2984
 Create a new L<DBIx::Custom> object.
3015 2985
 
3016 2986
 =head2 C<not_exists>
3017 2987
 
3018
-    my $not_exists = $dbi->not_exists;
2988
+  my $not_exists = $dbi->not_exists;
3019 2989
 
3020 2990
 DBIx::Custom::NotExists object, indicating the column is not exists.
3021 2991
 This is used in C<param> of L<DBIx::Custom::Where> .
3022 2992
 
3023 2993
 =head2 C<order>
3024 2994
 
3025
-    my $order = $dbi->order;
2995
+  my $order = $dbi->order;
3026 2996
 
3027 2997
 Create a new L<DBIx::Custom::Order> object.
3028 2998
 
3029 2999
 =head2 C<q>
3030 3000
 
3031
-    my $quooted = $dbi->q("title");
3001
+  my $quooted = $dbi->q("title");
3032 3002
 
3033 3003
 Quote string by value of C<quote>.
3034 3004
 
3035 3005
 =head2 C<register_filter>
3036 3006
 
3037
-    $dbi->register_filter(
3038
-        # Time::Piece object to database DATE format
3039
-        tp_to_date => sub {
3040
-            my $tp = shift;
3041
-            return $tp->strftime('%Y-%m-%d');
3042
-        },
3043
-        # database DATE format to Time::Piece object
3044
-        date_to_tp => sub {
3045
-           my $date = shift;
3046
-           return Time::Piece->strptime($date, '%Y-%m-%d');
3047
-        }
3048
-    );
3049
-    
3007
+  $dbi->register_filter(
3008
+    # Time::Piece object to database DATE format
3009
+    tp_to_date => sub {
3010
+      my $tp = shift;
3011
+      return $tp->strftime('%Y-%m-%d');
3012
+    },
3013
+    # database DATE format to Time::Piece object
3014
+    date_to_tp => sub {
3015
+      my $date = shift;
3016
+      return Time::Piece->strptime($date, '%Y-%m-%d');
3017
+    }
3018
+  );
3019
+  
3050 3020
 Register filters, used by C<filter> option of many methods.
3051 3021
 
3052 3022
 =head2 C<select>
3053 3023
 
3054
-    my $result = $dbi->select(
3055
-        column => ['author', 'title'],
3056
-        table  => 'book',
3057
-        where  => {author => 'Ken'},
3058
-    );
3059
-    
3024
+  my $result = $dbi->select(
3025
+    column => ['author', 'title'],
3026
+    table  => 'book',
3027
+    where  => {author => 'Ken'},
3028
+  );
3029
+  
3060 3030
 Execute select statement.
3061 3031
 
3062 3032
 You can pass odd number arguments. first argument is C<column>.
3063 3033
 This is EXPERIMENTAL.
3064 3034
 
3065
-    my $result = $dbi->select(['author', 'title'], table => 'book');
3035
+  my $result = $dbi->select(['author', 'title'], table => 'book');
3066 3036
 
3067 3037
 B<OPTIONS>
3068 3038
 
... ...
@@ -3072,186 +3042,186 @@ and use the following new ones.
3072 3042
 =over 4
3073 3043
 
3074 3044
 =item C<column>
3075
-    
3076
-    column => 'author'
3077
-    column => ['author', 'title']
3045
+  
3046
+  column => 'author'
3047
+  column => ['author', 'title']
3078 3048
 
3079 3049
 Column clause.
3080
-    
3050
+  
3081 3051
 if C<column> is not specified, '*' is set.
3082 3052
 
3083
-    column => '*'
3053
+  column => '*'
3084 3054
 
3085 3055
 You can specify hash of array reference.
3086 3056
 
3087
-    column => [
3088
-        {book => [qw/author title/]},
3089
-        {person => [qw/name age/]}
3090
-    ]
3057
+  column => [
3058
+    {book => [qw/author title/]},
3059
+    {person => [qw/name age/]}
3060
+  ]
3091 3061
 
3092 3062
 This is expanded to the following one by using C<colomn> method.
3093 3063
 
3094
-    book.author as "book.author",
3095
-    book.title as "book.title",
3096
-    person.name as "person.name",
3097
-    person.age as "person.age"
3064
+  book.author as "book.author",
3065
+  book.title as "book.title",
3066
+  person.name as "person.name",
3067
+  person.age as "person.age"
3098 3068
 
3099 3069
 You can specify array of array reference, first argument is
3100 3070
 column name, second argument is alias.
3101 3071
 
3102
-    column => [
3103
-        ['date(book.register_datetime)' => 'book.register_date']
3104
-    ];
3072
+  column => [
3073
+    ['date(book.register_datetime)' => 'book.register_date']
3074
+  ];
3105 3075
 
3106 3076
 Alias is quoted properly and joined.
3107 3077
 
3108
-    date(book.register_datetime) as "book.register_date"
3078
+  date(book.register_datetime) as "book.register_date"
3109 3079
 
3110 3080
 =item C<id>
3111 3081
 
3112
-    id => 4
3113
-    id => [4, 5]
3082
+  id => 4
3083
+  id => [4, 5]
3114 3084
 
3115 3085
 ID corresponding to C<primary_key>.
3116 3086
 You can select rows by C<id> and C<primary_key>.
3117 3087
 
3118
-    $dbi->select(
3119
-        primary_key => ['id1', 'id2'],
3120
-        id => [4, 5],
3121
-        table => 'book'
3122
-    );
3088
+  $dbi->select(
3089
+    primary_key => ['id1', 'id2'],
3090
+    id => [4, 5],
3091
+    table => 'book'
3092
+  );
3123 3093
 
3124 3094
 The above is same as the followin one.
3125 3095
 
3126
-    $dbi->select(
3127
-        where => {id1 => 4, id2 => 5},
3128
-        table => 'book'
3129
-    );
3130
-    
3096
+  $dbi->select(
3097
+    where => {id1 => 4, id2 => 5},
3098
+    table => 'book'
3099
+  );
3100
+  
3131 3101
 =item C<param>
3132 3102
 
3133
-    param => {'table2.key3' => 5}
3103
+  param => {'table2.key3' => 5}
3134 3104
 
3135 3105
 Parameter shown before where clause.
3136
-    
3106
+  
3137 3107
 For example, if you want to contain tag in join clause, 
3138 3108
 you can pass parameter by C<param> option.
3139 3109
 
3140
-    join  => ['inner join (select * from table2 where table2.key3 = :table2.key3)' . 
3141
-              ' as table2 on table1.key1 = table2.key1']
3110
+  join  => ['inner join (select * from table2 where table2.key3 = :table2.key3)' . 
3111
+            ' as table2 on table1.key1 = table2.key1']
3142 3112
 
3143 3113
 =itme C<prefix>
3144 3114
 
3145
-    prefix => 'SQL_CALC_FOUND_ROWS'
3115
+  prefix => 'SQL_CALC_FOUND_ROWS'
3146 3116
 
3147 3117
 Prefix of column cluase
3148 3118
 
3149
-    select SQL_CALC_FOUND_ROWS title, author from book;
3119
+  select SQL_CALC_FOUND_ROWS title, author from book;
3150 3120
 
3151 3121
 =item C<join>
3152 3122
 
3153
-    join => [
3154
-        'left outer join company on book.company_id = company_id',
3155
-        'left outer join location on company.location_id = location.id'
3156
-    ]
3157
-        
3123
+  join => [
3124
+    'left outer join company on book.company_id = company_id',
3125
+    'left outer join location on company.location_id = location.id'
3126
+  ]
3127
+      
3158 3128
 Join clause. If column cluase or where clause contain table name like "company.name",
3159 3129
 join clausees needed when SQL is created is used automatically.
3160 3130
 
3161
-    $dbi->select(
3162
-        table => 'book',
3163
-        column => ['company.location_id as location_id'],
3164
-        where => {'company.name' => 'Orange'},
3165
-        join => [
3166
-            'left outer join company on book.company_id = company.id',
3167
-            'left outer join location on company.location_id = location.id'
3168
-        ]
3169
-    );
3131
+  $dbi->select(
3132
+    table => 'book',
3133
+    column => ['company.location_id as location_id'],
3134
+    where => {'company.name' => 'Orange'},
3135
+    join => [
3136
+      'left outer join company on book.company_id = company.id',
3137
+      'left outer join location on company.location_id = location.id'
3138
+    ]
3139
+  );
3170 3140
 
3171 3141
 In above select, column and where clause contain "company" table,
3172 3142
 the following SQL is created
3173 3143
 
3174
-    select company.location_id as location_id
3175
-    from book
3176
-      left outer join company on book.company_id = company.id
3177
-    where company.name = ?;
3144
+  select company.location_id as location_id
3145
+  from book
3146
+    left outer join company on book.company_id = company.id
3147
+  where company.name = ?;
3178 3148
 
3179 3149
 You can specify two table by yourself. This is useful when join parser can't parse
3180 3150
 the join clause correctly.
3181 3151
 
3182
-    $dbi->select(
3183
-        table => 'book',
3184
-        column => ['company.location_id as location_id'],
3185
-        where => {'company.name' => 'Orange'},
3186
-        join => [
3187
-            {
3188
-                clause => 'left outer join location on company.location_id = location.id',
3189
-                table => ['company', 'location']
3190
-            }
3191
-        ]
3192
-    );
3152
+  $dbi->select(
3153
+    table => 'book',
3154
+    column => ['company.location_id as location_id'],
3155
+    where => {'company.name' => 'Orange'},
3156
+    join => [
3157
+      {
3158
+        clause => 'left outer join location on company.location_id = location.id',
3159
+        table => ['company', 'location']
3160
+      }
3161
+    ]
3162
+  );
3193 3163
 
3194 3164
 =item C<table>
3195 3165
 
3196
-    table => 'book'
3166
+  table => 'book'
3197 3167
 
3198 3168
 Table name.
3199 3169
 
3200 3170
 =item C<where>
3201
-    
3202
-    # Hash refrence
3203
-    where => {author => 'Ken', 'title' => 'Perl'}
3204
-    
3205
-    # DBIx::Custom::Where object
3206
-    where => $dbi->where(
3207
-        clause => ['and', ':author{=}', ':title{like}'],
3208
-        param  => {author => 'Ken', title => '%Perl%'}
3209
-    );
3210
-    
3211
-    # Array reference, this is same as above
3212
-    where => [
3213
-        ['and', ':author{=}', ':title{like}'],
3214
-        {author => 'Ken', title => '%Perl%'}
3215
-    ];
3216
-    
3217
-    # String
3218
-    where => 'title is null'
3171
+  
3172
+  # Hash refrence
3173
+  where => {author => 'Ken', 'title' => 'Perl'}
3174
+  
3175
+  # DBIx::Custom::Where object
3176
+  where => $dbi->where(
3177
+    clause => ['and', ':author{=}', ':title{like}'],
3178
+    param  => {author => 'Ken', title => '%Perl%'}
3179
+  );
3180
+  
3181
+  # Array reference, this is same as above
3182
+  where => [
3183
+    ['and', ':author{=}', ':title{like}'],
3184
+    {author => 'Ken', title => '%Perl%'}
3185
+  ];
3186
+  
3187
+  # String
3188
+  where => 'title is null'
3219 3189
 
3220 3190
 Where clause. See L<DBIx::Custom::Where>.
3221
-    
3191
+  
3222 3192
 =back
3223 3193
 
3224 3194
 =head2 C<setup_model>
3225 3195
 
3226
-    $dbi->setup_model;
3196
+  $dbi->setup_model;
3227 3197
 
3228 3198
 Setup all model objects.
3229 3199
 C<columns> of model object is automatically set, parsing database information.
3230 3200
 
3231 3201
 =head2 C<type_rule>
3232 3202
 
3233
-    $dbi->type_rule(
3234
-        into1 => {
3235
-            date => sub { ... },
3236
-            datetime => sub { ... }
3237
-        },
3238
-        into2 => {
3239
-            date => sub { ... },
3240
-            datetime => sub { ... }
3241
-        },
3242
-        from1 => {
3243
-            # DATE
3244
-            9 => sub { ... },
3245
-            # DATETIME or TIMESTAMP
3246
-            11 => sub { ... },
3247
-        }
3248
-        from2 => {
3249
-            # DATE
3250
-            9 => sub { ... },
3251
-            # DATETIME or TIMESTAMP
3252
-            11 => sub { ... },
3253
-        }
3254
-    );
3203
+  $dbi->type_rule(
3204
+    into1 => {
3205
+      date => sub { ... },
3206
+      datetime => sub { ... }
3207
+    },
3208
+    into2 => {
3209
+      date => sub { ... },
3210
+      datetime => sub { ... }
3211
+    },
3212
+    from1 => {
3213
+      # DATE
3214
+      9 => sub { ... },
3215
+      # DATETIME or TIMESTAMP
3216
+      11 => sub { ... },
3217
+    }
3218
+    from2 => {
3219
+      # DATE
3220
+      9 => sub { ... },
3221
+      # DATETIME or TIMESTAMP
3222
+      11 => sub { ... },
3223
+    }
3224
+  );
3255 3225
 
3256 3226
 Filtering rule when data is send into and get from database.
3257 3227
 This has a little complex problem.
... ...
@@ -3272,46 +3242,46 @@ column name.
3272 3242
 
3273 3243
 =item 1. column name
3274 3244
 
3275
-    issue_date
3276
-    issue_datetime
3245
+  issue_date
3246
+  issue_datetime
3277 3247
 
3278 3248
 This need C<table> option in each method.
3279 3249
 
3280 3250
 =item 2. table name and column name, separator is dot
3281 3251
 
3282
-    book.issue_date
3283
-    book.issue_datetime
3252
+  book.issue_date
3253
+  book.issue_datetime
3284 3254
 
3285 3255
 =back
3286 3256
 
3287 3257
 You get all type name used in database by C<available_typename>.
3288 3258
 
3289
-    print $dbi->available_typename;
3259
+  print $dbi->available_typename;
3290 3260
 
3291 3261
 In C<from1> and C<from2> you specify data type, not type name.
3292 3262
 C<from2> is executed after C<from1>.
3293 3263
 You get all data type by C<available_datatype>.
3294 3264
 
3295
-    print $dbi->available_datatype;
3265
+  print $dbi->available_datatype;
3296 3266
 
3297 3267
 You can also specify multiple types at once.
3298 3268
 
3299
-    $dbi->type_rule(
3300
-        into1 => [
3301
-            [qw/DATE DATETIME/] => sub { ... },
3302
-        ],
3303
-    );
3269
+  $dbi->type_rule(
3270
+    into1 => [
3271
+      [qw/DATE DATETIME/] => sub { ... },
3272
+    ],
3273
+  );
3304 3274
 
3305 3275
 =head2 C<update>
3306 3276
 
3307
-    $dbi->update({title => 'Perl'}, table  => 'book', where  => {id => 4});
3277
+  $dbi->update({title => 'Perl'}, table  => 'book', where  => {id => 4});
3308 3278
 
3309 3279
 Execute update statement. First argument is update row data.
3310 3280
 
3311 3281
 If you want to set constant value to row data, use scalar reference
3312 3282
 as parameter value.
3313 3283
 
3314
-    {date => \"NOW()"}
3284
+  {date => \"NOW()"}
3315 3285
 
3316 3286
 B<OPTIONS>
3317 3287
 
... ...
@@ -3322,38 +3292,38 @@ and use the following new ones.
3322 3292
 
3323 3293
 =item C<id>
3324 3294
 
3325
-    id => 4
3326
-    id => [4, 5]
3295
+  id => 4
3296
+  id => [4, 5]
3327 3297
 
3328 3298
 ID corresponding to C<primary_key>.
3329 3299
 You can update rows by C<id> and C<primary_key>.
3330 3300
 
3331
-    $dbi->update(
3332
-        {title => 'Perl', author => 'Ken'}
3333
-        primary_key => ['id1', 'id2'],
3334
-        id => [4, 5],
3335
-        table => 'book'
3336
-    );
3301
+  $dbi->update(
3302
+    {title => 'Perl', author => 'Ken'}
3303
+    primary_key => ['id1', 'id2'],
3304
+    id => [4, 5],
3305
+    table => 'book'
3306
+  );
3337 3307
 
3338 3308
 The above is same as the followin one.
3339 3309
 
3340
-    $dbi->update(
3341
-        {title => 'Perl', author => 'Ken'}
3342
-        where => {id1 => 4, id2 => 5},
3343
-        table => 'book'
3344
-    );
3310
+  $dbi->update(
3311
+    {title => 'Perl', author => 'Ken'}
3312
+    where => {id1 => 4, id2 => 5},
3313
+    table => 'book'
3314
+  );
3345 3315
 
3346 3316
 =item C<prefix>
3347 3317
 
3348
-    prefix => 'or replace'
3318
+  prefix => 'or replace'
3349 3319
 
3350 3320
 prefix before table name section
3351 3321
 
3352
-    update or replace book
3322
+  update or replace book
3353 3323
 
3354 3324
 =item C<table>
3355 3325
 
3356
-    table => 'book'
3326
+  table => 'book'
3357 3327
 
3358 3328
 Table name.
3359 3329
 
... ...
@@ -3363,22 +3333,22 @@ Same as C<select> method's C<where> option.
3363 3333
 
3364 3334
 =item C<wrap>
3365 3335
 
3366
-    wrap => {price => sub { "max($_[0])" }}
3336
+  wrap => {price => sub { "max($_[0])" }}
3367 3337
 
3368 3338
 placeholder wrapped string.
3369 3339
 
3370 3340
 If the following statement
3371 3341
 
3372
-    $dbi->update({price => 100}, table => 'book',
3373
-      {price => sub { "$_[0] + 5" }});
3342
+  $dbi->update({price => 100}, table => 'book',
3343
+    {price => sub { "$_[0] + 5" }});
3374 3344
 
3375 3345
 is executed, the following SQL is executed.
3376 3346
 
3377
-    update book set price =  ? + 5;
3347
+  update book set price =  ? + 5;
3378 3348
 
3379 3349
 =item C<updated_at>
3380 3350
 
3381
-    updated_at => 'updated_datetime'
3351
+  updated_at => 'updated_datetime'
3382 3352
 
3383 3353
 Updated timestamp column name. time when row is updated is set to the column.
3384 3354
 default time format is C<YYYY-mm-dd HH:MM:SS>, which can be changed by
... ...
@@ -3388,25 +3358,25 @@ C<now> attribute.
3388 3358
 
3389 3359
 =head2 C<update_all>
3390 3360
 
3391
-    $dbi->update_all({title => 'Perl'}, table => 'book', );
3361
+  $dbi->update_all({title => 'Perl'}, table => 'book', );
3392 3362
 
3393 3363
 Execute update statement for all rows.
3394 3364
 Options is same as C<update> method.
3395 3365
 
3396 3366
 =head2 C<update_or_insert>
3397
-    
3398
-    # ID
3399
-    $dbi->update_or_insert(
3400
-        {title => 'Perl'},
3401
-        table => 'book',
3402
-        id => 1,
3403
-        primary_key => 'id',
3404
-        option => {
3405
-            select => {
3406
-                 append => 'for update'
3407
-            }
3408
-        }
3409
-    );
3367
+  
3368
+  # ID
3369
+  $dbi->update_or_insert(
3370
+    {title => 'Perl'},
3371
+    table => 'book',
3372
+    id => 1,
3373
+    primary_key => 'id',
3374
+    option => {
3375
+      select => {
3376
+         append => 'for update'
3377
+      }
3378
+    }
3379
+  );
3410 3380
 
3411 3381
 Update or insert.
3412 3382
 
... ...
@@ -3423,17 +3393,17 @@ in C<select>, C<update>, C<delete>, and has the following new ones.
3423 3393
 
3424 3394
 =item C<option>
3425 3395
 
3426
-    option => {
3427
-        select => {
3428
-            append => '...'
3429
-        },
3430
-        insert => {
3431
-            prefix => '...'
3432
-        },
3433
-        update => {
3434
-            filter => {}
3435
-        }
3396
+  option => {
3397
+    select => {
3398
+      append => '...'
3399
+    },
3400
+    insert => {
3401
+      prefix => '...'
3402
+    },
3403
+    update => {
3404
+      filter => {}
3436 3405
     }
3406
+  }
3437 3407
 
3438 3408
 If you want to pass option to each method,
3439 3409
 you can use C<option> option.
... ...
@@ -3442,59 +3412,59 @@ you can use C<option> option.
3442 3412
 
3443 3413
 =item C<select_option>
3444 3414
 
3445
-    select_option => {append => 'for update'}
3415
+  select_option => {append => 'for update'}
3446 3416
 
3447 3417
 select method option,
3448 3418
 select method is used to check the row is already exists.
3449 3419
 
3450 3420
 =head2 C<show_datatype>
3451 3421
 
3452
-    $dbi->show_datatype($table);
3422
+  $dbi->show_datatype($table);
3453 3423
 
3454 3424
 Show data type of the columns of specified table.
3455 3425
 
3456
-    book
3457
-    title: 5
3458
-    issue_date: 91
3426
+  book
3427
+  title: 5
3428
+  issue_date: 91
3459 3429
 
3460 3430
 This data type is used in C<type_rule>'s C<from1> and C<from2>.
3461 3431
 
3462 3432
 =head2 C<show_tables>
3463 3433
 
3464
-    $dbi->show_tables;
3434
+  $dbi->show_tables;
3465 3435
 
3466 3436
 Show tables.
3467 3437
 
3468 3438
 =head2 C<show_typename>
3469 3439
 
3470
-    $dbi->show_typename($table);
3440
+  $dbi->show_typename($table);
3471 3441
 
3472 3442
 Show type name of the columns of specified table.
3473 3443
 
3474
-    book
3475
-    title: varchar
3476
-    issue_date: date
3444
+  book
3445
+  title: varchar
3446
+  issue_date: date
3477 3447
 
3478 3448
 This type name is used in C<type_rule>'s C<into1> and C<into2>.
3479 3449
 
3480 3450
 =head2 C<values_clause>
3481 3451
 
3482
-    my $values_clause = $dbi->values_clause({title => 'a', age => 2});
3452
+  my $values_clause = $dbi->values_clause({title => 'a', age => 2});
3483 3453
 
3484 3454
 Create values clause.
3485 3455
 
3486
-    (title, author) values (title = :title, age = :age);
3456
+  (title, author) values (title = :title, age = :age);
3487 3457
 
3488 3458
 You can use this in insert statement.
3489 3459
 
3490
-    my $insert_sql = "insert into book $values_clause";
3460
+  my $insert_sql = "insert into book $values_clause";
3491 3461
 
3492 3462
 =head2 C<where>
3493 3463
 
3494
-    my $where = $dbi->where(
3495
-        clause => ['and', 'title = :title', 'author = :author'],
3496
-        param => {title => 'Perl', author => 'Ken'}
3497
-    );
3464
+  my $where = $dbi->where(
3465
+    clause => ['and', 'title = :title', 'author = :author'],
3466
+    param => {title => 'Perl', author => 'Ken'}
3467
+  );
3498 3468
 
3499 3469
 Create a new L<DBIx::Custom::Where> object.
3500 3470
 
... ...
@@ -3522,121 +3492,121 @@ L<DBIx::Custom::Model> execute method call L<DBIx::Custom> execute.
3522 3492
 
3523 3493
 L<DBIx::Custom>
3524 3494
 
3525
-    # Attribute methods
3526
-    tag_parse # will be removed 2017/1/1
3527
-    default_dbi_option # will be removed 2017/1/1
3528
-    dbi_option # will be removed 2017/1/1
3529
-    data_source # will be removed at 2017/1/1
3530
-    dbi_options # will be removed at 2017/1/1
3531
-    filter_check # will be removed at 2017/1/1
3532
-    reserved_word_quote # will be removed at 2017/1/1
3533
-    cache_method # will be removed at 2017/1/1
3534
-    
3535
-    # Methods
3536
-    update_timestamp # will be removed at 2017/1/1
3537
-    insert_timestamp # will be removed at 2017/1/1
3538
-    method # will be removed at 2017/1/1
3539
-    assign_param # will be removed at 2017/1/1
3540
-    update_param # will be removed at 2017/1/1
3541
-    insert_param # will be removed at 2017/1/1
3542
-    create_query # will be removed at 2017/1/1
3543
-    apply_filter # will be removed at 2017/1/1
3544
-    select_at # will be removed at 2017/1/1
3545
-    delete_at # will be removed at 2017/1/1
3546
-    update_at # will be removed at 2017/1/1
3547
-    insert_at # will be removed at 2017/1/1
3548
-    register_tag # will be removed at 2017/1/1
3549
-    default_bind_filter # will be removed at 2017/1/1
3550
-    default_fetch_filter # will be removed at 2017/1/1
3551
-    insert_param_tag # will be removed at 2017/1/1
3552
-    register_tag # will be removed at 2017/1/1
3553
-    register_tag_processor # will be removed at 2017/1/1
3554
-    update_param_tag # will be removed at 2017/1/1
3555
-    
3556
-    # Options
3557
-    select column option [COLUMN => ALIAS] syntax # will be removed 2017/1/1
3558
-    execute method id option # will be removed 2017/1/1
3559
-    update timestamp option # will be removed 2017/1/1
3560
-    insert timestamp option # will be removed 2017/1/1
3561
-    select method where_param option # will be removed 2017/1/1
3562
-    delete method where_param option # will be removed 2017/1/1
3563
-    update method where_param option # will be removed 2017/1/1
3564
-    insert method param option # will be removed at 2017/1/1
3565
-    insert method id option # will be removed at 2017/1/1
3566
-    select method relation option # will be removed at 2017/1/1
3567
-    select method column option [COLUMN, as => ALIAS] format
3568
-      # will be removed at 2017/1/1
3569
-    execute method's sqlfilter option # will be removed at 2017/1/1
3570
-    
3571
-    # Others
3572
-    execute($query, ...) # execute method receiving query object.
3573
-                         # this is removed at 2017/1/1
3574
-    execute("select * from {= title}"); # execute method's
3575
-                                        # tag parsing functionality
3576
-                                        # will be removed at 2017/1/1
3577
-    Query caching # will be removed at 2017/1/1
3495
+  # Attribute methods
3496
+  tag_parse # will be removed 2017/1/1
3497
+  default_dbi_option # will be removed 2017/1/1
3498
+  dbi_option # will be removed 2017/1/1
3499
+  data_source # will be removed at 2017/1/1
3500
+  dbi_options # will be removed at 2017/1/1
3501
+  filter_check # will be removed at 2017/1/1
3502
+  reserved_word_quote # will be removed at 2017/1/1
3503
+  cache_method # will be removed at 2017/1/1
3504
+  
3505
+  # Methods
3506
+  update_timestamp # will be removed at 2017/1/1
3507
+  insert_timestamp # will be removed at 2017/1/1
3508
+  method # will be removed at 2017/1/1
3509
+  assign_param # will be removed at 2017/1/1
3510
+  update_param # will be removed at 2017/1/1
3511
+  insert_param # will be removed at 2017/1/1
3512
+  create_query # will be removed at 2017/1/1
3513
+  apply_filter # will be removed at 2017/1/1
3514
+  select_at # will be removed at 2017/1/1
3515
+  delete_at # will be removed at 2017/1/1
3516
+  update_at # will be removed at 2017/1/1
3517
+  insert_at # will be removed at 2017/1/1
3518
+  register_tag # will be removed at 2017/1/1
3519
+  default_bind_filter # will be removed at 2017/1/1
3520
+  default_fetch_filter # will be removed at 2017/1/1
3521
+  insert_param_tag # will be removed at 2017/1/1
3522
+  register_tag # will be removed at 2017/1/1
3523
+  register_tag_processor # will be removed at 2017/1/1
3524
+  update_param_tag # will be removed at 2017/1/1
3525
+  
3526
+  # Options
3527
+  select column option [COLUMN => ALIAS] syntax # will be removed 2017/1/1
3528
+  execute method id option # will be removed 2017/1/1
3529
+  update timestamp option # will be removed 2017/1/1
3530
+  insert timestamp option # will be removed 2017/1/1
3531
+  select method where_param option # will be removed 2017/1/1
3532
+  delete method where_param option # will be removed 2017/1/1
3533
+  update method where_param option # will be removed 2017/1/1
3534
+  insert method param option # will be removed at 2017/1/1
3535
+  insert method id option # will be removed at 2017/1/1
3536
+  select method relation option # will be removed at 2017/1/1
3537
+  select method column option [COLUMN, as => ALIAS] format
3538
+    # will be removed at 2017/1/1
3539
+  execute method's sqlfilter option # will be removed at 2017/1/1
3540
+  
3541
+  # Others
3542
+  execute($query, ...) # execute method receiving query object.
3543
+                       # this is removed at 2017/1/1
3544
+  execute("select * from {= title}"); # execute method's
3545
+                                      # tag parsing functionality
3546
+                                      # will be removed at 2017/1/1
3547
+  Query caching # will be removed at 2017/1/1
3578 3548
 
3579 3549
 L<DBIx::Custom::Model>
3580 3550
 
3581
-    # Attribute methods
3582
-    execute # will be removed at 2017/1/1
3583
-    method # will be removed at 2017/1/1
3584
-    filter # will be removed at 2017/1/1
3585
-    name # will be removed at 2017/1/1
3586
-    type # will be removed at 2017/1/1
3551
+  # Attribute methods
3552
+  execute # will be removed at 2017/1/1
3553
+  method # will be removed at 2017/1/1
3554
+  filter # will be removed at 2017/1/1
3555
+  name # will be removed at 2017/1/1
3556
+  type # will be removed at 2017/1/1
3587 3557
 
3588 3558
 L<DBIx::Custom::Query>
3589 3559
 
3590 3560
 This module is DEPRECATED! # will be removed at 2017/1/1
3591
-    
3592
-    # Attribute methods
3593
-    default_filter # will be removed at 2017/1/1
3594
-    table # will be removed at 2017/1/1
3595
-    filters # will be removed at 2017/1/1
3596
-    
3597
-    # Methods
3598
-    filter # will be removed at 2017/1/1
3561
+  
3562
+  # Attribute methods
3563
+  default_filter # will be removed at 2017/1/1
3564
+  table # will be removed at 2017/1/1
3565
+  filters # will be removed at 2017/1/1
3566
+  
3567
+  # Methods
3568
+  filter # will be removed at 2017/1/1
3599 3569
 
3600 3570
 L<DBIx::Custom::QueryBuilder>
3601 3571
 
3602 3572
 This module is DEPRECATED! # will be removed at 2017/1/1
3603
-    
3604
-    # Attribute methods
3605
-    tags # will be removed at 2017/1/1
3606
-    tag_processors # will be removed at 2017/1/1
3607
-    
3608
-    # Methods
3609
-    register_tag # will be removed at 2017/1/1
3610
-    register_tag_processor # will be removed at 2017/1/1
3611
-    
3612
-    # Others
3613
-    build_query("select * from {= title}"); # tag parsing functionality
3614
-                                            # will be removed at 2017/1/1
3573
+  
3574
+  # Attribute methods
3575
+  tags # will be removed at 2017/1/1
3576
+  tag_processors # will be removed at 2017/1/1
3577
+  
3578
+  # Methods
3579
+  register_tag # will be removed at 2017/1/1
3580
+  register_tag_processor # will be removed at 2017/1/1
3581
+  
3582
+  # Others
3583
+  build_query("select * from {= title}"); # tag parsing functionality
3584
+                                          # will be removed at 2017/1/1
3615 3585
 
3616 3586
 L<DBIx::Custom::Result>
3617
-    
3618
-    # Attribute methods
3619
-    filter_check # will be removed at 2017/1/1
3620
-    
3621
-    # Methods
3622
-    fetch_first # will be removed at 2017/2/1
3623
-    fetch_hash_first # will be removed 2017/2/1
3624
-    filter_on # will be removed at 2017/1/1
3625
-    filter_off # will be removed at 2017/1/1
3626
-    end_filter # will be removed at 2017/1/1
3627
-    remove_end_filter # will be removed at 2017/1/1
3628
-    remove_filter # will be removed at 2017/1/1
3629
-    default_filter # will be removed at 2017/1/1
3587
+  
3588
+  # Attribute methods
3589
+  filter_check # will be removed at 2017/1/1
3590
+  
3591
+  # Methods
3592
+  fetch_first # will be removed at 2017/2/1
3593
+  fetch_hash_first # will be removed 2017/2/1
3594
+  filter_on # will be removed at 2017/1/1
3595
+  filter_off # will be removed at 2017/1/1
3596
+  end_filter # will be removed at 2017/1/1
3597
+  remove_end_filter # will be removed at 2017/1/1
3598
+  remove_filter # will be removed at 2017/1/1
3599
+  default_filter # will be removed at 2017/1/1
3630 3600
 
3631 3601
 L<DBIx::Custom::Tag>
3632 3602
 
3633
-    This module is DEPRECATED! # will be removed at 2017/1/1
3603
+  This module is DEPRECATED! # will be removed at 2017/1/1
3634 3604
 
3635 3605
 L<DBIx::Custom::Order>
3636 3606
 
3637
-    # Other
3638
-    prepend method array reference receiving
3639
-      $order->prepend(['book', 'desc']); # will be removed 2017/1/1
3607
+  # Other
3608
+  prepend method array reference receiving
3609
+    $order->prepend(['book', 'desc']); # will be removed 2017/1/1
3640 3610
 
3641 3611
 =head1 BACKWARDS COMPATIBILITY POLICY
3642 3612
 
+144 -146
lib/DBIx/Custom/Mapper.pm
... ...
@@ -10,119 +10,117 @@ use DBIx::Custom::Util '_subname';
10 10
 push @DBIx::Custom::CARP_NOT, __PACKAGE__;
11 11
 
12 12
 has [qw/param/],
13
-    condition => sub {
14
-        sub { defined $_[0] && length $_[0] }
15
-    },
16
-    pass => sub { [] };
13
+  condition => sub {
14
+    sub { defined $_[0] && length $_[0] }
15
+  },
16
+  pass => sub { [] };
17 17
 
18 18
 sub map {
19
-    my ($self, %rule) = @_;
20
-    my $param = $self->param;
21
-    $rule{$_} = {key => $_} for @{$self->pass};
19
+  my ($self, %rule) = @_;
20
+  my $param = $self->param;
21
+  $rule{$_} = {key => $_} for @{$self->pass};
22
+  
23
+  # Mapping
24
+  my $new_param = {};
25
+  for my $key (keys %rule) {
22 26
     
23
-    # Mapping
24
-    my $new_param = {};
25
-    for my $key (keys %rule) {
26
-        
27
-        my $mapping = $rule{$key};
28
-        
29
-        # Get mapping information
30
-        my $new_key;
31
-        my $value;
32
-        my $condition;
33
-        
34
-        if (ref $mapping eq 'ARRAY') {
35
-            $new_key = $mapping->[0];
36
-            $value = $mapping->[1];
37
-            $condition = ref $mapping->[2] eq 'HASH' ? $mapping->[2]->{condition} : $mapping->[2];
38
-        }
39
-        elsif (ref $mapping eq 'HASH') {
40
-            $new_key = $mapping->{key};
41
-            $value = $mapping->{value};
42
-            $condition = $mapping->{condition};
43
-        }
44
-        elsif (!ref $mapping) {
45
-            $new_key = $mapping;
46
-            warn qq/map method's string value "$mapping" is DEPRECATED. / .
47
-                 qq/use {key => ...} syntax instead/
27
+    my $mapping = $rule{$key};
28
+    
29
+    # Get mapping information
30
+    my $new_key;
31
+    my $value;
32
+    my $condition;
33
+    
34
+    if (ref $mapping eq 'ARRAY') {
35
+      $new_key = $mapping->[0];
36
+      $value = $mapping->[1];
37
+      $condition = ref $mapping->[2] eq 'HASH' ? $mapping->[2]->{condition} : $mapping->[2];
38
+    }
39
+    elsif (ref $mapping eq 'HASH') {
40
+      $new_key = $mapping->{key};
41
+      $value = $mapping->{value};
42
+      $condition = $mapping->{condition};
43
+    }
44
+    elsif (!ref $mapping) {
45
+      $new_key = $mapping;
46
+      warn qq/map method's string value "$mapping" is DEPRECATED. / .
47
+           qq/use {key => ...} syntax instead/
48
+    }
49
+    elsif (ref $mapping eq 'CODE') {
50
+      $value = $mapping;
51
+      warn qq/map method's code reference value "$mapping" is DEPRECATED. / .
52
+           qq/use {value => ...} syntax instead/
53
+    }
54
+    
55
+    $new_key = $key unless defined $new_key;
56
+    $condition ||= $self->condition;
57
+    $condition = $self->_condition_to_sub($condition);
58
+
59
+    # Map parameter
60
+    if (ref $condition eq 'CODE') {
61
+      if (ref $param->{$key} eq 'ARRAY') {
62
+        $new_param->{$new_key} = [];
63
+        for (my $i = 0; $i < @{$param->{$key}}; $i++) {
64
+          $new_param->{$new_key}->[$i]
65
+            = $condition->($param->{$key}->[$i]) ? $param->{$key}->[$i]
66
+            : DBIx::Custom::NotExists->singleton;
48 67
         }
49
-        elsif (ref $mapping eq 'CODE') {
50
-            $value = $mapping;
51
-            warn qq/map method's code reference value "$mapping" is DEPRECATED. / .
52
-                 qq/use {value => ...} syntax instead/
68
+      }
69
+      else {
70
+        if ($condition->($param->{$key})) {
71
+          $new_param->{$new_key} = defined $value
72
+            ? $value->($param->{$key}) : $param->{$key};
53 73
         }
54
-        
55
-        $new_key = $key unless defined $new_key;
56
-        $condition ||= $self->condition;
57
-        $condition = $self->_condition_to_sub($condition);
58
-
59
-        # Map parameter
60
-        if (ref $condition eq 'CODE') {
61
-            if (ref $param->{$key} eq 'ARRAY') {
62
-                $new_param->{$new_key} = [];
63
-                for (my $i = 0; $i < @{$param->{$key}}; $i++) {
64
-                    $new_param->{$new_key}->[$i]
65
-                      = $condition->($param->{$key}->[$i]) ? $param->{$key}->[$i]
66
-                      : DBIx::Custom::NotExists->singleton;
67
-                }
68
-            }
69
-            else {
70
-              if ($condition->($param->{$key})) {
71
-                  $new_param->{$new_key} = defined $value
72
-                                         ? $value->($param->{$key})
73
-                                         : $param->{$key};
74
-              }
75
-            }
74
+      }
75
+    }
76
+    elsif ($condition eq 'exists') {
77
+      if (ref $param->{$key} eq 'ARRAY') {
78
+        $new_param->{$new_key} = [];
79
+        for (my $i = 0; $i < @{$param->{$key}}; $i++) {
80
+          $new_param->{$new_key}->[$i]
81
+            = exists $param->{$key}->[$i] ? $param->{$key}->[$i]
82
+            : DBIx::Custom::NotExists->singleton;
76 83
         }
77
-        elsif ($condition eq 'exists') {
78
-            if (ref $param->{$key} eq 'ARRAY') {
79
-                $new_param->{$new_key} = [];
80
-                for (my $i = 0; $i < @{$param->{$key}}; $i++) {
81
-                    $new_param->{$new_key}->[$i]
82
-                      = exists $param->{$key}->[$i] ? $param->{$key}->[$i]
83
-                      : DBIx::Custom::NotExists->singleton;
84
-                }
85
-            }
86
-            else {
87
-                if (exists $param->{$key}) {
88
-                    $new_param->{$new_key} = defined $value
89
-                                           ? $value->($param->{$key})
90
-                                           : $param->{$key};
91
-                }
92
-            }
84
+      }
85
+      else {
86
+        if (exists $param->{$key}) {
87
+          $new_param->{$new_key} = defined $value
88
+            ? $value->($param->{$key}) : $param->{$key};
93 89
         }
94
-        else { croak qq/Condition must be code reference or "exists" / . _subname }
90
+      }
95 91
     }
96
-    
97
-    return $new_param;
92
+    else { croak qq/Condition must be code reference or "exists" / . _subname }
93
+  }
94
+  
95
+  return $new_param;
98 96
 }
99 97
 
100 98
 sub new {
101
-    my $self = shift->SUPER::new(@_);
102
-    
103
-    # Check attribute names
104
-    my @attrs = keys %$self;
105
-    for my $attr (@attrs) {
106
-        croak qq{"$attr" is invalid attribute name (} . _subname . ")"
107
-          unless $self->can($attr);
108
-    }
109
-    
110
-    return $self;
99
+  my $self = shift->SUPER::new(@_);
100
+  
101
+  # Check attribute names
102
+  my @attrs = keys %$self;
103
+  for my $attr (@attrs) {
104
+    croak qq{"$attr" is invalid attribute name (} . _subname . ")"
105
+      unless $self->can($attr);
106
+  }
107
+  
108
+  return $self;
111 109
 }
112 110
 
113 111
 
114 112
 sub _condition_to_sub {
115
-    my ($self, $if) = @_;
116
-    $if = $if eq 'exists' ? $if
117
-            : $if eq 'defined' ? sub { defined $_[0] }
118
-            : $if eq 'length'  ? sub { defined $_[0] && length $_[0] }
119
-            : ref $if eq 'CODE' ? $if
120
-            : undef;
121
-
122
-    croak "You can must specify right value to C<condition> " . _subname
123
-      unless $if;
124
-    
125
-    return $if;
113
+  my ($self, $if) = @_;
114
+  $if = $if eq 'exists' ? $if
115
+    : $if eq 'defined' ? sub { defined $_[0] }
116
+    : $if eq 'length'  ? sub { defined $_[0] && length $_[0] }
117
+    : ref $if eq 'CODE' ? $if
118
+    : undef;
119
+
120
+  croak "You can must specify right value to C<condition> " . _subname
121
+    unless $if;
122
+  
123
+  return $if;
126 124
 }
127 125
 
128 126
 1;
... ...
@@ -133,33 +131,33 @@ DBIx::Custom::Mapper - Mapper of parameter
133 131
 
134 132
 =head1 SYNOPSYS
135 133
 
136
-    my $mapper = $dbi->mapper(param => $param);
137
-    my $new_param = $mapper->map(
138
-        title => 'book.title', # Key
139
-        author => sub { '%' . $_[0] . '%'} # Value
140
-        price => ['book.price' => sub { '%' . $_[0] . '%' }], # Key and value
141
-    );
134
+  my $mapper = $dbi->mapper(param => $param);
135
+  my $new_param = $mapper->map(
136
+    title => 'book.title', # Key
137
+    author => sub { '%' . $_[0] . '%'} # Value
138
+    price => ['book.price' => sub { '%' . $_[0] . '%' }], # Key and value
139
+  );
142 140
 
143 141
 =head1 ATTRIBUTES
144 142
 
145 143
 =head2 C<param>
146 144
 
147
-    my $param = $mapper->param;
148
-    $mapper = $mapper->param({title => 'Perl', author => 'Ken'});
145
+  my $param = $mapper->param;
146
+  $mapper = $mapper->param({title => 'Perl', author => 'Ken'});
149 147
 
150 148
 Parameter.
151 149
 
152 150
 =head2 C<pass>
153 151
 
154
-    my $pass = $mapper->pass;
155
-    $mapper = $mapper->pass([qw/title author/]);
152
+  my $pass = $mapper->pass;
153
+  $mapper = $mapper->pass([qw/title author/]);
156 154
 
157 155
 the key and value is copied without change when C<map> method is executed.
158 156
 
159 157
 =head2 C<condition>
160 158
 
161
-    my $condition = $mapper->condition;
162
-    $mapper = $mapper->condition('exists');
159
+  my $condition = $mapper->condition;
160
+  $mapper = $mapper->condition('exists');
163 161
 
164 162
 Mapping condtion, default to C<length>.
165 163
 
... ...
@@ -168,26 +166,26 @@ You can set the following values to C<condition>.
168 166
 =over 4
169 167
 
170 168
 =item * C<exists>
171
-   
172
-    condition => 'exists'
169
+ 
170
+  condition => 'exists'
173 171
 
174 172
 If key exists, key and value is mapped.
175 173
 
176 174
 =item * C<defined>
177 175
 
178
-    condition => 'defined';
176
+  condition => 'defined';
179 177
 
180 178
 If value is defined, key and value is mapped.
181 179
 
182 180
 =item * C<length>
183 181
 
184
-    condition => 'length';
182
+  condition => 'length';
185 183
 
186 184
 If value is defined and has length, key and value is mapped.
187 185
 
188 186
 =item * C<code reference>
189 187
 
190
-    condition => sub { defined $_[0] }
188
+  condition => sub { defined $_[0] }
191 189
 
192 190
 You can set code reference to C<condtion>.
193 191
 The subroutine return true, key and value is mapped.
... ...
@@ -199,61 +197,61 @@ and implements the following new ones.
199 197
 
200 198
 =head2 C<map>
201 199
 
202
-    my $new_param = $mapper->map(
203
-        price => {key => 'book.price'}
204
-        title => {value => sub { '%' . $_[0] . '%'}}
205
-        author => ['book.author' => sub { '%' . $_[0] . '%'}] # Key and value
206
-    );
200
+  my $new_param = $mapper->map(
201
+    price => {key => 'book.price'}
202
+    title => {value => sub { '%' . $_[0] . '%'}}
203
+    author => ['book.author' => sub { '%' . $_[0] . '%'}] # Key and value
204
+  );
207 205
 
208 206
 Map C<param> into new parameter.
209 207
 
210 208
 For example, if C<param> is set to
211 209
 
212
-    {
213
-        price => 1900,
214
-        title => 'Perl',
215
-        author => 'Ken',
216
-        issue_date => '2010-11-11'
217
-    }
210
+  {
211
+    price => 1900,
212
+    title => 'Perl',
213
+    author => 'Ken',
214
+    issue_date => '2010-11-11'
215
+  }
218 216
 
219 217
 The following hash reference is returned.
220 218
 
221
-    {
222
-        'book.price' => 1900,
223
-        title => '%Perl%',
224
-        'book.author' => '%Ken%',
225
-    }
219
+  {
220
+    'book.price' => 1900,
221
+    title => '%Perl%',
222
+    'book.author' => '%Ken%',
223
+  }
226 224
 
227 225
 By default, If the value has length, key and value is mapped.
228 226
 
229
-    title => 'Perl'  # Mapped
230
-    {title => '' }   # Not mapped
231
-    {title => undef} # Not mapped
232
-    {}               # Not mapped
227
+  title => 'Perl'  # Mapped
228
+  {title => '' }   # Not mapped
229
+  {title => undef} # Not mapped
230
+  {}               # Not mapped
233 231
 
234 232
 You can set change mapping condition by C<condition> attribute.
235 233
 
236
-    $mapper->condition('defined');
234
+  $mapper->condition('defined');
237 235
 
238 236
 Or you can set C<condtion> option for each key.
239 237
 
240
-    my $new_param = $mapper->map(
241
-        price => {key => 'book.price', condition => 'defined'}]
242
-        title => {value => sub { '%' . $_[0] . '%'}, condition => 'defined'}
243
-        author => ['book.author', sub { '%' . $_[0] . '%'}, 'exists']
244
-    );
238
+  my $new_param = $mapper->map(
239
+    price => {key => 'book.price', condition => 'defined'}]
240
+    title => {value => sub { '%' . $_[0] . '%'}, condition => 'defined'}
241
+    author => ['book.author', sub { '%' . $_[0] . '%'}, 'exists']
242
+  );
245 243
 
246 244
 If C<pass> attrivute is set, the keys and value is copied without change.
247 245
 
248
-    $mapper->pass([qw/title author/]);
249
-    my $new_param = $mapper->map(price => {key => 'book.price'});
246
+  $mapper->pass([qw/title author/]);
247
+  my $new_param = $mapper->map(price => {key => 'book.price'});
250 248
 
251 249
 The following hash reference
252
-    
253
-    {title => 'Perl', author => 'Ken', price => 1900}
250
+  
251
+  {title => 'Perl', author => 'Ken', price => 1900}
254 252
 
255 253
 is mapped to
256 254
 
257
-    {title => 'Perl', author => 'Ken', 'book.price' => 1900}
255
+  {title => 'Perl', author => 'Ken', 'book.price' => 1900}
258 256
 
259 257
 =cut
+173 -175
lib/DBIx/Custom/Model.pm
... ...
@@ -8,151 +8,149 @@ use DBIx::Custom::Util '_subname';
8 8
 push @DBIx::Custom::CARP_NOT, __PACKAGE__;
9 9
 
10 10
 has [qw/dbi table created_at updated_at bind_type join primary_key/],
11
-    columns => sub { [] };
11
+  columns => sub { [] };
12 12
 
13 13
 our $AUTOLOAD;
14 14
 
15 15
 sub AUTOLOAD {
16
-    my $self = shift;
17
-
18
-    # Method name
19
-    my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
20
-
21
-    # Method
22
-    $self->{_methods} ||= {};
23
-    if (my $method = $self->{_methods}->{$mname}) {
24
-        return $self->$method(@_)
25
-    }
26
-    elsif (my $dbi_method = $self->dbi->can($mname)) {
27
-        $self->dbi->$dbi_method(@_);
28
-    }
29
-    elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
30
-        $self->dbi->dbh->$dbh_method(@_);
31
-    }
32
-    else {
33
-        croak qq{Can't locate object method "$mname" via "$package" }
34
-            . _subname;
35
-    }
16
+  my $self = shift;
17
+
18
+  # Method name
19
+  my ($package, $mname) = $AUTOLOAD =~ /^([\w\:]+)\:\:(\w+)$/;
20
+
21
+  # Method
22
+  $self->{_methods} ||= {};
23
+  if (my $method = $self->{_methods}->{$mname}) {
24
+    return $self->$method(@_)
25
+  }
26
+  elsif (my $dbi_method = $self->dbi->can($mname)) {
27
+    $self->dbi->$dbi_method(@_);
28
+  }
29
+  elsif ($self->{dbh} && (my $dbh_method = $self->dbh->can($mname))) {
30
+    $self->dbi->dbh->$dbh_method(@_);
31
+  }
32
+  else {
33
+    croak qq{Can't locate object method "$mname" via "$package" }
34
+      . _subname;
35
+  }
36 36
 }
37 37
 
38 38
 my @methods = qw/insert insert_at update update_at update_all
39
-  delete delete_at delete_all select select_at count/;
39
+delete delete_at delete_all select select_at count/;
40 40
 for my $method (@methods) {
41
-    
42
-    my $code =
43
-         qq/sub {/ .
44
-         qq/my \$self = shift;/ .
45
-         qq/\$self->dbi->$method(/ .
46
-             qq/\@_ % 2 ? shift : (),/;
47
-
48
-    
49
-    my @attrs = qw/table type primary_key bind_type/;
50
-    my @insert_attrs = qw/created_at updated_at/;
51
-    my @update_attrs = qw/updated_at/;
52
-    my @select_attrs = qw/join/;
53
-    if ($method eq 'insert') { push @attrs, @insert_attrs }
54
-    elsif ($method eq 'update') { push @attrs, @update_attrs }
55
-    elsif (index($method, 'select') != -1 || $method eq 'count') {
56
-        push @attrs, @select_attrs
57
-    }
58
-    
59
-    for my $attr (@attrs) {
60
-        $code .= "exists \$self->{$attr} ? ($attr => \$self->{$attr}) : (),";
61
-    }
62
-    
63
-    $code .= qq/\@_);/ .
64
-         qq/}/;
65
-    
66
-    no strict 'refs';
67
-    *{__PACKAGE__ . "::$method"} = eval $code;
68
-    croak $code if $@;
41
+  
42
+  my $code =
43
+       qq/sub {/ .
44
+       qq/my \$self = shift;/ .
45
+       qq/\$self->dbi->$method(/ .
46
+           qq/\@_ % 2 ? shift : (),/;
47
+
48
+  
49
+  my @attrs = qw/table type primary_key bind_type/;
50
+  my @insert_attrs = qw/created_at updated_at/;
51
+  my @update_attrs = qw/updated_at/;
52
+  my @select_attrs = qw/join/;
53
+  if ($method eq 'insert') { push @attrs, @insert_attrs }
54
+  elsif ($method eq 'update') { push @attrs, @update_attrs }
55
+  elsif (index($method, 'select') != -1 || $method eq 'count') {
56
+    push @attrs, @select_attrs
57
+  }
58
+  
59
+  for my $attr (@attrs) {
60
+    $code .= "exists \$self->{$attr} ? ($attr => \$self->{$attr}) : (),";
61
+  }
62
+  
63
+  $code .= qq/\@_);/ .
64
+       qq/}/;
65
+  
66
+  no strict 'refs';
67
+  *{__PACKAGE__ . "::$method"} = eval $code;
68
+  croak $code if $@;
69 69
 }
70 70
 
71 71
 sub update_or_insert {
72
-    my ($self, $param, %opt) = @_;
73
-    
74
-    croak "update_or_insert method need primary_key and id option "
75
-      unless (defined $opt{id} || defined $self->{id})
76
-          && (defined $opt{primary_key} || defined $self->{primary_key});
77
-    
78
-    my $statement_opt = $opt{option} || {};
79
-    my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
80
-    if (@$rows == 0) {
81
-        return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
82
-    }
83
-    elsif (@$rows == 1) {
84
-        return $self->update($param, %opt, %{$statement_opt->{update} || {}});
85
-    }
86
-    else {
87
-        croak "selected row must be one " . _subname;
88
-    }
72
+  my ($self, $param, %opt) = @_;
73
+  
74
+  croak "update_or_insert method need primary_key and id option "
75
+    unless (defined $opt{id} || defined $self->{id})
76
+        && (defined $opt{primary_key} || defined $self->{primary_key});
77
+  
78
+  my $statement_opt = $opt{option} || {};
79
+  my $rows = $self->select(%opt, %{$statement_opt->{select} || {}})->all;
80
+  if (@$rows == 0) {
81
+    return $self->insert($param, %opt, %{$statement_opt->{insert} || {}});
82
+  }
83
+  elsif (@$rows == 1) {
84
+    return $self->update($param, %opt, %{$statement_opt->{update} || {}});
85
+  }
86
+  else { croak "selected row must be one " . _subname }
89 87
 }
90 88
 
91 89
 sub execute {
92
-    my $self = shift;
93
-    
94
-    if ($ENV{DBIX_CUSTOM_DISABLE_MODEL_EXECUTE}) {
95
-        $self->dbi->execute(@_);
96
-    }
97
-    else {
98
-        warn "DBIx::Custom::Model execute method is DEPRECATED! " .
99
-             "use DBIx::Custom execute method. " .
100
-             "If you want to call DBIx::Custom execute method directory from model, " .
101
-             "set \$ENV{DBIX_CUSTOM_DISABLE_MODEL_EXECUTE} to 1 " .
102
-             "until DBIx::Custom::Model execute method is removed in the future." ;
103
-        return $self->dbi->execute(
104
-            shift,
105
-            shift,
106
-            table => $self->table,
107
-            bind_type => $self->bind_type,
108
-            primary_key => $self->primary_key,
109
-            type => $self->type,
110
-            @_
111
-        );    
112
-    }
90
+  my $self = shift;
91
+  
92
+  if ($ENV{DBIX_CUSTOM_DISABLE_MODEL_EXECUTE}) {
93
+      $self->dbi->execute(@_);
94
+  }
95
+  else {
96
+    warn "DBIx::Custom::Model execute method is DEPRECATED! " .
97
+     "use DBIx::Custom execute method. " .
98
+     "If you want to call DBIx::Custom execute method directory from model, " .
99
+     "set \$ENV{DBIX_CUSTOM_DISABLE_MODEL_EXECUTE} to 1 " .
100
+     "until DBIx::Custom::Model execute method is removed in the future." ;
101
+    return $self->dbi->execute(
102
+      shift,
103
+      shift,
104
+      table => $self->table,
105
+      bind_type => $self->bind_type,
106
+      primary_key => $self->primary_key,
107
+      type => $self->type,
108
+      @_
109
+    );    
110
+  }
113 111
 }
114 112
 
115 113
 sub DESTROY { }
116 114
 
117 115
 sub helper {
118
-    my $self = shift;
119
-    
120
-    # Merge
121
-    my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
122
-    $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
123
-    
124
-    return $self;
116
+  my $self = shift;
117
+  
118
+  # Merge
119
+  my $methods = ref $_[0] eq 'HASH' ? $_[0] : {@_};
120
+  $self->{_methods} = {%{$self->{_methods} || {}}, %$methods};
121
+  
122
+  return $self;
125 123
 }
126 124
 
127 125
 sub mycolumn {
128
-    my $self = shift;
129
-    my $table = shift unless ref $_[0];
130
-    my $columns = shift;
131
-    
132
-    $table ||= $self->table || '';
133
-    $columns ||= $self->columns;
134
-    
135
-    return $self->dbi->mycolumn($table, $columns);
126
+  my $self = shift;
127
+  my $table = shift unless ref $_[0];
128
+  my $columns = shift;
129
+  
130
+  $table ||= $self->table || '';
131
+  $columns ||= $self->columns;
132
+  
133
+  return $self->dbi->mycolumn($table, $columns);
136 134
 }
137 135
 
138 136
 sub new {
139
-    my $self = shift->SUPER::new(@_);
140
-    
141
-    # Check attribute names
142
-    my @attrs = keys %$self;
143
-    for my $attr (@attrs) {
144
-        croak qq{"$attr" is invalid attribute name } . _subname
145
-          unless $self->can($attr);
146
-    }
147
-    
148
-    # Cache
149
-    for my $attr (qw/dbi table created_at updated_at bind_type join primary_key/) {
150
-        $self->$attr;
151
-        $self->{$attr} = undef unless exists $self->{$attr};
152
-    }
153
-    $self->columns;
154
-    
155
-    return $self;
137
+  my $self = shift->SUPER::new(@_);
138
+  
139
+  # Check attribute names
140
+  my @attrs = keys %$self;
141
+  for my $attr (@attrs) {
142
+    croak qq{"$attr" is invalid attribute name } . _subname
143
+      unless $self->can($attr);
144
+  }
145
+  
146
+  # Cache
147
+  for my $attr (qw/dbi table created_at updated_at bind_type join primary_key/) {
148
+    $self->$attr;
149
+    $self->{$attr} = undef unless exists $self->{$attr};
150
+  }
151
+  $self->columns;
152
+  
153
+  return $self;
156 154
 }
157 155
 
158 156
 # DEPRECATED!
... ...
@@ -160,11 +158,10 @@ has 'filter';
160 158
 has 'name';
161 159
 has 'type';
162 160
 
163
-
164 161
 # DEPRECATED!
165 162
 sub method {
166
-    warn "method method is DEPRECATED! use helper instead";
167
-    return shift->helper(@_);
163
+  warn "method method is DEPRECATED! use helper instead";
164
+  return shift->helper(@_);
168 165
 }
169 166
 
170 167
 1;
... ...
@@ -183,55 +180,55 @@ my $model = DBIx::Custom::Model->new(table => 'books');
183 180
 
184 181
 =head2 C<dbi>
185 182
 
186
-    my $dbi = $model->dbi;
187
-    $model = $model->dbi($dbi);
183
+  my $dbi = $model->dbi;
184
+  $model = $model->dbi($dbi);
188 185
 
189 186
 L<DBIx::Custom> object.
190 187
 
191 188
 =head2 C<created_at EXPERIMENTAL>
192 189
 
193
-    my $created_at = $model->created_at;
194
-    $model = $model->created_at('created_datatime');
190
+  my $created_at = $model->created_at;
191
+  $model = $model->created_at('created_datatime');
195 192
 
196 193
 Create timestamp column, this is passed to C<insert> or C<update> method.
197 194
 
198 195
 =head2 C<join>
199 196
 
200
-    my $join = $model->join;
201
-    $model = $model->join(
202
-        ['left outer join company on book.company_id = company.id']
203
-    );
204
-    
197
+  my $join = $model->join;
198
+  $model = $model->join(
199
+    ['left outer join company on book.company_id = company.id']
200
+  );
201
+  
205 202
 Join clause, this value is passed to C<select> method.
206 203
 
207 204
 =head2 C<primary_key>
208 205
 
209
-    my $primary_key = $model->primary_key;
210
-    $model = $model->primary_key(['id', 'number']);
206
+  my $primary_key = $model->primary_key;
207
+  $model = $model->primary_key(['id', 'number']);
211 208
 
212 209
 Primary key,this is passed to C<insert>, C<update>,
213 210
 C<delete>, and C<select> method.
214 211
 
215 212
 =head2 C<table>
216 213
 
217
-    my $model = $model->table;
218
-    $model = $model->table('book');
214
+  my $model = $model->table;
215
+  $model = $model->table('book');
219 216
 
220 217
 Table name, this is passed to C<select> method.
221 218
 
222 219
 =head2 C<bind_type>
223 220
 
224
-    my $type = $model->bind_type;
225
-    $model = $model->bind_type(['image' => DBI::SQL_BLOB]);
226
-    
221
+  my $type = $model->bind_type;
222
+  $model = $model->bind_type(['image' => DBI::SQL_BLOB]);
223
+  
227 224
 Database data type, this is used as type optioon of C<insert>, 
228 225
 C<update>, C<update_all>, C<delete>, C<delete_all>,
229 226
 and C<select> method
230 227
 
231 228
 =head2 C<updated_at EXPERIMENTAL>
232 229
 
233
-    my $updated_at = $model->updated_at;
234
-    $model = $model->updated_at('updated_datatime');
230
+  my $updated_at = $model->updated_at;
231
+  $model = $model->updated_at('updated_datatime');
235 232
 
236 233
 Updated timestamp column, this is passed to C<update> method.
237 234
 
... ...
@@ -243,7 +240,7 @@ and implements the following new ones.
243 240
 
244 241
 =head2 C<count>
245 242
 
246
-    my $count = $model->count;
243
+  my $count = $model->count;
247 244
 
248 245
 Get rows count.
249 246
 
... ...
@@ -251,89 +248,90 @@ Options is same as C<select> method's ones.
251 248
 
252 249
 =head2 C<delete>
253 250
 
254
-    $model->delete(...);
255
-    
251
+  $model->delete(...);
252
+  
256 253
 Same as C<delete> of L<DBIx::Custom> except that
257 254
 you don't have to specify options if you set attribute in model.
258 255
 
259 256
 =head2 C<delete_all>
260 257
 
261
-    $model->delete_all(...);
262
-    
258
+  $model->delete_all(...);
259
+  
263 260
 Same as C<delete_all> of L<DBIx::Custom> except that
264 261
 you don't have to specify options if you set attribute in model.
265 262
 
266 263
 =head2 C<insert>
267 264
 
268
-    $model->insert(...);
269
-    
265
+  $model->insert(...);
266
+  
270 267
 Same as C<insert> of L<DBIx::Custom> except that
271 268
 you don't have to specify options if you set attribute in model.
272 269
 
273 270
 =head2 C<helper>
274 271
 
275
-    $model->helper(
276
-        update_or_insert => sub {
277
-            my $self = shift;
278
-            
279
-            # ...
280
-        },
281
-        find_or_create   => sub {
282
-            my $self = shift;
283
-            
284
-            # ...
285
-    );
272
+  $model->helper(
273
+    update_or_insert => sub {
274
+      my $self = shift;
275
+      
276
+      # ...
277
+    },
278
+    find_or_create   => sub {
279
+      my $self = shift;
280
+      
281
+      # ...
282
+    }
283
+  );
286 284
 
287 285
 Register helper. These helper is called directly from L<DBIx::Custom::Model> object.
288 286
 
289
-    $model->update_or_insert;
290
-    $model->find_or_create;
287
+  $model->update_or_insert;
288
+  $model->find_or_create;
291 289
 
292 290
 =head2 C<mycolumn>
293 291
 
294
-    my $column = $self->mycolumn;
295
-    my $column = $self->mycolumn(book => ['author', 'title']);
296
-    my $column = $self->mycolumn(['author', 'title']);
292
+  my $column = $self->mycolumn;
293
+  my $column = $self->mycolumn(book => ['author', 'title']);
294
+  my $column = $self->mycolumn(['author', 'title']);
297 295
 
298 296
 Create column clause for myself. The follwoing column clause is created.
299 297
 
300
-    book.author as author,
301
-    book.title as title
298
+  book.author as author,
299
+  book.title as title
302 300
 
303 301
 If table name is ommited, C<table> attribute of the model is used.
304 302
 If column names is omitted, C<columns> attribute of the model is used.
305 303
 
306 304
 =head2 C<new>
307 305
 
308
-    my $model = DBIx::Custom::Model->new;
306
+  my $model = DBIx::Custom::Model->new;
309 307
 
310 308
 Create a L<DBIx::Custom::Model> object.
311 309
 
312 310
 =head2 C<select>
313 311
 
314
-    $model->select(...);
315
-    
312
+  $model->select(...);
313
+  
316 314
 Same as C<select> of L<DBIx::Custom> except that
317 315
 you don't have to specify options if you set attribute in model.
318 316
 
319 317
 =head2 C<update>
320 318
 
321
-    $model->update(...);
322
-    
319
+  $model->update(...);
320
+  
323 321
 Same as C<update> of L<DBIx::Custom> except that
324 322
 you don't have to specify options if you set attribute in model.
325 323
 
326 324
 =head2 C<update_all>
327 325
 
328
-    $model->update_all(param => \%param);
329
-    
326
+  $model->update_all(param => \%param);
327
+  
330 328
 Same as C<update_all> of L<DBIx::Custom> except that
331 329
 you don't have to specify options if you set attribute in model.
332 330
 
333 331
 =head2 C<update_or_insert>
334 332
 
335
-    $model->update_or_insert(...);
336
-    
333
+  $model->update_or_insert(...);
334
+  
337 335
 Same as C<update> of L<DBIx::Custom> except that
338 336
 you don't have to specify options if you set attribute in model.
339 337
 
+2 -2
lib/DBIx/Custom/NotExists.pm
... ...
@@ -13,13 +13,13 @@ DBIx::Custom::NotExists
13 13
 
14 14
 =head1 SYNOPSYS
15 15
 
16
-    $not_exists = DBIx::Custom::NotExists->singleton;
16
+  $not_exists = DBIx::Custom::NotExists->singleton;
17 17
 
18 18
 =head1 METHODS
19 19
 
20 20
 =head2 C<singleton>
21 21
 
22
-    $not_exists = DBIx::Custom::NotExists->singleton;
22
+  $not_exists = DBIx::Custom::NotExists->singleton;
23 23
 
24 24
 L<DBIx::Custom::NotExists> singleton object.
25 25
 
+43 -43
lib/DBIx/Custom/Order.pm
... ...
@@ -6,43 +6,43 @@ use overload
6 6
   fallback => 1;
7 7
 
8 8
 has 'dbi',
9
-    orders => sub { [] };
9
+  orders => sub { [] };
10 10
 
11 11
 sub prepend {
12
-    my $self = shift;
13
-    
14
-    for my $order (reverse @_) {
15
-        if (ref $order eq 'ARRAY') {
16
-            warn "prepend method receiving array reference is DEPRECATED! " .
17
-                 "use q method to quote column name.";
18
-            my $column = shift @$order;
19
-            $column = $self->dbi->q($column) if defined $column;
20
-            my $derection = shift @$order;
21
-            $order = $column;
22
-            $order .= " $derection" if $derection;
23
-        }
24
-        unshift @{$self->orders}, $order;
12
+  my $self = shift;
13
+  
14
+  for my $order (reverse @_) {
15
+    if (ref $order eq 'ARRAY') {
16
+      warn "prepend method receiving array reference is DEPRECATED! " .
17
+           "use q method to quote column name.";
18
+      my $column = shift @$order;
19
+      $column = $self->dbi->q($column) if defined $column;
20
+      my $derection = shift @$order;
21
+      $order = $column;
22
+      $order .= " $derection" if $derection;
25 23
     }
26
-    
27
-    return $self;
24
+    unshift @{$self->orders}, $order;
25
+  }
26
+  
27
+  return $self;
28 28
 }
29 29
 
30 30
 sub to_string {
31
-    my $self = shift;
32
-    
33
-    my $exists = {};
34
-    my @orders;
35
-    for my $order (@{$self->orders}) {
36
-        next unless defined $order;
37
-        $order =~ s/^\s+//;
38
-        $order =~ s/\s+$//;
39
-        my ($column, $direction) = split /\s+/, $order;
40
-        push @orders, $order unless $exists->{$column};
41
-        $exists->{$column} = 1;
42
-    }
43
-    
44
-    return '' unless @orders;
45
-    return 'order by ' . join(', ', @orders);
31
+  my $self = shift;
32
+  
33
+  my $exists = {};
34
+  my @orders;
35
+  for my $order (@{$self->orders}) {
36
+    next unless defined $order;
37
+    $order =~ s/^\s+//;
38
+    $order =~ s/\s+$//;
39
+    my ($column, $direction) = split /\s+/, $order;
40
+    push @orders, $order unless $exists->{$column};
41
+    $exists->{$column} = 1;
42
+  }
43
+  
44
+  return '' unless @orders;
45
+  return 'order by ' . join(', ', @orders);
46 46
 }
47 47
 
48 48
 1;
... ...
@@ -53,24 +53,24 @@ DBIx::Custom::Order - Order by
53 53
 
54 54
 =head1 SYNOPSIS
55 55
 
56
-    # Result
57
-    my $order = DBIx::Custom::Order->new;
58
-    $order->prepend('title', 'author desc');
59
-    my $order_by = "$order";
60
-    
56
+  # Result
57
+  my $order = DBIx::Custom::Order->new;
58
+  $order->prepend('title', 'author desc');
59
+  my $order_by = "$order";
60
+  
61 61
 =head1 ATTRIBUTES
62 62
 
63 63
 =head2 C<dbi>
64 64
 
65
-    my $dbi = $order->dbi;
66
-    $order = $order->dbi($dbi);
65
+  my $dbi = $order->dbi;
66
+  $order = $order->dbi($dbi);
67 67
 
68 68
 L<DBIx::Custom> object.
69 69
 
70 70
 =head2 C<orders>
71 71
 
72
-    my $orders = $result->orders;
73
-    $result = $result->orders(\%orders);
72
+  my $orders = $result->orders;
73
+  $result = $result->orders(\%orders);
74 74
 
75 75
 Parts of order by clause
76 76
 
... ...
@@ -81,18 +81,18 @@ and implements the following new ones.
81 81
 
82 82
 =head2 C<prepend>
83 83
 
84
-    $order->prepend('title', 'author desc');
84
+  $order->prepend('title', 'author desc');
85 85
 
86 86
 Prepend order parts to C<orders>.
87 87
 
88 88
 =head2 C<to_string>
89 89
 
90
-    my $order_by = $order->to_string;
90
+  my $order_by = $order->to_string;
91 91
 
92 92
 Create order by clause. If column name is duplicated, First one is used.
93 93
 C<to_string> override stringification. so you can write the follwoing way.
94 94
 
95
-    my $order_by = "$order";
95
+  my $order_by = "$order";
96 96
 
97 97
 =cut
98 98
 
+48 -52
lib/DBIx/Custom/Query.pm
... ...
@@ -5,72 +5,68 @@ use Carp 'croak';
5 5
 use DBIx::Custom::Util '_subname';
6 6
 
7 7
 has [qw/sth statement/],
8
-    sql => '',
9
-    columns => sub { [] };
8
+  sql => '',
9
+  columns => sub { [] };
10 10
 
11 11
 # DEPRECATED!
12 12
 has 'default_filter';
13 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};
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 21
 }
22 22
 
23 23
 # DEPRECATED!
24 24
 sub tables {
25
-    warn "DBIx::Custom::Query tables attribute method is DEPRECATED!";
26
-    my $self = shift;
27
-    if (@_) {
28
-        $self->{tables} = $_[0];
29
-        return $self;
30
-    }
31
-    return $self->{tables} ||= [];
25
+  warn "DBIx::Custom::Query tables attribute method is DEPRECATED!";
26
+  my $self = shift;
27
+  if (@_) {
28
+    $self->{tables} = $_[0];
29
+    return $self;
30
+  }
31
+  return $self->{tables} ||= [];
32 32
 }
33 33
 
34 34
 #DEPRECATED!
35 35
 sub filter {
36
-    Carp::carp "DBIx::Custom::Query filter method is DEPRECATED!";
37
-    my $self = shift;
38
-    if (@_) {
39
-        my $filter = {};
40
-        if (ref $_[0] eq 'HASH') {
41
-            $filter = $_[0];
42
-        }
43
-        else {
44
-            my $ef = @_ > 1 ? [@_] : $_[0];
45
-            for (my $i = 0; $i < @$ef; $i += 2) {
46
-                my $column = $ef->[$i];
47
-                my $f = $ef->[$i + 1];
48
-                if (ref $column eq 'ARRAY') {
49
-                    for my $c (@$column) {
50
-                        $filter->{$c} = $f;
51
-                    }
52
-                }
53
-                else {
54
-                    $filter->{$column} = $f;
55
-                }
56
-            }
57
-        }
58
-        for my $column (keys %$filter) {
59
-            my $fname = $filter->{$column};
60
-            if  (exists $filter->{$column}
61
-              && defined $fname
62
-              && ref $fname ne 'CODE') 
63
-            {
64
-                my $filters = $self->{filters} || {};
65
-                croak qq{Filter "$fname" is not registered" } . _subname
66
-                  unless exists $filters->{$fname};
67
-                $filter->{$column} = $filters->{$fname};
68
-            }
36
+  Carp::carp "DBIx::Custom::Query filter method is DEPRECATED!";
37
+  my $self = shift;
38
+  if (@_) {
39
+    my $filter = {};
40
+    if (ref $_[0] eq 'HASH') {
41
+        $filter = $_[0];
42
+    }
43
+    else {
44
+      my $ef = @_ > 1 ? [@_] : $_[0];
45
+      for (my $i = 0; $i < @$ef; $i += 2) {
46
+        my $column = $ef->[$i];
47
+        my $f = $ef->[$i + 1];
48
+        if (ref $column eq 'ARRAY') {
49
+          for my $c (@$column) { $filter->{$c} = $f }
69 50
         }
70
-        $self->{filter} = {%{$self->{filter} || {}}, %$filter};
71
-        return $self;
51
+        else { $filter->{$column} = $f }
52
+      }
53
+    }
54
+    for my $column (keys %$filter) {
55
+      my $fname = $filter->{$column};
56
+      if (exists $filter->{$column}
57
+        && defined $fname
58
+        && ref $fname ne 'CODE') 
59
+      {
60
+        my $filters = $self->{filters} || {};
61
+        croak qq{Filter "$fname" is not registered" } . _subname
62
+          unless exists $filters->{$fname};
63
+        $filter->{$column} = $filters->{$fname};
64
+      }
72 65
     }
73
-    return $self->{filter} ||= {};
66
+    $self->{filter} = {%{$self->{filter} || {}}, %$filter};
67
+    return $self;
68
+  }
69
+  return $self->{filter} ||= {};
74 70
 }
75 71
 
76 72
 1;
+215 -215
lib/DBIx/Custom/QueryBuilder.pm
... ...
@@ -13,51 +13,51 @@ push @DBIx::Custom::Where::CARP_NOT, __PACKAGE__;
13 13
 
14 14
 # DEPRECATED!
15 15
 sub build_query {
16
-    my ($self, $sql) = @_;
16
+  my ($self, $sql) = @_;
17 17
 
18
-    my $query = $self->_parse_tag($sql);
19
-    my $tag_count = delete $query->{tag_count};
20
-    warn qq/Tag system such as {? name} is DEPRECATED! / .
21
-         qq/use parameter system such as :name instead/
22
-      if $tag_count;
23
-    my $query2 = $self->_parse_parameter($query->sql);
24
-    $query->sql($query2->sql);
25
-    for (my $i =0; $i < @{$query->columns}; $i++) {
26
-        my $column = $query->columns->[$i];
27
-        if ($column eq 'RESERVED_PARAMETER') {
28
-            my $column2 = shift @{$query2->columns};
29
-            croak ":name syntax is wrong"
30
-              unless defined $column2;
31
-            $query->columns->[$i] = $column2;
32
-        }
18
+  my $query = $self->_parse_tag($sql);
19
+  my $tag_count = delete $query->{tag_count};
20
+  warn qq/Tag system such as {? name} is DEPRECATED! / .
21
+      qq/use parameter system such as :name instead/
22
+    if $tag_count;
23
+  my $query2 = $self->_parse_parameter($query->sql);
24
+  $query->sql($query2->sql);
25
+  for (my $i =0; $i < @{$query->columns}; $i++) {
26
+    my $column = $query->columns->[$i];
27
+    if ($column eq 'RESERVED_PARAMETER') {
28
+      my $column2 = shift @{$query2->columns};
29
+      croak ":name syntax is wrong"
30
+        unless defined $column2;
31
+      $query->columns->[$i] = $column2;
33 32
     }
34
-    return $query;
33
+  }
34
+  return $query;
35 35
 }
36 36
 
37 37
 # DEPRECATED!
38 38
 sub _parse_parameter {
39
-    my ($self, $source) = @_;
40
-    
41
-    # Get and replace parameters
42
-    my $sql = $source || '';
43
-    my $columns = [];
44
-    my $c = $self->dbi->safety_character;
45
-    # Parameter regex
46
-    $sql =~ s/([^:]):(\d+):([^:])/$1\\:$2\\:$3/g;
47
-    my $re = qr/(^|.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
48
-    while ($sql =~ /$re/g) {
49
-        push @$columns, $2;
50
-        $sql = defined $3 ? "$1$2 $3 ?$4" : "$1?$4";
51
-    }
52
-    $sql =~ s/\\:/:/g;
39
+  my ($self, $source) = @_;
40
+  
41
+  # Get and replace parameters
42
+  my $sql = $source || '';
43
+  my $columns = [];
44
+  my $c = $self->dbi->safety_character;
45
+  # Parameter regex
46
+  $sql =~ s/([^:]):(\d+):([^:])/$1\\:$2\\:$3/g;
47
+  my $re = qr/(^|.*?[^\\]):([$c\.]+)(?:\{(.*?)\})?(.*)/s;
48
+  while ($sql =~ /$re/g) {
49
+    push @$columns, $2;
50
+    $sql = defined $3 ? "$1$2 $3 ?$4" : "$1?$4";
51
+  }
52
+  $sql =~ s/\\:/:/g;
53 53
 
54
-    # Create query
55
-    my $query = DBIx::Custom::Query->new(
56
-        sql => $sql,
57
-        columns => $columns
58
-    );
59
-    
60
-    return $query;
54
+  # Create query
55
+  my $query = DBIx::Custom::Query->new(
56
+    sql => $sql,
57
+    columns => $columns
58
+  );
59
+  
60
+  return $query;
61 61
 }
62 62
 
63 63
 # DEPRECATED
... ...
@@ -68,190 +68,190 @@ has tags => sub { {} };
68 68
 
69 69
 # DEPRECATED!
70 70
 sub register_tag {
71
-    my $self = shift;
72
-    
73
-    warn "register_tag is DEPRECATED!";
74
-    
75
-    # Merge tag
76
-    my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
77
-    $self->tags({%{$self->tags}, %$tags});
78
-    
79
-    return $self;
71
+  my $self = shift;
72
+  
73
+  warn "register_tag is DEPRECATED!";
74
+  
75
+  # Merge tag
76
+  my $tags = ref $_[0] eq 'HASH' ? $_[0] : {@_};
77
+  $self->tags({%{$self->tags}, %$tags});
78
+  
79
+  return $self;
80 80
 }
81 81
 
82 82
 # DEPRECATED!
83 83
 sub _parse_tag {
84
-    my ($self, $source) = @_;
85
-    # Source
86
-    $source ||= '';
87
-    # Tree
88
-    my @tree;
89
-    # Value
90
-    my $value = '';
91
-    # State
92
-    my $state = 'text';
93
-    # Before charactor
94
-    my $before = '';
95
-    # Position
96
-    my $pos = 0;
97
-    # Parse
98
-    my $original = $source;
99
-    my $tag_count = 0;
100
-    while (defined(my $c = substr($source, $pos, 1))) {
101
-        # Last
102
-        last unless length $c;
103
-        # Parameter
104
-        if ($c eq ':' && (substr($source, $pos + 1, 1) || '') =~ /\w/) {
105
-            push @tree, {type => 'param'};;
84
+  my ($self, $source) = @_;
85
+  # Source
86
+  $source ||= '';
87
+  # Tree
88
+  my @tree;
89
+  # Value
90
+  my $value = '';
91
+  # State
92
+  my $state = 'text';
93
+  # Before charactor
94
+  my $before = '';
95
+  # Position
96
+  my $pos = 0;
97
+  # Parse
98
+  my $original = $source;
99
+  my $tag_count = 0;
100
+  while (defined(my $c = substr($source, $pos, 1))) {
101
+    # Last
102
+    last unless length $c;
103
+    # Parameter
104
+    if ($c eq ':' && (substr($source, $pos + 1, 1) || '') =~ /\w/) {
105
+        push @tree, {type => 'param'};;
106
+    }
107
+    # State is text
108
+    if ($state eq 'text') {
109
+      # Tag start charactor
110
+      if ($c eq '{') {
111
+        # Escaped charactor
112
+        if ($before eq "\\") {
113
+          substr($value, -1, 1, '');
114
+          $value .= $c;
115
+        }
116
+        # Tag start
117
+        else {
118
+          # Change state
119
+          $state = 'tag';
120
+          # Add text
121
+          push @tree, {type => 'text', value => $value}
122
+            if $value;
123
+          # Clear
124
+          $value = '';
106 125
         }
107
-        # State is text
108
-        if ($state eq 'text') {
109
-            # Tag start charactor
110
-            if ($c eq '{') {
111
-                # Escaped charactor
112
-                if ($before eq "\\") {
113
-                    substr($value, -1, 1, '');
114
-                    $value .= $c;
115
-                }
116
-                # Tag start
117
-                else {
118
-                    # Change state
119
-                    $state = 'tag';
120
-                    # Add text
121
-                    push @tree, {type => 'text', value => $value}
122
-                      if $value;
123
-                    # Clear
124
-                    $value = '';
125
-                }
126
-            }
127
-            # Tag end charactor
128
-            elsif ($c eq '}') {
129
-                # Escaped charactor
130
-                if ($before eq "\\") {
131
-                    substr($value, -1, 1, '');
132
-                    $value .= $c;
133
-                }
134
-                # Unexpected
135
-                else {
136
-                    croak qq{Parsing error. unexpected "\}". }
137
-                        . qq{pos $pos of "$original" } . _subname
138
-                }
139
-            }
140
-            # Normal charactor
141
-            else { $value .= $c }
126
+      }
127
+      # Tag end charactor
128
+      elsif ($c eq '}') {
129
+        # Escaped charactor
130
+        if ($before eq "\\") {
131
+          substr($value, -1, 1, '');
132
+          $value .= $c;
142 133
         }
143
-        # State is tags
134
+        # Unexpected
144 135
         else {
145
-            # Tag start charactor
146
-            if ($c eq '{') {
147
-                # Escaped charactor
148
-                if ($before eq "\\") {
149
-                    substr($value, -1, 1, '');
150
-                    $value .= $c;
151
-                }
152
-                # Unexpected
153
-                else {
154
-                    croak qq{Parsing error. unexpected "\{". }
155
-                        . qq{pos $pos of "$original" } . _subname
156
-                }
157
-            }
158
-            # Tag end charactor
159
-            elsif ($c eq '}') {
160
-                # Escaped charactor
161
-                if ($before eq "\\") {
162
-                    substr($value, -1, 1, '');
163
-                    $value .= $c;
164
-                }
165
-                # Tag end
166
-                else {
167
-                    # Change state
168
-                    $state = 'text';
169
-                    # Add tag
170
-                    my ($tag_name, @tag_args) = split /\s+/, $value;
171
-                    push @tree, {type => 'tag', tag_name => $tag_name, 
172
-                                 tag_args => \@tag_args};
173
-                    # Clear
174
-                    $value = '';
175
-                    # Countup
176
-                    $tag_count++;
177
-                }
178
-            }
179
-            # Normal charactor
180
-            else { $value .= $c }
136
+          croak qq{Parsing error. unexpected "\}". }
137
+            . qq{pos $pos of "$original" } . _subname
181 138
         }
182
-        # Save before charactor
183
-        $before = $c;
184
-        # increment position
185
-        $pos++;
139
+      }
140
+      # Normal charactor
141
+      else { $value .= $c }
186 142
     }
187
-    # Tag not finished
188
-    croak qq{Tag not finished. "$original" } . _subname
189
-      if $state eq 'tag';
190
-    # Not contains tag
191
-    return DBIx::Custom::Query->new(sql => $source, tag_count => $tag_count)
192
-      if $tag_count == 0;
193
-    # Add rest text
194
-    push @tree, {type => 'text', value => $value}
195
-      if $value;
196
-    # SQL
197
-    my $sql = '';
198
-    # All Columns
199
-    my $all_columns = [];
200
-    # Tables
201
-    my $tables = [];
202
-    # Build SQL 
203
-    for my $node (@tree) {
204
-        # Text
205
-        if ($node->{type} eq 'text') { $sql .= $node->{value} }
206
-        # Parameter
207
-        elsif ($node->{type} eq 'param') {
208
-            push @$all_columns, 'RESERVED_PARAMETER';
143
+    # State is tags
144
+    else {
145
+      # Tag start charactor
146
+      if ($c eq '{') {
147
+        # Escaped charactor
148
+        if ($before eq "\\") {
149
+          substr($value, -1, 1, '');
150
+          $value .= $c;
209 151
         }
210
-        # Tag
152
+        # Unexpected
211 153
         else {
212
-            # Tag name
213
-            my $tag_name = $node->{tag_name};
214
-            # Tag arguments
215
-            my $tag_args = $node->{tag_args};
216
-            # Table
217
-            if ($tag_name eq 'table') {
218
-                my $table = $tag_args->[0];
219
-                push @$tables, $table;
220
-                $sql .= $table;
221
-                next;
222
-            }
223
-            # Get tag
224
-            $self->dbi->{_tags} ||= {};
225
-            my $tag = $self->tag_processors->{$tag_name}
226
-                             || $self->dbi->{_tags}->{$tag_name};
227
-            # Tag is not registered
228
-            croak qq{Tag "$tag_name" is not registered } . _subname
229
-              unless $tag;
230
-            # Tag not sub reference
231
-            croak qq{Tag "$tag_name" must be sub reference } . _subname
232
-              unless ref $tag eq 'CODE';
233
-            # Execute tag
234
-            my $r = $tag->(@$tag_args);
235
-            # Check tag return value
236
-            croak qq{Tag "$tag_name" must return [STRING, ARRAY_REFERENCE] }
237
-                . _subname
238
-              unless ref $r eq 'ARRAY' && defined $r->[0] && ref $r->[1] eq 'ARRAY';
239
-            # Part of SQL statement and colum names
240
-            my ($part, $columns) = @$r;
241
-            # Add columns
242
-            push @$all_columns, @$columns;
243
-            # Join part tag to SQL
244
-            $sql .= $part;
154
+          croak qq{Parsing error. unexpected "\{". }
155
+              . qq{pos $pos of "$original" } . _subname
245 156
         }
157
+      }
158
+      # Tag end charactor
159
+      elsif ($c eq '}') {
160
+        # Escaped charactor
161
+        if ($before eq "\\") {
162
+          substr($value, -1, 1, '');
163
+          $value .= $c;
164
+        }
165
+        # Tag end
166
+        else {
167
+          # Change state
168
+          $state = 'text';
169
+          # Add tag
170
+          my ($tag_name, @tag_args) = split /\s+/, $value;
171
+          push @tree, {type => 'tag', tag_name => $tag_name, 
172
+                       tag_args => \@tag_args};
173
+          # Clear
174
+          $value = '';
175
+          # Countup
176
+          $tag_count++;
177
+        }
178
+      }
179
+      # Normal charactor
180
+      else { $value .= $c }
181
+    }
182
+    # Save before charactor
183
+    $before = $c;
184
+    # increment position
185
+    $pos++;
186
+  }
187
+  # Tag not finished
188
+  croak qq{Tag not finished. "$original" } . _subname
189
+    if $state eq 'tag';
190
+  # Not contains tag
191
+  return DBIx::Custom::Query->new(sql => $source, tag_count => $tag_count)
192
+    if $tag_count == 0;
193
+  # Add rest text
194
+  push @tree, {type => 'text', value => $value}
195
+    if $value;
196
+  # SQL
197
+  my $sql = '';
198
+  # All Columns
199
+  my $all_columns = [];
200
+  # Tables
201
+  my $tables = [];
202
+  # Build SQL 
203
+  for my $node (@tree) {
204
+    # Text
205
+    if ($node->{type} eq 'text') { $sql .= $node->{value} }
206
+    # Parameter
207
+    elsif ($node->{type} eq 'param') {
208
+        push @$all_columns, 'RESERVED_PARAMETER';
209
+    }
210
+    # Tag
211
+    else {
212
+      # Tag name
213
+      my $tag_name = $node->{tag_name};
214
+      # Tag arguments
215
+      my $tag_args = $node->{tag_args};
216
+      # Table
217
+      if ($tag_name eq 'table') {
218
+        my $table = $tag_args->[0];
219
+        push @$tables, $table;
220
+        $sql .= $table;
221
+        next;
222
+      }
223
+      # Get tag
224
+      $self->dbi->{_tags} ||= {};
225
+      my $tag = $self->tag_processors->{$tag_name}
226
+                       || $self->dbi->{_tags}->{$tag_name};
227
+      # Tag is not registered
228
+      croak qq{Tag "$tag_name" is not registered } . _subname
229
+        unless $tag;
230
+      # Tag not sub reference
231
+      croak qq{Tag "$tag_name" must be sub reference } . _subname
232
+        unless ref $tag eq 'CODE';
233
+      # Execute tag
234
+      my $r = $tag->(@$tag_args);
235
+      # Check tag return value
236
+      croak qq{Tag "$tag_name" must return [STRING, ARRAY_REFERENCE] }
237
+          . _subname
238
+        unless ref $r eq 'ARRAY' && defined $r->[0] && ref $r->[1] eq 'ARRAY';
239
+      # Part of SQL statement and colum names
240
+      my ($part, $columns) = @$r;
241
+      # Add columns
242
+      push @$all_columns, @$columns;
243
+      # Join part tag to SQL
244
+      $sql .= $part;
246 245
     }
247
-    # Query
248
-    my $query = DBIx::Custom::Query->new(
249
-        sql => $sql,
250
-        columns => $all_columns,
251
-        tables => $tables,
252
-        tag_count => $tag_count
253
-    );
254
-    return $query;
246
+  }
247
+  # Query
248
+  my $query = DBIx::Custom::Query->new(
249
+    sql => $sql,
250
+    columns => $all_columns,
251
+    tables => $tables,
252
+    tag_count => $tag_count
253
+  );
254
+  return $query;
255 255
 }
256 256
 
257 257
 # DEPRECATED!
... ...
@@ -259,12 +259,12 @@ has tag_processors => sub { {} };
259 259
 
260 260
 # DEPRECATED!
261 261
 sub register_tag_processor {
262
-    my $self = shift;
263
-    warn "register_tag_processor is DEPRECATED!";
264
-    # Merge tag
265
-    my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
266
-    $self->tag_processors({%{$self->tag_processors}, %{$tag_processors}});
267
-    return $self;
262
+  my $self = shift;
263
+  warn "register_tag_processor is DEPRECATED!";
264
+  # Merge tag
265
+  my $tag_processors = ref $_[0] eq 'HASH' ? $_[0] : {@_};
266
+  $self->tag_processors({%{$self->tag_processors}, %{$tag_processors}});
267
+  return $self;
268 268
 }
269 269
 
270 270
 1;
+395 -395
lib/DBIx/Custom/Result.pm
... ...
@@ -5,245 +5,245 @@ use Carp 'croak';
5 5
 use DBIx::Custom::Util qw/_array_to_hash _subname/;
6 6
 
7 7
 has [qw/dbi sth/],
8
-    stash => sub { {} };
8
+  stash => sub { {} };
9 9
 
10 10
 *all = \&fetch_hash_all;
11 11
 
12 12
 sub column {
13
-    my $self = shift;
14
-    
15
-    my $column = [];
16
-    my $rows = $self->fetch_all;
17
-    push @$column, $_->[0] for @$rows;
18
-    return $column;
13
+  my $self = shift;
14
+  
15
+  my $column = [];
16
+  my $rows = $self->fetch_all;
17
+  push @$column, $_->[0] for @$rows;
18
+  return $column;
19 19
 }
20 20
 
21 21
 sub filter {
22
-    my $self = shift;
23
-    
24
-    # Set
25
-    if (@_) {
26
-        
27
-        # Convert filter name to subroutine
28
-        my $filter = @_ == 1 ? $_[0] : [@_];
29
-        $filter = _array_to_hash($filter);
30
-        for my $column (keys %$filter) {
31
-            my $fname = $filter->{$column};
32
-            if  (exists $filter->{$column}
33
-              && defined $fname
34
-              && ref $fname ne 'CODE') 
35
-            {
36
-              croak qq{Filter "$fname" is not registered" } . _subname
37
-                unless exists $self->dbi->filters->{$fname};
38
-              $filter->{$column} = $self->dbi->filters->{$fname};
39
-            }
40
-        }
41
-        
42
-        # Merge
43
-        $self->{filter} = {%{$self->filter}, %$filter};
44
-        
45
-        return $self;
22
+  my $self = shift;
23
+  
24
+  # Set
25
+  if (@_) {
26
+    
27
+    # Convert filter name to subroutine
28
+    my $filter = @_ == 1 ? $_[0] : [@_];
29
+    $filter = _array_to_hash($filter);
30
+    for my $column (keys %$filter) {
31
+      my $fname = $filter->{$column};
32
+      if  (exists $filter->{$column}
33
+        && defined $fname
34
+        && ref $fname ne 'CODE') 
35
+      {
36
+        croak qq{Filter "$fname" is not registered" } . _subname
37
+          unless exists $self->dbi->filters->{$fname};
38
+        $filter->{$column} = $self->dbi->filters->{$fname};
39
+      }
46 40
     }
47 41
     
48
-    return $self->{filter} ||= {};
42
+    # Merge
43
+    $self->{filter} = {%{$self->filter}, %$filter};
44
+    
45
+    return $self;
46
+  }
47
+  
48
+  return $self->{filter} ||= {};
49 49
 }
50 50
 
51 51
 sub fetch {
52
-    my $self = shift;
53
-    
54
-    # Info
55
-    $self->_cache unless $self->{_cache};
56
-    
57
-    # Fetch
58
-    my @row = $self->{sth}->fetchrow_array;
59
-    return unless @row;
60
-    
61
-    # Type rule
62
-    if ($self->{type_rule}->{from1} && !$self->{type_rule_off} && !$self->{type_rule1_off}) {
63
-        my $from = $self->{type_rule}->{from1};
64
-        for my $type (keys %$from) {
65
-            for my $column (@{$self->{_type_map}->{$type}}) {
66
-                $row[$_] = $from->{$type}->($row[$_])
67
-                  for @{$self->{_pos}{$column} || []};
68
-            }
69
-        }
52
+  my $self = shift;
53
+  
54
+  # Info
55
+  $self->_cache unless $self->{_cache};
56
+  
57
+  # Fetch
58
+  my @row = $self->{sth}->fetchrow_array;
59
+  return unless @row;
60
+  
61
+  # Type rule
62
+  if ($self->{type_rule}->{from1} && !$self->{type_rule_off} && !$self->{type_rule1_off}) {
63
+    my $from = $self->{type_rule}->{from1};
64
+    for my $type (keys %$from) {
65
+      for my $column (@{$self->{_type_map}->{$type}}) {
66
+        $row[$_] = $from->{$type}->($row[$_])
67
+          for @{$self->{_pos}{$column} || []};
68
+      }
70 69
     }
71
-    if ($self->{type_rule}->{from2} && !$self->{type_rule_off} && !$self->{type_rule2_off}) {
72
-        my $from = $self->{type_rule}->{from2};
73
-        for my $type (keys %$from) {
74
-            for my $column (@{$self->{_type_map}->{$type}}) {
75
-                $row[$_] = $from->{$type}->($row[$_])
76
-                  for @{$self->{_pos}{$column} || []};
77
-            }
78
-        }
70
+  }
71
+  if ($self->{type_rule}->{from2} && !$self->{type_rule_off} && !$self->{type_rule2_off}) {
72
+    my $from = $self->{type_rule}->{from2};
73
+    for my $type (keys %$from) {
74
+      for my $column (@{$self->{_type_map}->{$type}}) {
75
+        $row[$_] = $from->{$type}->($row[$_])
76
+          for @{$self->{_pos}{$column} || []};
77
+      }
79 78
     }
80
-    
81
-    # Filter
82
-    if (($self->{filter} || $self->{default_filter}) && !$self->{filter_off}) {
83
-         my @columns = $self->{default_filter} ? keys %{$self->{_columns}}
84
-           : keys %{$self->{filter}};
85
-         
86
-         for my $column (@columns) {
87
-             my $filter = exists $self->{filter}->{$column} ? $self->{filter}->{$column}
88
-               : $self->{default_filter};
89
-             next unless $filter;
90
-             $row[$_] = $filter->($row[$_])
91
-               for @{$self->{_pos}{$column} || []};
92
-         }
93
-    }
94
-    if ($self->{end_filter} && !$self->{filter_off}) {
95
-         for my $column (keys %{$self->{end_filter}}) {
96
-             next unless $self->{end_filter}->{$column};
97
-             $row[$_] = $self->{end_filter}->{$column}->($row[$_])
98
-               for @{$self->{_pos}{$column} || []};
99
-         }
100
-    }
101
-
102
-    return \@row;
79
+  }
80
+  
81
+  # Filter
82
+  if (($self->{filter} || $self->{default_filter}) && !$self->{filter_off}) {
83
+     my @columns = $self->{default_filter} ? keys %{$self->{_columns}}
84
+       : keys %{$self->{filter}};
85
+     
86
+     for my $column (@columns) {
87
+       my $filter = exists $self->{filter}->{$column} ? $self->{filter}->{$column}
88
+         : $self->{default_filter};
89
+       next unless $filter;
90
+       $row[$_] = $filter->($row[$_])
91
+         for @{$self->{_pos}{$column} || []};
92
+     }
93
+  }
94
+  if ($self->{end_filter} && !$self->{filter_off}) {
95
+     for my $column (keys %{$self->{end_filter}}) {
96
+       next unless $self->{end_filter}->{$column};
97
+       $row[$_] = $self->{end_filter}->{$column}->($row[$_])
98
+         for @{$self->{_pos}{$column} || []};
99
+     }
100
+  }
101
+
102
+  return \@row;
103 103
 }
104 104
 
105 105
 sub fetch_hash {
106
-    my $self = shift;
107
-    
108
-    # Info
109
-    $self->_cache unless $self->{_cache};
110
-    
111
-    # Fetch
112
-    return unless my $row = $self->{sth}->fetchrow_hashref;
113
-    
114
-    # Type rule
115
-    if ($self->{type_rule}->{from1} &&
116
-      !$self->{type_rule_off} && !$self->{type_rule1_off})
117
-    {
118
-        my $from = $self->{type_rule}->{from1};
119
-        for my $type (keys %$from) {
120
-            $from->{$type} and $row->{$_} = $from->{$type}->($row->{$_})
121
-              for @{$self->{_type_map}->{$type}};
122
-        }
123
-    }
124
-    if ($self->{type_rule}->{from2} &&
125
-      !$self->{type_rule_off} && !$self->{type_rule2_off})
126
-    {
127
-        my $from = $self->{type_rule}->{from2};
128
-        for my $type (keys %{$self->{type_rule}->{from2}}) {
129
-            $from->{$type} and $row->{$_} = $from->{$type}->($row->{$_})
130
-              for @{$self->{_type_map}->{$type}};
131
-        }
132
-    }        
133
-    # Filter
134
-    if (($self->{filter} || $self->{default_filter}) &&
135
-      !$self->{filter_off})
136
-    {
137
-         my @columns = $self->{default_filter} ? keys %{$self->{_columns}}
138
-           : keys %{$self->{filter}};
139
-         
140
-         for my $column (@columns) {
141
-             next unless exists $row->{$column};
142
-             my $filter = exists $self->{filter}->{$column} ? $self->{filter}->{$column}
143
-               : $self->{default_filter};
144
-             $row->{$column} = $filter->($row->{$column}) if $filter;
145
-         }
106
+  my $self = shift;
107
+  
108
+  # Info
109
+  $self->_cache unless $self->{_cache};
110
+  
111
+  # Fetch
112
+  return unless my $row = $self->{sth}->fetchrow_hashref;
113
+  
114
+  # Type rule
115
+  if ($self->{type_rule}->{from1} &&
116
+    !$self->{type_rule_off} && !$self->{type_rule1_off})
117
+  {
118
+    my $from = $self->{type_rule}->{from1};
119
+    for my $type (keys %$from) {
120
+      $from->{$type} and $row->{$_} = $from->{$type}->($row->{$_})
121
+        for @{$self->{_type_map}->{$type}};
146 122
     }
147
-    if ($self->{end_filter} && !$self->{filter_off}) {
148
-         exists $self->{_columns}{$_} && $self->{end_filter}->{$_} and
149
-             $row->{$_} = $self->{end_filter}->{$_}->($row->{$_})
150
-           for keys %{$self->{end_filter}};
123
+  }
124
+  if ($self->{type_rule}->{from2} &&
125
+    !$self->{type_rule_off} && !$self->{type_rule2_off})
126
+  {
127
+    my $from = $self->{type_rule}->{from2};
128
+    for my $type (keys %{$self->{type_rule}->{from2}}) {
129
+      $from->{$type} and $row->{$_} = $from->{$type}->($row->{$_})
130
+        for @{$self->{_type_map}->{$type}};
151 131
     }
152
-    $row;
132
+  }        
133
+  # Filter
134
+  if (($self->{filter} || $self->{default_filter}) &&
135
+    !$self->{filter_off})
136
+  {
137
+     my @columns = $self->{default_filter} ? keys %{$self->{_columns}}
138
+       : keys %{$self->{filter}};
139
+     
140
+     for my $column (@columns) {
141
+       next unless exists $row->{$column};
142
+       my $filter = exists $self->{filter}->{$column} ? $self->{filter}->{$column}
143
+         : $self->{default_filter};
144
+       $row->{$column} = $filter->($row->{$column}) if $filter;
145
+     }
146
+  }
147
+  if ($self->{end_filter} && !$self->{filter_off}) {
148
+     exists $self->{_columns}{$_} && $self->{end_filter}->{$_} and
149
+         $row->{$_} = $self->{end_filter}->{$_}->($row->{$_})
150
+       for keys %{$self->{end_filter}};
151
+  }
152
+  $row;
153 153
 }
154 154
 
155 155
 sub fetch_all {
156
-    my $self = shift;
157
-    
158
-    # Fetch all rows
159
-    my $rows = [];
160
-    while(my $row = $self->fetch) { push @$rows, $row}
161
-    
162
-    return $rows;
156
+  my $self = shift;
157
+  
158
+  # Fetch all rows
159
+  my $rows = [];
160
+  while(my $row = $self->fetch) { push @$rows, $row}
161
+  
162
+  return $rows;
163 163
 }
164 164
 
165 165
 sub fetch_hash_all {
166
-    my $self = shift;
167
-    
168
-    # Fetch all rows as hash
169
-    my $rows = [];
170
-    while(my $row = $self->fetch_hash) { push @$rows, $row }
171
-    
172
-    return $rows;
166
+  my $self = shift;
167
+  
168
+  # Fetch all rows as hash
169
+  my $rows = [];
170
+  while(my $row = $self->fetch_hash) { push @$rows, $row }
171
+  
172
+  return $rows;
173 173
 }
174 174
 
175 175
 sub fetch_hash_one {
176
-    my $self = shift;
177
-    
178
-    # Fetch hash
179
-    my $row = $self->fetch_hash;
180
-    return unless $row;
181
-    
182
-    # Finish statement handle
183
-    $self->sth->finish;
184
-    
185
-    return $row;
176
+  my $self = shift;
177
+  
178
+  # Fetch hash
179
+  my $row = $self->fetch_hash;
180
+  return unless $row;
181
+  
182
+  # Finish statement handle
183
+  $self->sth->finish;
184
+  
185
+  return $row;
186 186
 }
187 187
 
188 188
 sub fetch_hash_multi {
189
-    my ($self, $count) = @_;
190
-    
191
-    # Fetch multiple rows
192
-    croak 'Row count must be specified ' . _subname
193
-      unless $count;
194
-    
195
-    return if $self->{_finished};
196
-
197
-    my $rows = [];
198
-    for (my $i = 0; $i < $count; $i++) {
199
-        my $row = $self->fetch_hash;
200
-        unless ($row) {
201
-            $self->{_finished} = 1;
202
-            last;
203
-        }
204
-        push @$rows, $row;
189
+  my ($self, $count) = @_;
190
+  
191
+  # Fetch multiple rows
192
+  croak 'Row count must be specified ' . _subname
193
+    unless $count;
194
+  
195
+  return if $self->{_finished};
196
+
197
+  my $rows = [];
198
+  for (my $i = 0; $i < $count; $i++) {
199
+    my $row = $self->fetch_hash;
200
+    unless ($row) {
201
+      $self->{_finished} = 1;
202
+      last;
205 203
     }
206
-    
207
-    return unless @$rows;
208
-    return $rows;
204
+    push @$rows, $row;
205
+  }
206
+  
207
+  return unless @$rows;
208
+  return $rows;
209 209
 }
210 210
 
211 211
 sub fetch_multi {
212
-    my ($self, $count) = @_;
213
-    
214
-    # Row count not specifed
215
-    croak 'Row count must be specified ' . _subname
216
-      unless $count;
217
-    
218
-    return if $self->{_finished};
219
-    
220
-    # Fetch multi rows
221
-    my $rows = [];
222
-    for (my $i = 0; $i < $count; $i++) {
223
-        my $row = $self->fetch;
224
-        unless ($row) {
225
-            $self->{_finished} = 1;
226
-            last;
227
-        }
228
-        push @$rows, $row;
212
+  my ($self, $count) = @_;
213
+  
214
+  # Row count not specifed
215
+  croak 'Row count must be specified ' . _subname
216
+    unless $count;
217
+  
218
+  return if $self->{_finished};
219
+  
220
+  # Fetch multi rows
221
+  my $rows = [];
222
+  for (my $i = 0; $i < $count; $i++) {
223
+    my $row = $self->fetch;
224
+    unless ($row) {
225
+      $self->{_finished} = 1;
226
+      last;
229 227
     }
230
-    
231
-    return unless @$rows;
232
-    return $rows;
228
+    push @$rows, $row;
229
+  }
230
+  
231
+  return unless @$rows;
232
+  return $rows;
233 233
 }
234 234
 
235 235
 
236 236
 sub fetch_one {
237
-    my $self = shift;
238
-    
239
-    # Fetch
240
-    my $row = $self->fetch;
241
-    return unless $row;
242
-    
243
-    # Finish statement handle
244
-    $self->sth->finish;
245
-    
246
-    return $row;
237
+  my $self = shift;
238
+  
239
+  # Fetch
240
+  my $row = $self->fetch;
241
+  return unless $row;
242
+  
243
+  # Finish statement handle
244
+  $self->sth->finish;
245
+  
246
+  return $row;
247 247
 }
248 248
 
249 249
 sub header { shift->sth->{NAME} }
... ...
@@ -251,183 +251,183 @@ sub header { shift->sth->{NAME} }
251 251
 *one = \&fetch_hash_one;
252 252
 
253 253
 sub type_rule {
254
-    my $self = shift;
255
-    
256
-    if (@_) {
257
-        my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
258
-
259
-        # From
260
-        for my $i (1 .. 2) {
261
-            $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
262
-            for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
263
-                croak qq{data type of from$i section must be lower case or number}
264
-                  if $data_type =~ /[A-Z]/;
265
-                my $fname = $type_rule->{"from$i"}{$data_type};
266
-                if (defined $fname && ref $fname ne 'CODE') {
267
-                    croak qq{Filter "$fname" is not registered" } . _subname
268
-                      unless exists $self->dbi->filters->{$fname};
269
-                    
270
-                    $type_rule->{"from$i"}{$data_type} = $self->dbi->filters->{$fname};
271
-                }
272
-            }
254
+  my $self = shift;
255
+  
256
+  if (@_) {
257
+    my $type_rule = ref $_[0] eq 'HASH' ? $_[0] : {@_};
258
+
259
+    # From
260
+    for my $i (1 .. 2) {
261
+      $type_rule->{"from$i"} = _array_to_hash($type_rule->{"from$i"});
262
+      for my $data_type (keys %{$type_rule->{"from$i"} || {}}) {
263
+        croak qq{data type of from$i section must be lower case or number}
264
+          if $data_type =~ /[A-Z]/;
265
+        my $fname = $type_rule->{"from$i"}{$data_type};
266
+        if (defined $fname && ref $fname ne 'CODE') {
267
+          croak qq{Filter "$fname" is not registered" } . _subname
268
+            unless exists $self->dbi->filters->{$fname};
269
+          
270
+          $type_rule->{"from$i"}{$data_type} = $self->dbi->filters->{$fname};
273 271
         }
274
-        $self->{type_rule} = $type_rule;
275
-        
276
-        return $self;
272
+      }
277 273
     }
274
+    $self->{type_rule} = $type_rule;
278 275
     
279
-    return $self->{type_rule} || {};
276
+    return $self;
277
+  }
278
+  
279
+  return $self->{type_rule} || {};
280 280
 }
281 281
 
282 282
 sub type_rule_off {
283
-    my $self = shift;
284
-    $self->{type_rule_off} = 1;
285
-    return $self;
283
+  my $self = shift;
284
+  $self->{type_rule_off} = 1;
285
+  return $self;
286 286
 }
287 287
 
288 288
 sub type_rule_on {
289
-    my $self = shift;
290
-    $self->{type_rule_off} = 0;
291
-    return $self;
289
+  my $self = shift;
290
+  $self->{type_rule_off} = 0;
291
+  return $self;
292 292
 }
293 293
 
294 294
 sub type_rule1_off {
295
-    my $self = shift;
296
-    $self->{type_rule1_off} = 1;
297
-    return $self;
295
+  my $self = shift;
296
+  $self->{type_rule1_off} = 1;
297
+  return $self;
298 298
 }
299 299
 
300 300
 sub type_rule1_on {
301
-    my $self = shift;
302
-    $self->{type_rule1_off} = 0;
303
-    return $self;
301
+  my $self = shift;
302
+  $self->{type_rule1_off} = 0;
303
+  return $self;
304 304
 }
305 305
 
306 306
 sub type_rule2_off {
307
-    my $self = shift;
308
-    $self->{type_rule2_off} = 1;
309
-    return $self;
307
+  my $self = shift;
308
+  $self->{type_rule2_off} = 1;
309
+  return $self;
310 310
 }
311 311
 
312 312
 sub type_rule2_on {
313
-    my $self = shift;
314
-    $self->{type_rule2_off} = 0;
315
-    return $self;
313
+  my $self = shift;
314
+  $self->{type_rule2_off} = 0;
315
+  return $self;
316 316
 }
317 317
 
318 318
 sub value {
319
-    my $self = shift;
320
-    my $row = $self->fetch_one;
321
-    my $value = $row ? $row->[0] : undef;
322
-    return $value;
319
+  my $self = shift;
320
+  my $row = $self->fetch_one;
321
+  my $value = $row ? $row->[0] : undef;
322
+  return $value;
323 323
 }
324 324
 
325 325
 sub _cache {
326
-    my $self = shift;
327
-    $self->{_type_map} = {};
328
-    $self->{_pos} = {};
329
-    $self->{_columns} = {};
330
-    for (my $i = 0; $i < @{$self->{sth}->{NAME}}; $i++) {
331
-        my $type = lc $self->{sth}{TYPE}[$i];
332
-        my $name = $self->{sth}{NAME}[$i];
333
-        $self->{_type_map}{$type} ||= [];
334
-        push @{$self->{_type_map}{$type}}, $name;
335
-        $self->{_pos}{$name} ||= [];
336
-        push @{$self->{_pos}{$name}}, $i;
337
-        $self->{_columns}{$name} = 1;
338
-    }
339
-    $self->{_cache} = 1;
326
+  my $self = shift;
327
+  $self->{_type_map} = {};
328
+  $self->{_pos} = {};
329
+  $self->{_columns} = {};
330
+  for (my $i = 0; $i < @{$self->{sth}->{NAME}}; $i++) {
331
+    my $type = lc $self->{sth}{TYPE}[$i];
332
+    my $name = $self->{sth}{NAME}[$i];
333
+    $self->{_type_map}{$type} ||= [];
334
+    push @{$self->{_type_map}{$type}}, $name;
335
+    $self->{_pos}{$name} ||= [];
336
+    push @{$self->{_pos}{$name}}, $i;
337
+    $self->{_columns}{$name} = 1;
338
+  }
339
+  $self->{_cache} = 1;
340 340
 }
341 341
 
342 342
 # DEPRECATED!
343 343
 sub fetch_hash_first {
344
-    my $self = shift;
345
-    warn "DBIx::Custom::Result::fetch_hash_first is DEPRECATED! use fetch_hash_one instead";
346
-    return $self->fetch_hash_one(@_);
344
+  my $self = shift;
345
+  warn "DBIx::Custom::Result::fetch_hash_first is DEPRECATED! use fetch_hash_one instead";
346
+  return $self->fetch_hash_one(@_);
347 347
 }
348 348
 
349 349
 # DEPRECATED!
350 350
 sub fetch_first {
351
-    my $self = shift;
352
-    warn "DBIx::Custom::Result::fetch_first is DEPRECATED! use fetch_one instead";
353
-    return $self->fetch_one(@_);
351
+  my $self = shift;
352
+  warn "DBIx::Custom::Result::fetch_first is DEPRECATED! use fetch_one instead";
353
+  return $self->fetch_one(@_);
354 354
 }
355 355
 
356 356
 # DEPRECATED!
357 357
 sub filter_off {
358
-    warn "filter_off method is DEPRECATED!";
359
-    my $self = shift;
360
-    $self->{filter_off} = 1;
361
-    return $self;
358
+  warn "filter_off method is DEPRECATED!";
359
+  my $self = shift;
360
+  $self->{filter_off} = 1;
361
+  return $self;
362 362
 }
363 363
 
364 364
 # DEPRECATED!
365 365
 sub filter_on {
366
-    warn "filter_on method is DEPRECATED!";
367
-    my $self = shift;
368
-    $self->{filter_off} = 0;
369
-    return $self;
366
+  warn "filter_on method is DEPRECATED!";
367
+  my $self = shift;
368
+  $self->{filter_off} = 0;
369
+  return $self;
370 370
 }
371 371
 
372 372
 # DEPRECATED!
373 373
 sub end_filter {
374
-    warn "end_filter method is DEPRECATED!";
375
-    my $self = shift;
376
-    if (@_) {
377
-        my $end_filter = {};
378
-        if (ref $_[0] eq 'HASH') { $end_filter = $_[0] }
379
-        else { 
380
-            $end_filter = _array_to_hash(
381
-                @_ > 1 ? [@_] : $_[0]
382
-            );
383
-        }
384
-        for my $column (keys %$end_filter) {
385
-            my $fname = $end_filter->{$column};
386
-            if  (exists $end_filter->{$column}
387
-              && defined $fname
388
-              && ref $fname ne 'CODE') 
389
-            {
390
-              croak qq{Filter "$fname" is not registered" } . _subname
391
-                unless exists $self->dbi->filters->{$fname};
392
-              $end_filter->{$column} = $self->dbi->filters->{$fname};
393
-            }
394
-        }
395
-        $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
396
-        return $self;
374
+  warn "end_filter method is DEPRECATED!";
375
+  my $self = shift;
376
+  if (@_) {
377
+    my $end_filter = {};
378
+    if (ref $_[0] eq 'HASH') { $end_filter = $_[0] }
379
+    else { 
380
+      $end_filter = _array_to_hash(
381
+          @_ > 1 ? [@_] : $_[0]
382
+      );
383
+    }
384
+    for my $column (keys %$end_filter) {
385
+      my $fname = $end_filter->{$column};
386
+      if (exists $end_filter->{$column}
387
+        && defined $fname
388
+        && ref $fname ne 'CODE') 
389
+      {
390
+        croak qq{Filter "$fname" is not registered" } . _subname
391
+          unless exists $self->dbi->filters->{$fname};
392
+        $end_filter->{$column} = $self->dbi->filters->{$fname};
393
+      }
397 394
     }
398
-    return $self->{end_filter} ||= {};
395
+    $self->{end_filter} = {%{$self->end_filter}, %$end_filter};
396
+    return $self;
397
+  }
398
+  return $self->{end_filter} ||= {};
399 399
 }
400 400
 # DEPRECATED!
401 401
 sub remove_end_filter {
402
-    warn "remove_end_filter is DEPRECATED!";
403
-    my $self = shift;
404
-    $self->{end_filter} = {};
405
-    return $self;
402
+  warn "remove_end_filter is DEPRECATED!";
403
+  my $self = shift;
404
+  $self->{end_filter} = {};
405
+  return $self;
406 406
 }
407 407
 # DEPRECATED!
408 408
 sub remove_filter {
409
-    warn "remove_filter is DEPRECATED!";
410
-    my $self = shift;
411
-    $self->{filter} = {};
412
-    return $self;
409
+  warn "remove_filter is DEPRECATED!";
410
+  my $self = shift;
411
+  $self->{filter} = {};
412
+  return $self;
413 413
 }
414 414
 # DEPRECATED!
415 415
 sub default_filter {
416
-    warn "default_filter is DEPRECATED!";
417
-    my $self = shift;
418
-    if (@_) {
419
-        my $fname = $_[0];
420
-        if (@_ && !$fname) {
421
-            $self->{default_filter} = undef;
422
-        }
423
-        else {
424
-            croak qq{Filter "$fname" is not registered}
425
-              unless exists $self->dbi->filters->{$fname};
426
-            $self->{default_filter} = $self->dbi->filters->{$fname};
427
-        }
428
-        return $self;
416
+  warn "default_filter is DEPRECATED!";
417
+  my $self = shift;
418
+  if (@_) {
419
+    my $fname = $_[0];
420
+    if (@_ && !$fname) {
421
+      $self->{default_filter} = undef;
429 422
     }
430
-    return $self->{default_filter};
423
+    else {
424
+      croak qq{Filter "$fname" is not registered}
425
+        unless exists $self->dbi->filters->{$fname};
426
+      $self->{default_filter} = $self->dbi->filters->{$fname};
427
+    }
428
+    return $self;
429
+  }
430
+  return $self->{default_filter};
431 431
 }
432 432
 # DEPRECATED!
433 433
 has 'filter_check'; 
... ...
@@ -440,48 +440,48 @@ DBIx::Custom::Result - Result of select statement
440 440
 
441 441
 =head1 SYNOPSIS
442 442
 
443
-    # Result
444
-    my $result = $dbi->select(table => 'book');
445
-
446
-    # Fetch a row and put it into array reference
447
-    while (my $row = $result->fetch) {
448
-        my $author = $row->[0];
449
-        my $title  = $row->[1];
450
-    }
451
-    
452
-    # Fetch only a first row and put it into array reference
453
-    my $row = $result->fetch_one;
454
-    
455
-    # Fetch all rows and put them into array of array reference
456
-    my $rows = $result->fetch_all;
457
-
458
-    # Fetch a row and put it into hash reference
459
-    while (my $row = $result->fetch_hash) {
460
-        my $title  = $row->{title};
461
-        my $author = $row->{author};
462
-    }
463
-    
464
-    # Fetch only a first row and put it into hash reference
465
-    my $row = $result->fetch_hash_one;
466
-    my $row = $result->one; # Alias for "fetch_hash_one"
467
-    
468
-    # Fetch all rows and put them into array of hash reference
469
-    my $rows = $result->fetch_hash_all;
470
-    my $rows = $result->all; # Alias for "fetch_hash_all"
443
+  # Result
444
+  my $result = $dbi->select(table => 'book');
445
+
446
+  # Fetch a row and put it into array reference
447
+  while (my $row = $result->fetch) {
448
+    my $author = $row->[0];
449
+    my $title  = $row->[1];
450
+  }
451
+  
452
+  # Fetch only a first row and put it into array reference
453
+  my $row = $result->fetch_one;
454
+  
455
+  # Fetch all rows and put them into array of array reference
456
+  my $rows = $result->fetch_all;
457
+
458
+  # Fetch a row and put it into hash reference
459
+  while (my $row = $result->fetch_hash) {
460
+    my $title  = $row->{title};
461
+    my $author = $row->{author};
462
+  }
463
+  
464
+  # Fetch only a first row and put it into hash reference
465
+  my $row = $result->fetch_hash_one;
466
+  my $row = $result->one; # Alias for "fetch_hash_one"
467
+  
468
+  # Fetch all rows and put them into array of hash reference
469
+  my $rows = $result->fetch_hash_all;
470
+  my $rows = $result->all; # Alias for "fetch_hash_all"
471 471
 
472 472
 =head1 ATTRIBUTES
473 473
 
474 474
 =head2 C<dbi>
475 475
 
476
-    my $dbi = $result->dbi;
477
-    $result = $result->dbi($dbi);
476
+  my $dbi = $result->dbi;
477
+  $result = $result->dbi($dbi);
478 478
 
479 479
 L<DBIx::Custom> object.
480 480
 
481 481
 =head2 C<sth>
482 482
 
483
-    my $sth = $reuslt->sth
484
-    $result = $result->sth($sth);
483
+  my $sth = $reuslt->sth
484
+  $result = $result->sth($sth);
485 485
 
486 486
 Statement handle of L<DBI>.
487 487
 
... ...
@@ -492,72 +492,72 @@ and implements the following new ones.
492 492
 
493 493
 =head2 C<all>
494 494
 
495
-    my $rows = $result->all;
495
+  my $rows = $result->all;
496 496
 
497 497
 Same as C<fetch_hash_all>.
498 498
 
499 499
 =head2 C<column> EXPERIMENTAL
500 500
 
501
-    my $column = $result->column;
501
+  my $column = $result->column;
502 502
 
503 503
 Get first column's all values.
504 504
 
505
-    my $names = $dbi->select('name', table => 'book')->column;
505
+  my $names = $dbi->select('name', table => 'book')->column;
506 506
 
507 507
 =head2 C<fetch>
508 508
 
509
-    my $row = $result->fetch;
509
+  my $row = $result->fetch;
510 510
 
511 511
 Fetch a row and put it into array reference.
512 512
 
513 513
 =head2 C<fetch_all>
514 514
 
515
-    my $rows = $result->fetch_all;
515
+  my $rows = $result->fetch_all;
516 516
 
517 517
 Fetch all rows and put them into array of array reference.
518 518
 
519 519
 =head2 C<fetch_one>
520 520
 
521
-    my $row = $result->fetch_one;
521
+  my $row = $result->fetch_one;
522 522
 
523 523
 Fetch only a first row and put it into array reference,
524 524
 and finish statment handle.
525 525
 
526 526
 =head2 C<fetch_hash>
527 527
 
528
-    my $row = $result->fetch_hash;
528
+  my $row = $result->fetch_hash;
529 529
 
530 530
 Fetch a row and put it into hash reference.
531 531
 
532 532
 =head2 C<fetch_hash_all>
533 533
 
534
-    my $rows = $result->fetch_hash_all;
534
+  my $rows = $result->fetch_hash_all;
535 535
 
536 536
 Fetch all rows and put them into array of hash reference.
537 537
 
538 538
 =head2 C<fetch_hash_one>
539
-    
540
-    my $row = $result->fetch_hash_one;
539
+  
540
+  my $row = $result->fetch_hash_one;
541 541
 
542 542
 Fetch only a first row and put it into hash reference,
543 543
 and finish statment handle.
544 544
 
545 545
 =head2 C<fetch_hash_multi>
546 546
 
547
-    my $rows = $result->fetch_hash_multi(5);
548
-    
547
+  my $rows = $result->fetch_hash_multi(5);
548
+  
549 549
 Fetch multiple rows and put them into array of hash reference.
550 550
 
551 551
 =head2 C<fetch_multi>
552 552
 
553
-    my $rows = $result->fetch_multi(5);
554
-    
553
+  my $rows = $result->fetch_multi(5);
554
+  
555 555
 Fetch multiple rows and put them into array of array reference.
556 556
 
557 557
 =head2 C<filter>
558 558
 
559
-    $result->filter(title  => sub { uc $_[0] }, author => 'to_upper');
560
-    $result->filter([qw/title author/] => 'to_upper');
559
+  $result->filter(title  => sub { uc $_[0] }, author => 'to_upper');
560
+  $result->filter([qw/title author/] => 'to_upper');
561 561
 
562 562
 Set filter for column.
563 563
 You can use subroutine or filter name as filter.
... ...
@@ -565,92 +565,92 @@ This filter is executed after C<type_rule> filter.
565 565
 
566 566
 =head2 C<header>
567 567
 
568
-    my $header = $result->header;
568
+  my $header = $result->header;
569 569
 
570 570
 Get header column names.
571 571
 
572 572
 =head2 C<one>
573 573
 
574
-    my $row = $result->one;
574
+  my $row = $result->one;
575 575
 
576 576
 Alias for C<fetch_hash_one>.
577 577
 
578 578
 =head2 C<stash>
579 579
 
580
-    my $stash = $result->stash;
581
-    my $foo = $result->stash->{foo};
582
-    $result->stash->{foo} = $foo;
580
+  my $stash = $result->stash;
581
+  my $foo = $result->stash->{foo};
582
+  $result->stash->{foo} = $foo;
583 583
 
584 584
 Stash is hash reference to save some data.
585 585
 
586 586
 =head2 C<type_rule>
587
-    
588
-    # Merge type rule
589
-    $result->type_rule(
590
-        # DATE
591
-        9 => sub { ... },
592
-        # DATETIME or TIMESTAMP
593
-        11 => sub { ... }
594
-    );
595
-
596
-    # Replace type rule(by reference)
597
-    $result->type_rule([
598
-        # DATE
599
-        9 => sub { ... },
600
-        # DATETIME or TIMESTAMP
601
-        11 => sub { ... }
602
-    ]);
587
+  
588
+  # Merge type rule
589
+  $result->type_rule(
590
+    # DATE
591
+    9 => sub { ... },
592
+    # DATETIME or TIMESTAMP
593
+    11 => sub { ... }
594
+  );
595
+
596
+  # Replace type rule(by reference)
597
+  $result->type_rule([
598
+    # DATE
599
+    9 => sub { ... },
600
+    # DATETIME or TIMESTAMP
601
+    11 => sub { ... }
602
+  ]);
603 603
 
604 604
 This is same as L<DBIx::Custom>'s C<type_rule>'s <from>.
605 605
 
606 606
 =head2 C<type_rule_off>
607 607
 
608
-    $result = $result->type_rule_off;
608
+  $result = $result->type_rule_off;
609 609
 
610 610
 Turn C<from1> and C<from2> type rule off.
611 611
 By default, type rule is on.
612 612
 
613 613
 =head2 C<type_rule_on>
614 614
 
615
-    $result = $result->type_rule_on;
615
+  $result = $result->type_rule_on;
616 616
 
617 617
 Turn C<from1> and C<from2> type rule on.
618 618
 By default, type rule is on.
619 619
 
620 620
 =head2 C<type_rule1_off>
621 621
 
622
-    $result = $result->type_rule1_off;
622
+  $result = $result->type_rule1_off;
623 623
 
624 624
 Turn C<from1> type rule off.
625 625
 By default, type rule is on.
626 626
 
627 627
 =head2 C<type_rule1_on>
628 628
 
629
-    $result = $result->type_rule1_on;
629
+  $result = $result->type_rule1_on;
630 630
 
631 631
 Turn C<from1> type rule on.
632 632
 By default, type rule is on.
633 633
 
634 634
 =head2 C<type_rule2_off>
635 635
 
636
-    $result = $result->type_rule2_off;
636
+  $result = $result->type_rule2_off;
637 637
 
638 638
 Turn C<from2> type rule off.
639 639
 By default, type rule is on.
640 640
 
641 641
 =head2 C<type_rule2_on>
642 642
 
643
-    $result = $result->type_rule2_on;
643
+  $result = $result->type_rule2_on;
644 644
 
645 645
 Turn C<from2> type rule on.
646 646
 By default, type rule is on.
647 647
 
648 648
 =head2 C<value> EXPERIMENTAL
649 649
 
650
-    my $value = $result->value;
650
+  my $value = $result->value;
651 651
 
652 652
 Get first column's first value.
653 653
 
654
-    my $count = $dbi->select('count(*)')->value;
654
+  my $count = $dbi->select('count(*)')->value;
655 655
 
656 656
 =cut
+53 -55
lib/DBIx/Custom/Tag.pm
... ...
@@ -14,42 +14,40 @@ sub greater_than_equal { _basic('>=', @_) }
14 14
 sub greater_than       { _basic('>',  @_) }
15 15
 
16 16
 sub in {
17
-    my ($column, $count) = @_;
18
-    
19
-    # Check arguments
20
-    croak qq{Column name and count of values must be specified in tag "{in }" }
21
-        . _subname
22
-      unless $column && $count && $count =~ /^\d+$/;
23
-
24
-    # Part of statement
25
-    my $s = "$column in (";
26
-    for (my $i = 0; $i < $count; $i++) {
27
-        $s .= '?, ';
28
-    }
29
-    $s =~ s/, $//;
30
-    $s .= ')';
31
-    
32
-    # Columns
33
-    my $columns = [];
34
-    push @$columns, $column for (0 .. $count - 1);
35
-    
36
-    return [$s, $columns];
17
+  my ($column, $count) = @_;
18
+  
19
+  # Check arguments
20
+  croak qq{Column name and count of values must be specified in tag "{in }" }
21
+      . _subname
22
+    unless $column && $count && $count =~ /^\d+$/;
23
+
24
+  # Part of statement
25
+  my $s = "$column in (";
26
+  for (my $i = 0; $i < $count; $i++) { $s .= '?, ' }
27
+  $s =~ s/, $//;
28
+  $s .= ')';
29
+  
30
+  # Columns
31
+  my $columns = [];
32
+  push @$columns, $column for (0 .. $count - 1);
33
+  
34
+  return [$s, $columns];
37 35
 }
38 36
 
39 37
 sub insert_param {
40
-    my @columns = @_;
41
-    
42
-    # Insert parameters
43
-    my $s = '(';
44
-    $s .= "$_, " for @columns;
45
-    $s =~ s/, $//;
46
-    $s .= ') ';
47
-    $s .= 'values (';
48
-    $s .= "?, " for @columns;
49
-    $s =~ s/, $//;
50
-    $s .= ')';
51
-    
52
-    return [$s, \@columns];
38
+  my @columns = @_;
39
+  
40
+  # Insert parameters
41
+  my $s = '(';
42
+  $s .= "$_, " for @columns;
43
+  $s =~ s/, $//;
44
+  $s .= ') ';
45
+  $s .= 'values (';
46
+  $s .= "?, " for @columns;
47
+  $s =~ s/, $//;
48
+  $s .= ')';
49
+  
50
+  return [$s, \@columns];
53 51
 }
54 52
 
55 53
 sub like               { _basic('like', @_) }
... ...
@@ -58,34 +56,34 @@ sub lower_than         { _basic('<',    @_) }
58 56
 sub not_equal          { _basic('<>',   @_) }
59 57
 
60 58
 sub placeholder {
61
-    my $column = shift;
62
-    
63
-    # Check arguments
64
-    croak qq{Column name must be specified in tag "{? }" } . _subname
65
-      unless $column;
66
-    
67
-    return ['?', [$column]];
59
+  my $column = shift;
60
+  
61
+  # Check arguments
62
+  croak qq{Column name must be specified in tag "{? }" } . _subname
63
+    unless $column;
64
+  
65
+  return ['?', [$column]];
68 66
 }
69 67
 
70 68
 sub update_param {
71
-    my @columns = @_;
72
-    
73
-    # Update parameters
74
-    my $s = 'set ';
75
-    $s .= "$_ = ?, " for @columns;
76
-    $s =~ s/, $//;
77
-    
78
-    return [$s, \@columns];
69
+  my @columns = @_;
70
+  
71
+  # Update parameters
72
+  my $s = 'set ';
73
+  $s .= "$_ = ?, " for @columns;
74
+  $s =~ s/, $//;
75
+  
76
+  return [$s, \@columns];
79 77
 }
80 78
 
81 79
 sub _basic {
82
-    my ($name, $column) = @_;
83
-    
84
-    # Check arguments
85
-    croak qq{Column name must be specified in tag "{$name }" } . _subname
86
-      unless $column;
87
-    
88
-    return ["$column $name ?", [$column]];
80
+  my ($name, $column) = @_;
81
+  
82
+  # Check arguments
83
+  croak qq{Column name must be specified in tag "{$name }" } . _subname
84
+    unless $column;
85
+  
86
+  return ["$column $name ?", [$column]];
89 87
 }
90 88
 
91 89
 1;
+15 -19
lib/DBIx/Custom/Util.pm
... ...
@@ -8,27 +8,23 @@ use base 'Exporter';
8 8
 our @EXPORT_OK = qw/_array_to_hash _subname/;
9 9
 
10 10
 sub _array_to_hash {
11
-    my $array = shift;
11
+  my $array = shift;
12
+  
13
+  return $array if ref $array eq 'HASH';
14
+  return unless $array;
15
+  
16
+  my $hash = {};
17
+  
18
+  for (my $i = 0; $i < @$array; $i += 2) {
19
+    my $key = $array->[$i];
20
+    my $f = $array->[$i + 1];
12 21
     
13
-    return $array if ref $array eq 'HASH';
14
-    return unless $array;
15
-    
16
-    my $hash = {};
17
-    
18
-    for (my $i = 0; $i < @$array; $i += 2) {
19
-        my $key = $array->[$i];
20
-        my $f = $array->[$i + 1];
21
-        
22
-        if (ref $key eq 'ARRAY') {
23
-            for my $k (@$key) {
24
-                $hash->{$k} = $f;
25
-            }
26
-        }
27
-        else {
28
-            $hash->{$key} = $f;
29
-        }
22
+    if (ref $key eq 'ARRAY') {
23
+      for my $k (@$key) { $hash->{$k} = $f }
30 24
     }
31
-    return $hash;
25
+    else { $hash->{$key} = $f }
26
+  }
27
+  return $hash;
32 28
 }
33 29
 
34 30
 sub _subname { '(' . (caller 1)[3] . ')' }
+196 -197
lib/DBIx/Custom/Where.pm
... ...
@@ -10,135 +10,134 @@ use overload '""' => sub { shift->to_string }, fallback => 1;
10 10
 push @DBIx::Custom::CARP_NOT, __PACKAGE__;
11 11
 
12 12
 has [qw/dbi param/],
13
-    clause => sub { [] };
13
+  clause => sub { [] };
14 14
 
15 15
 sub new {
16
-    my $self = shift->SUPER::new(@_);
17
-    
18
-    # Check attribute names
19
-    my @attrs = keys %$self;
20
-    for my $attr (@attrs) {
21
-        croak qq{"$attr" is invalid attribute name (} . _subname . ")"
22
-          unless $self->can($attr);
23
-    }
24
-    
25
-    return $self;
16
+  my $self = shift->SUPER::new(@_);
17
+  
18
+  # Check attribute names
19
+  my @attrs = keys %$self;
20
+  for my $attr (@attrs) {
21
+    croak qq{"$attr" is invalid attribute name (} . _subname . ")"
22
+      unless $self->can($attr);
23
+  }
24
+  
25
+  return $self;
26 26
 }
27 27
 
28 28
 sub to_string {
29
-    my $self = shift;
30
-    
31
-    # Clause
32
-    my $clause = $self->clause;
33
-    $clause = ['and', $clause] unless ref $clause eq 'ARRAY';
34
-    $clause->[0] = 'and' unless @$clause;
35
-    
36
-    # Parse
37
-    my $where = [];
38
-    my $count = {};
39
-    $self->{_query_builder} = $self->dbi->query_builder;
40
-    my $c = $self->dbi->safety_character;
41
-    $self->{_re} = $c eq 'a-zA-Z0-9_' ?
42
-      qr/[^\\]:([$c\.]+)/so : qr/[^\\]:([$c\.]+)/s;
43
-    
44
-    $self->{_quote} = $self->dbi->_quote;
45
-    $self->{_tag_parse} = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
46
-      ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->dbi->{tag_parse};
47
-    $self->_parse($clause, $where, $count, 'and');
29
+  my $self = shift;
30
+  
31
+  # Clause
32
+  my $clause = $self->clause;
33
+  $clause = ['and', $clause] unless ref $clause eq 'ARRAY';
34
+  $clause->[0] = 'and' unless @$clause;
35
+  
36
+  # Parse
37
+  my $where = [];
38
+  my $count = {};
39
+  $self->{_query_builder} = $self->dbi->query_builder;
40
+  my $c = $self->dbi->safety_character;
41
+  $self->{_re} = $c eq 'a-zA-Z0-9_' ?
42
+    qr/[^\\]:([$c\.]+)/so : qr/[^\\]:([$c\.]+)/s;
43
+  
44
+  $self->{_quote} = $self->dbi->_quote;
45
+  $self->{_tag_parse} = exists $ENV{DBIX_CUSTOM_TAG_PARSE}
46
+    ? $ENV{DBIX_CUSTOM_TAG_PARSE} : $self->dbi->{tag_parse};
47
+  $self->_parse($clause, $where, $count, 'and');
48 48
 
49
-    # Stringify
50
-    unshift @$where, 'where' if @$where;
51
-    return join(' ', @$where);
49
+  # Stringify
50
+  unshift @$where, 'where' if @$where;
51
+  return join(' ', @$where);
52 52
 }
53
-    
53
+  
54 54
 our %VALID_OPERATIONS = map { $_ => 1 } qw/and or/;
55 55
 sub _parse {
56
-    my ($self, $clause, $where, $count, $op, $info) = @_;
56
+  my ($self, $clause, $where, $count, $op, $info) = @_;
57
+  
58
+  # Array
59
+  if (ref $clause eq 'ARRAY') {
60
+    # Start
61
+    push @$where, '(';
57 62
     
58
-    # Array
59
-    if (ref $clause eq 'ARRAY') {
60
-        
61
-        # Start
62
-        push @$where, '(';
63
-        
64
-        # Operation
65
-        my $op = $clause->[0] || '';
66
-        croak qq{First argument must be "and" or "or" in where clause } .
67
-              qq{"$op" is passed} . _subname . ")"
68
-          unless $VALID_OPERATIONS{$op};
69
-        
70
-        my $pushed_array;
71
-        # Parse internal clause
72
-        for (my $i = 1; $i < @$clause; $i++) {
73
-            my $pushed = $self->_parse($clause->[$i], $where, $count, $op);
74
-            push @$where, $op if $pushed;
75
-            $pushed_array = 1 if $pushed;
76
-        }
77
-        pop @$where if $where->[-1] eq $op;
78
-        
79
-        # Undo
80
-        if ($where->[-1] eq '(') {
81
-            pop @$where;
82
-            pop @$where if ($where->[-1] || '') eq $op;
83
-        }
84
-        # End
85
-        else { push @$where, ')' }
86
-        
87
-        return $pushed_array;
63
+    # Operation
64
+    my $op = $clause->[0] || '';
65
+    croak qq{First argument must be "and" or "or" in where clause } .
66
+        qq{"$op" is passed} . _subname . ")"
67
+      unless $VALID_OPERATIONS{$op};
68
+    
69
+    my $pushed_array;
70
+    # Parse internal clause
71
+    for (my $i = 1; $i < @$clause; $i++) {
72
+      my $pushed = $self->_parse($clause->[$i], $where, $count, $op);
73
+      push @$where, $op if $pushed;
74
+      $pushed_array = 1 if $pushed;
75
+    }
76
+    pop @$where if $where->[-1] eq $op;
77
+    
78
+    # Undo
79
+    if ($where->[-1] eq '(') {
80
+      pop @$where;
81
+      pop @$where if ($where->[-1] || '') eq $op;
88 82
     }
83
+    # End
84
+    else { push @$where, ')' }
89 85
     
90
-    # String
86
+    return $pushed_array;
87
+  }
88
+  
89
+  # String
90
+  else {
91
+    # Pushed
92
+    my $pushed;
93
+    
94
+    # Column
95
+    my $re = $self->{_re};
96
+    
97
+    my $column;
98
+    my $sql = " " . $clause || '';
99
+    if ($self->{_tag_parse} && ($sql =~ /\s\{/)) {
100
+      my $columns = $self->dbi->query_builder->build_query($sql)->{columns};
101
+      $column = $columns->[0];
102
+    }
91 103
     else {
92
-        # Pushed
93
-        my $pushed;
94
-        
95
-        # Column
96
-        my $re = $self->{_re};
97
-        
98
-        my $column;
99
-        my $sql = " " . $clause || '';
100
-        if ($self->{_tag_parse} && ($sql =~ /\s\{/)) {
101
-            my $columns = $self->dbi->query_builder->build_query($sql)->{columns};
102
-            $column = $columns->[0];
103
-        }
104
-        else {
105
-            $sql =~ s/([0-9]):/$1\\:/g;
106
-            ($column) = $sql =~ /$re/;
107
-        }
108
-        unless (defined $column) {
109
-            push @$where, $clause;
110
-            $pushed = 1;
111
-            return $pushed;
112
-        }
113
-        
114
-        # Column count up
115
-        my $count = ++$count->{$column};
104
+      $sql =~ s/([0-9]):/$1\\:/g;
105
+      ($column) = $sql =~ /$re/;
106
+    }
107
+    unless (defined $column) {
108
+      push @$where, $clause;
109
+      $pushed = 1;
110
+      return $pushed;
111
+    }
112
+    
113
+    # Column count up
114
+    my $count = ++$count->{$column};
115
+    
116
+    # Push
117
+    my $param = $self->{param};
118
+    if (ref $param eq 'HASH') {
119
+      if (exists $param->{$column}) {
120
+        my $if = $self->{_if};
116 121
         
117
-        # Push
118
-        my $param = $self->{param};
119
-        if (ref $param eq 'HASH') {
120
-            if (exists $param->{$column}) {
121
-                my $if = $self->{_if};
122
-                
123
-                if (ref $param->{$column} eq 'ARRAY') {
124
-                    $pushed = 1 if exists $param->{$column}->[$count - 1]
125
-                      && ref $param->{$column}->[$count - 1] ne 'DBIx::Custom::NotExists'
126
-                }
127
-                elsif ($count == 1) { $pushed = 1 }
128
-            }
129
-            push @$where, $clause if $pushed;
122
+        if (ref $param->{$column} eq 'ARRAY') {
123
+          $pushed = 1 if exists $param->{$column}->[$count - 1]
124
+            && ref $param->{$column}->[$count - 1] ne 'DBIx::Custom::NotExists'
130 125
         }
131
-        elsif (!defined $param) {
132
-            push @$where, $clause;
133
-            $pushed = 1;
134
-        }
135
-        else {
136
-            croak "Parameter must be hash reference or undfined value ("
137
-                . _subname . ")"
138
-        }
139
-        return $pushed;
126
+        elsif ($count == 1) { $pushed = 1 }
127
+      }
128
+      push @$where, $clause if $pushed;
129
+    }
130
+    elsif (!defined $param) {
131
+      push @$where, $clause;
132
+      $pushed = 1;
140 133
     }
141
-    return;
134
+    else {
135
+      croak "Parameter must be hash reference or undfined value ("
136
+          . _subname . ")"
137
+    }
138
+    return $pushed;
139
+  }
140
+  return;
142 141
 }
143 142
 1;
144 143
 
... ...
@@ -147,103 +146,103 @@ sub _parse {
147 146
 DBIx::Custom::Where - Where clause
148 147
 
149 148
 =head1 SYNOPSYS
150
-    
151
-    # Create DBIx::Custom::Where object
152
-    my $where = $dbi->where;
153
-    
154
-    # Set clause and parameter
155
-    $where->clause(['and', ':title{like}', ':price{=}']);
156
-    
157
-    # Create where clause by to_string method
158
-    my $where_clause = $where->to_string;
159
-    
160
-    # Create where clause by stringify
161
-    my $where_clause = "$where";
162
-    
163
-    # Created where clause in the above way
164
-    where :title{=} and :price{like}
165
-    
166
-    # Only price condition
167
-    $where->clause(['and', ':title{like}', ':price{=}']);
168
-    $where->param({price => 1900});
169
-    my $where_clause = "$where";
170
-    
171
-    # Created where clause in the above way
172
-    where :price{=}
173
-    
174
-    # Only title condition
175
-    $where->clause(['and', ':title{like}', ':price{=}']);
176
-    $where->param({title => 'Perl'});
177
-    my $where_clause = "$where";
178
-    
179
-    # Created where clause in the above way
180
-    where :title{like}
181
-    
182
-    # Nothing
183
-    $where->clause(['and', ':title{like}', ':price{=}']);
184
-    $where->param({});
185
-    my $where_clause = "$where";
186
-    
187
-    # or condition
188
-    $where->clause(['or', ':title{like}', ':price{=}']);
189
-    
190
-    # More than one parameter
191
-    $where->clause(['and', ':price{>}', ':price{<}']);
192
-    $where->param({price => [1000, 2000]});
193
-    
194
-    # Only first condition
195
-    $where->clause(['and', ':price{>}', ':price{<}']);
196
-    $where->param({price => [1000, $dbi->not_exists]});
197
-    
198
-    # Only second condition
199
-    $where->clause(['and', ':price{>}', ':price{<}']);
200
-    $where->param({price => [$dbi->not_exists, 2000]});
201
-    
202
-    # More complex condition
203
-    $where->clause(
204
-        [
205
-            'and',
206
-            ':price{=}',
207
-            ['or', ':title{=}', ':title{=}', ':title{=}']
208
-        ]
209
-    );
210
-    my $where_clause = "$where";
211
-    
212
-    # Created where clause in the above way
213
-    where :price{=} and (:title{=} or :title{=} or :title{=})
214
-    
215
-    # Using Full-qualified column name
216
-    $where->clause(['and', ':book.title{like}', ':book.price{=}']);
149
+  
150
+  # Create DBIx::Custom::Where object
151
+  my $where = $dbi->where;
152
+  
153
+  # Set clause and parameter
154
+  $where->clause(['and', ':title{like}', ':price{=}']);
155
+  
156
+  # Create where clause by to_string method
157
+  my $where_clause = $where->to_string;
158
+  
159
+  # Create where clause by stringify
160
+  my $where_clause = "$where";
161
+  
162
+  # Created where clause in the above way
163
+  where :title{=} and :price{like}
164
+  
165
+  # Only price condition
166
+  $where->clause(['and', ':title{like}', ':price{=}']);
167
+  $where->param({price => 1900});
168
+  my $where_clause = "$where";
169
+  
170
+  # Created where clause in the above way
171
+  where :price{=}
172
+  
173
+  # Only title condition
174
+  $where->clause(['and', ':title{like}', ':price{=}']);
175
+  $where->param({title => 'Perl'});
176
+  my $where_clause = "$where";
177
+  
178
+  # Created where clause in the above way
179
+  where :title{like}
180
+  
181
+  # Nothing
182
+  $where->clause(['and', ':title{like}', ':price{=}']);
183
+  $where->param({});
184
+  my $where_clause = "$where";
185
+  
186
+  # or condition
187
+  $where->clause(['or', ':title{like}', ':price{=}']);
188
+  
189
+  # More than one parameter
190
+  $where->clause(['and', ':price{>}', ':price{<}']);
191
+  $where->param({price => [1000, 2000]});
192
+  
193
+  # Only first condition
194
+  $where->clause(['and', ':price{>}', ':price{<}']);
195
+  $where->param({price => [1000, $dbi->not_exists]});
196
+  
197
+  # Only second condition
198
+  $where->clause(['and', ':price{>}', ':price{<}']);
199
+  $where->param({price => [$dbi->not_exists, 2000]});
200
+  
201
+  # More complex condition
202
+  $where->clause(
203
+    [
204
+      'and',
205
+      ':price{=}',
206
+      ['or', ':title{=}', ':title{=}', ':title{=}']
207
+    ]
208
+  );
209
+  my $where_clause = "$where";
210
+  
211
+  # Created where clause in the above way
212
+  where :price{=} and (:title{=} or :title{=} or :title{=})
213
+  
214
+  # Using Full-qualified column name
215
+  $where->clause(['and', ':book.title{like}', ':book.price{=}']);
217 216
 
218 217
 =head1 ATTRIBUTES
219 218
 
220 219
 =head2 C<clause>
221 220
 
222
-    my $clause = $where->clause;
223
-    $where = $where->clause(
224
-        ['and',
225
-            ':title{=}', 
226
-            ['or', ':date{<}', ':date{>}']
227
-        ]
228
-    );
221
+  my $clause = $where->clause;
222
+  $where = $where->clause(
223
+    ['and',
224
+      ':title{=}', 
225
+      ['or', ':date{<}', ':date{>}']
226
+    ]
227
+  );
229 228
 
230 229
 Where clause. Above one is expanded to the following SQL by to_string
231 230
 If all parameter names is exists.
232 231
 
233
-    where title = :title and ( date < :date or date > :date )
232
+  where title = :title and ( date < :date or date > :date )
234 233
 
235 234
 =head2 C<param>
236 235
 
237
-    my $param = $where->param;
238
-    $where = $where->param({
239
-        title => 'Perl',
240
-        date => ['2010-11-11', '2011-03-05'],
241
-    });
236
+  my $param = $where->param;
237
+  $where = $where->param({
238
+    title => 'Perl',
239
+    date => ['2010-11-11', '2011-03-05'],
240
+  });
242 241
 
243 242
 =head2 C<dbi>
244 243
 
245
-    my $dbi = $where->dbi;
246
-    $where = $where->dbi($dbi);
244
+  my $dbi = $where->dbi;
245
+  $where = $where->dbi($dbi);
247 246
 
248 247
 L<DBIx::Custom> object.
249 248
 
... ...
@@ -254,12 +253,12 @@ and implements the following new ones.
254 253
 
255 254
 =head2 C<to_string>
256 255
 
257
-    $where->to_string;
256
+  $where->to_string;
258 257
 
259 258
 Convert where clause to string.
260 259
 
261 260
 double quote is override to execute C<to_string> method.
262 261
 
263
-    my $string_where = "$where";
262
+  my $string_where = "$where";
264 263
 
265 264
 =cut