... | ... |
@@ -1,4 +1,5 @@ |
1 | 1 |
0.1701 |
2 |
+ - added EXPERIMENTAL each_table method |
|
2 | 3 |
- select method column option [COLUMN, as => ALIAS] format is DEPRECATED! |
3 | 4 |
changed to [COLUMN => ALIAS] |
4 | 5 |
- added EXPERIMENTAL DBIx::Custom::Result header method |
... | ... |
@@ -284,6 +284,19 @@ sub each_column { |
284 | 284 |
} |
285 | 285 |
} |
286 | 286 |
|
287 |
+sub each_table { |
|
288 |
+ my ($self, $cb) = @_; |
|
289 |
+ |
|
290 |
+ # Iterate all tables |
|
291 |
+ my $sth_tables = $self->dbh->table_info; |
|
292 |
+ while (my $table_info = $sth_tables->fetchrow_hashref) { |
|
293 |
+ |
|
294 |
+ # Table |
|
295 |
+ my $table = $table_info->{TABLE_NAME}; |
|
296 |
+ $self->$cb($table, $table_info); |
|
297 |
+ } |
|
298 |
+} |
|
299 |
+ |
|
287 | 300 |
our %EXECUTE_ARGS = map { $_ => 1 } @COMMON_ARGS, 'param'; |
288 | 301 |
|
289 | 302 |
sub execute { |
... | ... |
@@ -2076,6 +2089,21 @@ Argument is callback when one column is found. |
2076 | 2089 |
Callback receive four arguments, dbi object, table name, |
2077 | 2090 |
column name and column information. |
2078 | 2091 |
|
2092 |
+=head2 C<each_table> EXPERIMENTAL |
|
2093 |
+ |
|
2094 |
+ $dbi->each_table( |
|
2095 |
+ sub { |
|
2096 |
+ my ($dbi, $table, $table_info) = @_; |
|
2097 |
+ |
|
2098 |
+ my $table_name = $table_info->{TABLE_NAME}; |
|
2099 |
+ } |
|
2100 |
+ ); |
|
2101 |
+ |
|
2102 |
+Iterate all table informationsfrom database. |
|
2103 |
+Argument is callback when one table is found. |
|
2104 |
+Callback receive three arguments, dbi object, table name, |
|
2105 |
+table information. |
|
2106 |
+ |
|
2079 | 2107 |
=head2 C<execute> |
2080 | 2108 |
|
2081 | 2109 |
my $result = $dbi->execute( |
... | ... |
@@ -2973,75 +3001,77 @@ DEBUG output encoding. Default to UTF-8. |
2973 | 3001 |
L<DBIx::Custom> |
2974 | 3002 |
|
2975 | 3003 |
# Attribute methods |
2976 |
- data_source # Removed at 2017/1/1 |
|
2977 |
- dbi_options # Removed at 2017/1/1 |
|
2978 |
- filter_check # Removed at 2017/1/1 |
|
2979 |
- reserved_word_quote # Removed at 2017/1/1 |
|
2980 |
- cache_method # Removed at 2017/1/1 |
|
3004 |
+ data_source # will be removed at 2017/1/1 |
|
3005 |
+ dbi_options # will be removed at 2017/1/1 |
|
3006 |
+ filter_check # will be removed at 2017/1/1 |
|
3007 |
+ reserved_word_quote # will be removed at 2017/1/1 |
|
3008 |
+ cache_method # will be removed at 2017/1/1 |
|
2981 | 3009 |
|
2982 | 3010 |
# Methods |
2983 |
- create_query # Removed at 2017/1/1 |
|
2984 |
- apply_filter # Removed at 2017/1/1 |
|
2985 |
- select_at # Removed at 2017/1/1 |
|
2986 |
- delete_at # Removed at 2017/1/1 |
|
2987 |
- update_at # Removed at 2017/1/1 |
|
2988 |
- insert_at # Removed at 2017/1/1 |
|
2989 |
- register_tag # Removed at 2017/1/1 |
|
2990 |
- default_bind_filter # Removed at 2017/1/1 |
|
2991 |
- default_fetch_filter # Removed at 2017/1/1 |
|
2992 |
- insert_param_tag # Removed at 2017/1/1 |
|
2993 |
- register_tag_processor # Removed at 2017/1/1 |
|
2994 |
- update_param_tag # Removed at 2017/1/1 |
|
3011 |
+ create_query # will be removed at 2017/1/1 |
|
3012 |
+ apply_filter # will be removed at 2017/1/1 |
|
3013 |
+ select_at # will be removed at 2017/1/1 |
|
3014 |
+ delete_at # will be removed at 2017/1/1 |
|
3015 |
+ update_at # will be removed at 2017/1/1 |
|
3016 |
+ insert_at # will be removed at 2017/1/1 |
|
3017 |
+ register_tag # will be removed at 2017/1/1 |
|
3018 |
+ default_bind_filter # will be removed at 2017/1/1 |
|
3019 |
+ default_fetch_filter # will be removed at 2017/1/1 |
|
3020 |
+ insert_param_tag # will be removed at 2017/1/1 |
|
3021 |
+ register_tag_processor # will be removed at 2017/1/1 |
|
3022 |
+ update_param_tag # will be removed at 2017/1/1 |
|
2995 | 3023 |
|
2996 | 3024 |
# Options |
2997 |
- select method relation option # Removed at 2017/1/1 |
|
2998 |
- select method param option # Removed at 2017/1/1 |
|
3025 |
+ select method relation option # will be removed at 2017/1/1 |
|
3026 |
+ select method param option # will be removed at 2017/1/1 |
|
3027 |
+ select method column option [COLUMN, as => ALIAS] format |
|
3028 |
+ # will be removed at 2017/1/1 |
|
2999 | 3029 |
|
3000 | 3030 |
# Others |
3001 | 3031 |
execute("select * from {= title}"); # execute tag parsing functionality |
3002 |
- # Removed at 2017/1/1 |
|
3003 |
- Query caching # Removed at 2017/1/1 |
|
3032 |
+ # will be removed at 2017/1/1 |
|
3033 |
+ Query caching # will be removed at 2017/1/1 |
|
3004 | 3034 |
|
3005 | 3035 |
L<DBIx::Custom::Model> |
3006 | 3036 |
|
3007 | 3037 |
# Attribute method |
3008 |
- filter # Removed at 2017/1/1 |
|
3009 |
- name # Removed at 2017/1/1 |
|
3010 |
- type # Removed at 2017/1/1 |
|
3038 |
+ filter # will be removed at 2017/1/1 |
|
3039 |
+ name # will be removed at 2017/1/1 |
|
3040 |
+ type # will be removed at 2017/1/1 |
|
3011 | 3041 |
|
3012 | 3042 |
L<DBIx::Custom::Query> |
3013 | 3043 |
|
3014 | 3044 |
# Attribute method |
3015 |
- default_filter # Removed at 2017/1/1 |
|
3045 |
+ default_filter # will be removed at 2017/1/1 |
|
3016 | 3046 |
|
3017 | 3047 |
L<DBIx::Custom::QueryBuilder> |
3018 | 3048 |
|
3019 | 3049 |
# Attribute method |
3020 |
- tags # Removed at 2017/1/1 |
|
3021 |
- tag_processors # Removed at 2017/1/1 |
|
3050 |
+ tags # will be removed at 2017/1/1 |
|
3051 |
+ tag_processors # will be removed at 2017/1/1 |
|
3022 | 3052 |
|
3023 | 3053 |
# Method |
3024 |
- register_tag # Removed at 2017/1/1 |
|
3025 |
- register_tag_processor # Removed at 2017/1/1 |
|
3054 |
+ register_tag # will be removed at 2017/1/1 |
|
3055 |
+ register_tag_processor # will be removed at 2017/1/1 |
|
3026 | 3056 |
|
3027 | 3057 |
# Others |
3028 | 3058 |
build_query("select * from {= title}"); # tag parsing functionality |
3029 |
- # Removed at 2017/1/1 |
|
3059 |
+ # will be removed at 2017/1/1 |
|
3030 | 3060 |
|
3031 | 3061 |
L<DBIx::Custom::Result> |
3032 | 3062 |
|
3033 | 3063 |
# Attribute method |
3034 |
- filter_check # Removed at 2017/1/1 |
|
3064 |
+ filter_check # will be removed at 2017/1/1 |
|
3035 | 3065 |
|
3036 | 3066 |
# Methods |
3037 |
- end_filter # Removed at 2017/1/1 |
|
3038 |
- remove_end_filter # Removed at 2017/1/1 |
|
3039 |
- remove_filter # Removed at 2017/1/1 |
|
3040 |
- default_filter # Removed at 2017/1/1 |
|
3067 |
+ end_filter # will be removed at 2017/1/1 |
|
3068 |
+ remove_end_filter # will be removed at 2017/1/1 |
|
3069 |
+ remove_filter # will be removed at 2017/1/1 |
|
3070 |
+ default_filter # will be removed at 2017/1/1 |
|
3041 | 3071 |
|
3042 | 3072 |
L<DBIx::Custom::Tag> |
3043 | 3073 |
|
3044 |
- This module is DEPRECATED! # Removed at 2017/1/1 |
|
3074 |
+ This module is DEPRECATED! # will be removed at 2017/1/1 |
|
3045 | 3075 |
|
3046 | 3076 |
=head1 BACKWORD COMPATIBLE POLICY |
3047 | 3077 |
|
... | ... |
@@ -3050,11 +3080,11 @@ except for attribute method. |
3050 | 3080 |
You can check all DEPRECATED functionalities by document. |
3051 | 3081 |
DEPRECATED functionality is removed after five years, |
3052 | 3082 |
but if at least one person use the functionality and tell me that thing |
3053 |
-I extend one year each time you tell me it. |
|
3083 |
+I extend one year each time he tell me it. |
|
3054 | 3084 |
|
3055 | 3085 |
EXPERIMENTAL functionality will be changed without warnings. |
3056 | 3086 |
|
3057 |
-This policy is changed at 2011/6/28 |
|
3087 |
+This policy was changed at 2011/6/28 |
|
3058 | 3088 |
|
3059 | 3089 |
=head1 BUGS |
3060 | 3090 |
|
... | ... |
@@ -905,6 +905,27 @@ is_deeply($infos, |
905 | 905 |
] |
906 | 906 |
|
907 | 907 |
); |
908 |
+test 'each_table'; |
|
909 |
+$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
910 |
+$dbi->execute($CREATE_TABLE->{2}); |
|
911 |
+$dbi->execute($CREATE_TABLE->{3}); |
|
912 |
+ |
|
913 |
+$infos = []; |
|
914 |
+$dbi->each_table(sub { |
|
915 |
+ my ($self, $table, $table_info) = @_; |
|
916 |
+ |
|
917 |
+ if ($table =~ /^table/) { |
|
918 |
+ my $info = [$table, $table_info->{TABLE_NAME}]; |
|
919 |
+ push @$infos, $info; |
|
920 |
+ } |
|
921 |
+}); |
|
922 |
+$infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos]; |
|
923 |
+is_deeply($infos, |
|
924 |
+ [ |
|
925 |
+ ['table1', 'table1'], |
|
926 |
+ ['table2', 'table2'], |
|
927 |
+ ] |
|
928 |
+); |
|
908 | 929 |
|
909 | 930 |
test 'limit'; |
910 | 931 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |