Showing 7 changed files with 55 additions and 127 deletions
+55 -55
t/common.t
... ...
@@ -27,8 +27,8 @@ use MyDBI1;
27 27
         
28 28
         $self->include_model(
29 29
             MyModel2 => [
30
-                'book',
31
-                {class => 'Company', name => 'company'}
30
+                'table1',
31
+                'table2'
32 32
             ]
33 33
         );
34 34
     }
... ...
@@ -40,7 +40,7 @@ use MyDBI1;
40 40
 
41 41
     use base 'DBIx::Custom::Model';
42 42
 
43
-    package MyModel2::book;
43
+    package MyModel2::table1;
44 44
 
45 45
     use strict;
46 46
     use warnings;
... ...
@@ -55,7 +55,7 @@ use MyDBI1;
55 55
 
56 56
     sub list { shift->select; }
57 57
 
58
-    package MyModel2::Company;
58
+    package MyModel2::table2;
59 59
 
60 60
     use strict;
61 61
     use warnings;
... ...
@@ -2062,30 +2062,30 @@ is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
2062 2062
 
2063 2063
 $where = $dbi->where;
2064 2064
 $where->param({id => 1, author => 'Ken', price => 1900});
2065
-$where->map(id => 'book.id',
2066
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
2067
-    price => ['book.price', {if => sub { $_[0] eq 1900 }}]
2065
+$where->map(id => 'table1.id',
2066
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2067
+    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2068 2068
 );
2069
-is_deeply($where->param, {'book.id' => 1, 'book.author' => '%Ken%',
2070
-  'book.price' => 1900});
2069
+is_deeply($where->param, {'table1.id' => 1, 'table1.author' => '%Ken%',
2070
+  'table1.price' => 1900});
2071 2071
 
2072 2072
 $where = $dbi->where;
2073 2073
 $where->param({id => 0, author => 0, price => 0});
2074 2074
 $where->map(
2075
-    id => 'book.id',
2076
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
2077
-    price => ['book.price', sub { '%' . $_[0] . '%' },
2075
+    id => 'table1.id',
2076
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2077
+    price => ['table1.price', sub { '%' . $_[0] . '%' },
2078 2078
       {if => sub { $_[0] eq 0 }}]
2079 2079
 );
2080
-is_deeply($where->param, {'book.id' => 0, 'book.author' => '%0%', 'book.price' => '%0%'});
2080
+is_deeply($where->param, {'table1.id' => 0, 'table1.author' => '%0%', 'table1.price' => '%0%'});
2081 2081
 
2082 2082
 $where = $dbi->where;
2083 2083
 $where->param({id => '', author => '', price => ''});
2084 2084
 $where->if('length');
2085 2085
 $where->map(
2086
-    id => 'book.id',
2087
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
2088
-    price => ['book.price', sub { '%' . $_[0] . '%' },
2086
+    id => 'table1.id',
2087
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2088
+    price => ['table1.price', sub { '%' . $_[0] . '%' },
2089 2089
       {if => sub { $_[0] eq 1 }}]
2090 2090
 );
2091 2091
 is_deeply($where->param, {});
... ...
@@ -2094,50 +2094,50 @@ $where = $dbi->where;
2094 2094
 $where->param({id => undef, author => undef, price => undef});
2095 2095
 $where->if('length');
2096 2096
 $where->map(
2097
-    id => 'book.id',
2098
-    price => ['book.price', {if => 'exists'}]
2097
+    id => 'table1.id',
2098
+    price => ['table1.price', {if => 'exists'}]
2099 2099
 );
2100
-is_deeply($where->param, {'book.price' => undef});
2100
+is_deeply($where->param, {'table1.price' => undef});
2101 2101
 
2102 2102
 $where = $dbi->where;
2103 2103
 $where->param({price => 'a'});
2104 2104
 $where->if('length');
2105 2105
 $where->map(
2106
-    id => ['book.id', {if => 'exists'}],
2107
-    price => ['book.price', sub { '%' . $_[0] }, {if => 'exists'}]
2106
+    id => ['table1.id', {if => 'exists'}],
2107
+    price => ['table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
2108 2108
 );
2109
-is_deeply($where->param, {'book.price' => '%a'});
2109
+is_deeply($where->param, {'table1.price' => '%a'});
2110 2110
 
2111 2111
 $where = $dbi->where;
2112 2112
 $where->param({id => [1, 2], author => 'Ken', price => 1900});
2113 2113
 $where->map(
2114
-    id => 'book.id',
2115
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
2116
-    price => ['book.price', {if => sub { $_[0] eq 1900 }}]
2114
+    id => 'table1.id',
2115
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2116
+    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2117 2117
 );
2118
-is_deeply($where->param, {'book.id' => [1, 2], 'book.author' => '%Ken%',
2119
-  'book.price' => 1900});
2118
+is_deeply($where->param, {'table1.id' => [1, 2], 'table1.author' => '%Ken%',
2119
+  'table1.price' => 1900});
2120 2120
 
2121 2121
 $where = $dbi->where;
2122 2122
 $where->if('length');
2123 2123
 $where->param({id => ['', ''], author => 'Ken', price => 1900});
2124 2124
 $where->map(
2125
-    id => 'book.id',
2126
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
2127
-    price => ['book.price', {if => sub { $_[0] eq 1900 }}]
2125
+    id => 'table1.id',
2126
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2127
+    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2128 2128
 );
2129
-is_deeply($where->param, {'book.id' => [$dbi->not_exists, $dbi->not_exists], 'book.author' => '%Ken%',
2130
-  'book.price' => 1900});
2129
+is_deeply($where->param, {'table1.id' => [$dbi->not_exists, $dbi->not_exists], 'table1.author' => '%Ken%',
2130
+  'table1.price' => 1900});
2131 2131
 
2132 2132
 $where = $dbi->where;
2133 2133
 $where->param({id => ['', ''], author => 'Ken', price => 1900});
2134 2134
 $where->map(
2135
-    id => ['book.id', {if => 'length'}],
2136
-    author => ['book.author', sub { '%' . $_[0] . '%' }, {if => 'defined'}],
2137
-    price => ['book.price', {if => sub { $_[0] eq 1900 }}]
2135
+    id => ['table1.id', {if => 'length'}],
2136
+    author => ['table1.author', sub { '%' . $_[0] . '%' }, {if => 'defined'}],
2137
+    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2138 2138
 );
2139
-is_deeply($where->param, {'book.id' => [$dbi->not_exists, $dbi->not_exists], 'book.author' => '%Ken%',
2140
-  'book.price' => 1900});
2139
+is_deeply($where->param, {'table1.id' => [$dbi->not_exists, $dbi->not_exists], 'table1.author' => '%Ken%',
2140
+  'table1.price' => 1900});
2141 2141
 
2142 2142
 test 'dbi_option default';
2143 2143
 $dbi = DBIx::Custom->new;
... ...
@@ -3074,44 +3074,44 @@ test 'map_param';
3074 3074
 $dbi = DBIx::Custom->connect;
3075 3075
 $param = $dbi->map_param(
3076 3076
     {id => 1, author => 'Ken', price => 1900},
3077
-    id => 'book.id',
3078
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
3079
-    price => ['book.price', {if => sub { $_[0] eq 1900 }}]
3077
+    id => 'table1.id',
3078
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
3079
+    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
3080 3080
 );
3081
-is_deeply($param, {'book.id' => 1, 'book.author' => '%Ken%',
3082
-  'book.price' => 1900});
3081
+is_deeply($param, {'table1.id' => 1, 'table1.author' => '%Ken%',
3082
+  'table1.price' => 1900});
3083 3083
 
3084 3084
 $param = $dbi->map_param(
3085 3085
     {id => 0, author => 0, price => 0},
3086
-    id => 'book.id',
3087
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
3088
-    price => ['book.price', sub { '%' . $_[0] . '%' },
3086
+    id => 'table1.id',
3087
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
3088
+    price => ['table1.price', sub { '%' . $_[0] . '%' },
3089 3089
       {if => sub { $_[0] eq 0 }}]
3090 3090
 );
3091
-is_deeply($param, {'book.id' => 0, 'book.author' => '%0%', 'book.price' => '%0%'});
3091
+is_deeply($param, {'table1.id' => 0, 'table1.author' => '%0%', 'table1.price' => '%0%'});
3092 3092
 
3093 3093
 $param = $dbi->map_param(
3094 3094
     {id => '', author => '', price => ''},
3095
-    id => 'book.id',
3096
-    author => ['book.author', sub { '%' . $_[0] . '%' }],
3097
-    price => ['book.price', sub { '%' . $_[0] . '%' },
3095
+    id => 'table1.id',
3096
+    author => ['table1.author', sub { '%' . $_[0] . '%' }],
3097
+    price => ['table1.price', sub { '%' . $_[0] . '%' },
3098 3098
       {if => sub { $_[0] eq 1 }}]
3099 3099
 );
3100 3100
 is_deeply($param, {});
3101 3101
 
3102 3102
 $param = $dbi->map_param(
3103 3103
     {id => undef, author => undef, price => undef},
3104
-    id => 'book.id',
3105
-    price => ['book.price', {if => 'exists'}]
3104
+    id => 'table1.id',
3105
+    price => ['table1.price', {if => 'exists'}]
3106 3106
 );
3107
-is_deeply($param, {'book.price' => undef});
3107
+is_deeply($param, {'table1.price' => undef});
3108 3108
 
3109 3109
 $param = $dbi->map_param(
3110 3110
     {price => 'a'},
3111
-    id => ['book.id', {if => 'exists'}],
3112
-    price => ['book.price', sub { '%' . $_[0] }, {if => 'exists'}]
3111
+    id => ['table1.id', {if => 'exists'}],
3112
+    price => ['table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
3113 3113
 );
3114
-is_deeply($param, {'book.price' => '%a'});
3114
+is_deeply($param, {'table1.price' => '%a'});
3115 3115
 
3116 3116
 test 'order';
3117 3117
 $dbi = DBIx::Custom->connect;
-17
t/common/MyModel1/Company.pm
... ...
@@ -1,17 +0,0 @@
1
-package MyModel1::Company;
2
-
3
-use strict;
4
-use warnings;
5
-
6
-use base 'DBIx::Custom::Model';
7
-
8
-
9
-sub insert {
10
-    my ($self, $param) = @_;
11
-    
12
-    return $self->SUPER::insert(param => $param);
13
-}
14
-
15
-sub list { shift->select; }
16
-
17
-1;
-13
t/common/MyModel1/book.pm
... ...
@@ -1,13 +0,0 @@
1
-package MyModel1::book;
2
-
3
-use DBIx::Custom::Model -base;
4
-
5
-sub insert {
6
-    my ($self, $param) = @_;
7
-    
8
-    return $self->SUPER::insert(param => $param);
9
-}
10
-
11
-sub list { shift->select; }
12
-
13
-1;
-9
t/common/MyModel4/book.pm
... ...
@@ -1,9 +0,0 @@
1
-package MyModel4::book;
2
-
3
-use base 'MyModel4';
4
-
5
-sub table { 'table1' }
6
-
7
-sub list { shift->select }
8
-
9
-1;
-8
t/common/MyModel4/company.pm
... ...
@@ -1,8 +0,0 @@
1
-package MyModel4::company;
2
-
3
-use base 'MyModel4';
4
-
5
-sub insert { shift->SUPER::insert(param => $_[0]) }
6
-sub list { shift->select }
7
-
8
-1;
-12
t/common/MyModel5/table1_1.pm
... ...
@@ -1,12 +0,0 @@
1
-package MyModel5::table1_1;
2
-
3
-use strict;
4
-use warnings;
5
-
6
-use base 'MyModel5';
7
-
8
-__PACKAGE__->attr(table => 'table2');
9
-
10
-__PACKAGE__->attr('primary_key' => sub { ['key1', 'key2'] });
11
-
12
-1;
-13
t/common/MyModel5/table1_2.pm
... ...
@@ -1,13 +0,0 @@
1
-package MyModel5::table1_2;
2
-
3
-use strict;
4
-use warnings;
5
-
6
-use base 'MyModel5';
7
-
8
-__PACKAGE__->attr(name => 'table1_3');
9
-__PACKAGE__->attr(table => 'table3');
10
-
11
-__PACKAGE__->attr('primary_key' => sub { ['key1', 'key2'] });
12
-
13
-1;