Showing 2 changed files with 14 additions and 1 deletions
+3
lib/DBI/Custom.pm
... ...
@@ -16,6 +16,7 @@ sub password    : ClassObjectAttr { initialize => {clone => 'scalar'} }
16 16
 sub data_source : ClassObjectAttr { initialize => {clone => 'scalar'} }
17 17
 sub dbi_options : ClassObjectAttr { initialize => {clone => 'hash', 
18 18
                                                    default => sub { {} } } }
19
+sub database    : ClassObjectAttr { initialize => {clone => 'scalar'} }
19 20
 
20 21
 sub bind_filter  : ClassObjectAttr { initialize => {clone => 'scalar'} }
21 22
 sub fetch_filter : ClassObjectAttr { initialize => {clone => 'scalar'} }
... ...
@@ -783,6 +784,8 @@ Please tell me bug if you find
783 784
     $self     = $dbi->database($database);
784 785
     $database = $dbi->database;
785 786
 
787
+This method will be used in subclass connect method.
788
+
786 789
 =head2 dbi_options
787 790
 
788 791
     # Set and get DBI option
+11 -1
t/01-core.t
... ...
@@ -23,6 +23,7 @@ my $dbi;
23 23
 test 'Constructor';
24 24
 $dbi = DBI::Custom->new(
25 25
     user => 'a',
26
+    database => 'a',
26 27
     password => 'b',
27 28
     data_source => 'c',
28 29
     dbi_options => {d => 1, e => 2},
... ...
@@ -34,7 +35,7 @@ $dbi = DBI::Custom->new(
34 35
     result_class => 'g',
35 36
     sql_template => $SQL_TMPL->{0},
36 37
 );
37
-is_deeply($dbi,{user => 'a', password => 'b', data_source => 'c', 
38
+is_deeply($dbi,{user => 'a', database => 'a', password => 'b', data_source => 'c', 
38 39
                 dbi_options => {d => 1, e => 2}, filters => {f => 3}, bind_filter => 'f',
39 40
                 fetch_filter => 'g', result_class => 'g',
40 41
                 sql_template => $SQL_TMPL->{0}}, $test);
... ...
@@ -48,6 +49,7 @@ test 'Sub class constructor';
48 49
     
49 50
     __PACKAGE__
50 51
       ->user('a')
52
+      ->database('a')
51 53
       ->password('b')
52 54
       ->data_source('c')
53 55
       ->dbi_options({d => 1, e => 2})
... ...
@@ -65,6 +67,7 @@ test 'Sub class constructor';
65 67
 }
66 68
 $dbi = DBI::Custom::T1->new(
67 69
     user => 'ao',
70
+    database => 'ao',
68 71
     password => 'bo',
69 72
     data_source => 'co',
70 73
     dbi_options => {do => 10, eo => 20},
... ...
@@ -80,6 +83,7 @@ $dbi = DBI::Custom::T1->new(
80 83
     sql_template => $SQL_TMPL->{0},
81 84
 );
82 85
 is($dbi->user, 'ao', "$test : user");
86
+is($dbi->database, 'ao', "$test : database");
83 87
 is($dbi->password, 'bo', "$test : passowr");
84 88
 is($dbi->data_source, 'co', "$test : data_source");
85 89
 is_deeply($dbi->dbi_options, {do => 10, eo => 20}, "$test : dbi_options");
... ...
@@ -94,6 +98,7 @@ isa_ok($dbi, 'DBI::Custom::T1');
94 98
 test 'Sub class constructor default';
95 99
 $dbi = DBI::Custom::T1->new;
96 100
 is($dbi->user, 'a', "$test : user");
101
+is($dbi->database, 'a', "$test : database");
97 102
 is($dbi->password, 'b', "$test : password");
98 103
 is($dbi->data_source, 'c', "$test : data_source");
99 104
 is_deeply($dbi->dbi_options, {d => 1, e => 2}, "$test : dbi_options");
... ...
@@ -113,6 +118,7 @@ test 'Sub sub class constructor default';
113 118
 }
114 119
 $dbi = DBI::Custom::T1_2->new;
115 120
 is($dbi->user, 'a', "$test : user");
121
+is($dbi->database, 'a', "$test : database");
116 122
 is($dbi->password, 'b', "$test : passowrd");
117 123
 is($dbi->data_source, 'c', "$test : data_source");
118 124
 is_deeply($dbi->dbi_options, {d => 1, e => 2}, "$test : dbi_options");
... ...
@@ -132,6 +138,7 @@ test 'Customized sub class constructor default';
132 138
     
133 139
     __PACKAGE__
134 140
       ->user('ao')
141
+      ->database('ao')
135 142
       ->password('bo')
136 143
       ->data_source('co')
137 144
       ->dbi_options({do => 10, eo => 20})
... ...
@@ -149,6 +156,7 @@ test 'Customized sub class constructor default';
149 156
 }
150 157
 $dbi = DBI::Custom::T1_3->new;
151 158
 is($dbi->user, 'ao', "$test : user");
159
+is($dbi->database, 'ao', "$test : database");
152 160
 is($dbi->password, 'bo', "$test : password");
153 161
 is($dbi->data_source, 'co', "$test : data_source");
154 162
 is_deeply($dbi->dbi_options, {do => 10, eo => 20}, "$test : dbi_options");
... ...
@@ -164,6 +172,7 @@ isa_ok($dbi, 'DBI::Custom::T1_3');
164 172
 test 'Customized sub class constructor';
165 173
 $dbi = DBI::Custom::T1_3->new(
166 174
     user => 'a',
175
+    database => 'a',
167 176
     password => 'b',
168 177
     data_source => 'c',
169 178
     dbi_options => {d => 1, e => 2},
... ...
@@ -179,6 +188,7 @@ $dbi = DBI::Custom::T1_3->new(
179 188
     sql_template => $SQL_TMPL->{2},
180 189
 );
181 190
 is($dbi->user, 'a', "$test : user");
191
+is($dbi->database, 'a', "$test : database");
182 192
 is($dbi->password, 'b', "$test : password");
183 193
 is($dbi->data_source, 'c', "$test : data_source");
184 194
 is_deeply($dbi->dbi_options, {d => 1, e => 2}, "$test : dbi_options");