Showing 3 changed files with 5 additions and 136 deletions
+4 -2
Changes
... ...
@@ -1,4 +1,5 @@
1 1
 0.1723
2
+    - removed EXPERIMENTAL map_param method from DBIx::Custom
2 3
     - removed EXPERIMENTAL flag from the following DBIx::Custom::Result mehotds
3 4
       filter_on, type_rule, type_rule_off, type_rule_on, type_rule1_off,
4 5
       type_rule1_on, type_rule2_off, type_rule2_on
... ...
@@ -6,11 +7,12 @@
6 7
       sqlfilter, type_rule_off, type_rule1_off, type_rule2_off,
7 8
       table_alias, wrap
8 9
     - removed EXPERIMENTAL flag from DBIx::Custom::Order
9
-    - removed EXPERIMETNAL flag from the following DBIx::Custom mehtods
10
+    - removed EXPERIMETNAL flag from the following DBIx::Custom methods
10 11
       exclude_table, user_column_info,
11 12
       user_table_info, available_datatype, available_typename,
12 13
       assign_param, count, get_column_info, get_table_info
13
-      order, show_datatype, show_typename methods, type_rule
14
+      order, show_datatype, show_typename methods, type_rule,
15
+      mapper
14 16
     - added EXPERIMENTAL update_timestamp method to DBIx::Custom
15 17
     - added EXPERIMENTAL insert_timestamp method to DBIx::Custom
16 18
     - removed EXPERIMENTAL timestamp attribute from DBIx::Custom
+1 -91
lib/DBIx/Custom.pm
... ...
@@ -751,48 +751,6 @@ sub mapper {
751 751
     return DBIx::Custom::Mapper->new(@_);
752 752
 }
753 753
 
