Showing 2 changed files with 13 additions and 16 deletions
+13 -5
lib/DBI/Custom.pm
... ...
@@ -6,16 +6,18 @@ our $VERSION = '0.0101';
6 6
 use Carp 'croak';
7 7
 use DBI;
8 8
 use DBI::Custom::SQL::Template;
9
+use DBI::Custom::Result;
9 10
 
10 11
 ### Class-Object Accessors
11 12
 sub connect_info : ClassObjectAttr { type => 'hash',  auto_build => sub {
12 13
     shift->Object::Simple::initialize_class_object_attr(
13
-        default => sub { {} }, clone => sub {
14
+        clone => sub {
14 15
             my $value = shift;
15 16
             my $new_value = \%{$value || {}};
16 17
             $new_value->{options} = $value->{options} if $value->{options};
17 18
             return $new_value;
18
-        }
19
+        },
20
+        default => sub { {} },
19 21
     )
20 22
 }}
21 23
 
... ...
@@ -27,11 +29,17 @@ sub fetch_filter : ClassObjectAttr { auto_build => sub {
27 29
 }}
28 30
 
29 31
 sub filters : ClassObjectAttr { type => 'hash', deref => 1, auto_build => sub {
30
-    shift->Object::Simple::initialize_class_object_attr(clone => 'hash')
32
+    shift->Object::Simple::initialize_class_object_attr(
33
+        clone   => 'hash',
34
+        default => sub { {} }
35
+    )
31 36
 }}
32 37
 
33 38
 sub result_class : ClassObjectAttr { auto_build => sub {
34
-    shift->Object::Simple::initialize_class_object_attr(clone => 'scalar')
39
+    shift->Object::Simple::initialize_class_object_attr(
40
+        clone   => 'scalar',
41
+        default => 'DBI::Custom::Result'
42
+    )
35 43
 }}
36 44
 
37 45
 sub sql_template : ClassObjectAttr { auto_build => sub {
... ...
@@ -43,8 +51,8 @@ sub sql_template : ClassObjectAttr { auto_build => sub {
43 51
 
44 52
 sub valid_connect_info : ClassObjectAttr { type => 'hash', deref => 1, auto_build => sub {
45 53
     shift->Object::Simple::initialize_class_object_attr(
54
+        clone => 'hash',
46 55
         default => sub { return {map {$_ => 1} qw/data_source user password options/} },
47
-        clone => 'hash'
48 56
     )
49 57
 }}
50 58
 
-11
t/02-sqlite.t
... ...
@@ -69,7 +69,6 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
69 69
     my @rows;
70 70
     my $rows;
71 71
     
72
-    #----------
73 72
     $r = $dbi->query("select k1, k2 from t1");
74 73
     
75 74
     @rows = ();
... ...
@@ -79,7 +78,6 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
79 78
     is_deeply(\@rows, [[1, 2], [3, 4]], 'fetch');
80 79
     
81 80
     
82
-    #----------
83 81
     $r = $dbi->query("select k1, k2 from t1");
84 82
     
85 83
     @rows = ();
... ...
@@ -89,7 +87,6 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
89 87
     is_deeply(\@rows, [[1, 2], [3, 4]], 'fetch list context');
90 88
     
91 89
     
92
-    #-----------
93 90
     $r = $dbi->query("select k1, k2 from t1;");
94 91
     
95 92
     @rows = ();
... ...
@@ -99,7 +96,6 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
99 96
     is_deeply(\@rows, [{k1 => 1, k2 => 2}, {k1 => 3, k2 => 4}], 'fetch_hash');
100 97
     
101 98
     
102
-    #-----------
103 99
     $r = $dbi->query("select k1, k2 from t1;");
104 100
     
105 101
     @rows = ();
... ...
@@ -109,35 +105,30 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
109 105
     is_deeply(\@rows, [{k1 => 1, k2 => 2}, {k1 => 3, k2 => 4}], 'fetch hash list context');
110 106
     
111 107
     
112
-    #-----------
113 108
     $r = $dbi->query("select k1, k2 from t1");
114 109
     
115 110
     $rows = $r->fetch_all;
116 111
     is_deeply($rows, [[1, 2], [3, 4]], 'fetch_all');
117 112
     
118 113
     
119
-    #------------
120 114
     $r = $dbi->query("select k1, k2 from t1");
121 115
     
122 116
     @rows = $r->fetch_all;
123 117
     is_deeply(\@rows, [[1, 2], [3, 4]], 'fetch_all list context');
124 118
     
125 119
     
126
-    #------------
127 120
     $r = $dbi->query("select k1, k2 from t1");
128 121
     
129 122
     @rows = $r->fetch_all_hash;
130 123
     is_deeply($rows, [[1, 2], [3, 4]], 'fetch_all_hash');
131 124
     
132 125
     
133
-    #-------------
134 126
     $r = $dbi->query("select k1, k2 from t1");
135 127
     
136 128
     @rows = $r->fetch_all;
137 129
     is_deeply(\@rows, [[1, 2], [3, 4]], 'fetch_all_hash list context');
138 130
     
139 131
     
140
-    #---------------------------------------------------------------------
141 132
     $dbi->fetch_filter(sub {
142 133
         my ($key, $value, $type, $sth, $i) = @_;
143 134
         if ($key eq 'k1' && $value == 1 && $type =~ /char/i && $i == 0 && $sth->{TYPE}->[$i] eq $type) {
... ...
@@ -146,7 +137,6 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
146 137
         return $value;
147 138
     });
148 139
     
149
-    #-----------------------------------
150 140
     $r = $dbi->query("select k1, k2 from t1");
151 141
     
152 142
     $rows = $r->fetch_all;
... ...
@@ -154,7 +144,6 @@ $t->new->create_table1->insert({k1 => 1, k2 => 2}, {k1 => 3, k2 => 4})->test(sub
154 144
     is_deeply($rows, [[3, 2], [3, 4]], 'fetch_filter array');
155 145
     
156 146
     
157
-    #----------------------------------
158 147
     $r = $dbi->query("select k1, k2 from t1");
159 148
     
160 149
     $rows = $r->fetch_all_hash;