754
-sub map_param {
755
-    my $self = shift;
756
-    my $param = shift;
757
-    my %map = @_;
758
-    
759
-    # Mapping
760
-    my $map_param = {};
761
-    foreach my $key (keys %map) {
762
-        my $value_cb;
763
-        my $condition;
764
-        my $map_key;
765
-        
766
-        # Get mapping information
767
-        if (ref $map{$key} eq 'ARRAY') {
768
-            foreach my $some (@{$map{$key}}) {
769
-                $map_key = $some unless ref $some;
770
-                $condition = $some->{if} if ref $some eq 'HASH';
771
-                $value_cb = $some if ref $some eq 'CODE';
772
-            }
773
-        }
774
-        else {
775
-            $map_key = $map{$key};
776
-        }
777
-        $value_cb ||= sub { $_[0] };
778
-        $condition ||= sub { defined $_[0] && length $_[0] };
779
-
780
-        # Map parameter
781
-        my $value;
782
-        if (ref $condition eq 'CODE') {
783
-            $map_param->{$map_key} = $value_cb->($param->{$key})
784
-              if $condition->($param->{$key});
785
-        }
786
-        elsif ($condition eq 'exists') {
787
-            $map_param->{$map_key} = $value_cb->($param->{$key})
788
-              if exists $param->{$key};
789
-        }
790
-        else { croak qq/Condition must be code reference or "exists" / . _subname }
791
-    }
792
-    
793
-    return $map_param;
794
-}
795
-
796 754
 sub merge_param {
797 755
     my ($self, @params) = @_;
798 756
     
... ...
@@ -2918,60 +2876,12 @@ See L<DBIx::Custom::Model> to know model features.
2918 2876
 Parameter for timestamp columns when C<insert> method is executed
2919 2877
 with C<timestamp> option.
2920 2878
 
2921
-=head2 C<mapper EXPERIMETNAL>
2879
+=head2 C<mapper>
2922 2880
 
2923 2881
     my $mapper = $dbi->mapper(param => $param);
2924 2882
 
2925 2883
 Create a new L<DBIx::Custom::Mapper> object.
2926 2884
 
2927
-=head2 C<map_param> EXPERIMENTAL
2928
-
2929
-    my $map_param = $dbi->map_param(
2930
-        {id => 1, authro => 'Ken', price => 1900},
2931
-        'id' => 'book.id',
2932
-        'author' => ['book.author' => sub { '%' . $_[0] . '%' }],
2933
-        'price' => [
2934
-            'book.price', {if => sub { length $_[0] }}
2935
-        ]
2936
-    );
2937
-
2938
-Map paramters to other key and value. First argument is original
2939
-parameter. this is hash reference. Rest argument is mapping.
2940
-By default, Mapping is done if the value length is not zero.
2941
-
2942
-=over 4
2943
-
2944
-=item Key mapping
2945
-
2946
-    'id' => 'book.id'
2947
-
2948
-This is only key mapping. Value is same as original one.
2949
-
2950
-    (id => 1) is mapped to ('book.id' => 1) if value length is not zero.
2951
-
2952
-=item Key and value mapping
2953
-
2954
-    'author' => ['book.author' => sub { '%' . $_[0] . '%' }]
2955
-
2956
-This is key and value mapping. Frist element of array reference
2957
-is mapped key name, second element is code reference to map the value.
2958
-
2959
-    (author => 'Ken') is mapped to ('book.author' => '%Ken%')
2960
-      if value length is not zero.
2961
-
2962
-=item Condition
2963
-
2964
-    'price' => ['book.price', {if => 'exists'}]
2965
-    'price' => ['book.price', sub { '%' . $_[0] . '%' }, {if => 'exists'}]
2966
-    'price' => ['book.price', {if => sub { defined shift }}]
2967
-
2968
-If you need condition, you can sepecify it. this is code reference
2969
-or 'exists'. By default, condition is the following one.
2970
-
2971
-    sub { defined $_[0] && length $_[0] }
2972
-
2973
-=back
2974
-
2975 2885
 =head2 C<merge_param>
2976 2886
 
2977 2887
     my $param = $dbi->merge_param({key1 => 1}, {key1 => 1, key2 => 2});
-43
t/common.t
... ...
@@ -2873,49 +2873,6 @@ $param = $dbi->mapper(param => {id => 'a', author => 'b', price => 'c'}, pass =>
2873 2873
   ->map(price => 'book.price');
2874 2874
 is_deeply($param, {id => 'a', author => 'b', 'book.price' => 'c'});
2875 2875
 
2876
-test 'map_param';
2877
-$dbi = DBIx::Custom->connect;
2878
-$param = $dbi->map_param(
2879
-    {id => 1, author => 'Ken', price => 1900},
2880
-    id => "$table1.id",
2881
-    author => ["$table1.author", sub { '%' . $_[0] . '%' }],
2882
-    price => ["$table1.price", {if => sub { $_[0] eq 1900 }}]
2883
-);
2884
-is_deeply($param, {"$table1.id" => 1, "$table1.author" => '%Ken%',
2885
-  "$table1.price" => 1900});
2886
-
2887
-$param = $dbi->map_param(
2888
-    {id => 0, author => 0, price => 0},
2889
-    id => "$table1.id",
2890
-    author => ["$table1.author", sub { '%' . $_[0] . '%' }],
2891
-    price => ["$table1.price", sub { '%' . $_[0] . '%' },
2892
-      {if => sub { $_[0] eq 0 }}]
2893
-);
2894
-is_deeply($param, {"$table1.id" => 0, "$table1.author" => '%0%', "$table1.price" => '%0%'});
2895
-
2896
-$param = $dbi->map_param(
2897
-    {id => '', author => '', price => ''},
2898
-    id => "$table1.id",
2899
-    author => ["$table1.author", sub { '%' . $_[0] . '%' }],
2900
-    price => ["$table1.price", sub { '%' . $_[0] . '%' },
2901
-      {if => sub { $_[0] eq 1 }}]
2902
-);
2903
-is_deeply($param, {});
2904
-
2905
-$param = $dbi->map_param(
2906
-    {id => undef, author => undef, price => undef},
2907
-    id => "$table1.id",
2908
-    price => ["$table1.price", {if => 'exists'}]
2909
-);
2910
-is_deeply($param, {"$table1.price" => undef});
2911
-
2912
-$param = $dbi->map_param(
2913
-    {price => 'a'},
2914
-    id => ["$table1.id", {if => 'exists'}],
2915
-    price => ["$table1.price", sub { '%' . $_[0] }, {if => 'exists'}]
2916
-);
2917
-is_deeply($param, {"$table1.price" => '%a'});
2918
-
2919 2876
 test 'order';
2920 2877
 $dbi = DBIx::Custom->connect;
2921 2878
 eval { $dbi->execute("drop table $table1") };