add test
|
1 |
use Test::More; |
2 |
use strict; |
|
3 |
use warnings; |
|
4 |
|
|
5 |
BEGIN { |
|
6 |
eval { require DBD::SQLite; 1 } |
|
7 |
or plan skip_all => 'DBD::SQLite required'; |
|
8 |
eval { DBD::SQLite->VERSION >= 1 } |
|
9 |
or plan skip_all => 'DBD::SQLite >= 1.00 required'; |
|
10 |
|
|
11 |
plan 'no_plan'; |
|
12 |
use_ok('DBI::Custom'); |
|
13 |
} |
|
14 |
|
|
cleanup
|
15 |
# Function for test name |
16 |
my $test; |
|
17 |
sub test { |
|
18 |
$test = shift; |
|
19 |
} |
|
add test
|
20 |
|
add tests
|
21 |
# Constant varialbes for test |
22 |
my $CREATE_TABLE = { |
|
add tests
|
23 |
0 => 'create table table1 (key1 char(255), key2 char(255));', |
add tests
|
24 |
1 => 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));', |
25 |
2 => 'create table table2 (key1 char(255), key3 char(255));' |
|
add prepare
|
26 |
}; |
27 |
|
|
add tests
|
28 |
my $SELECT_TMPL = { |
add tests
|
29 |
0 => 'select * from table1;' |
add tests
|
30 |
}; |
31 |
|
|
add tests
|
32 |
my $DROP_TABLE = { |
cleanup
|
33 |
0 => 'drop table table1' |
34 |
}; |
|
35 |
|
|
add tests
|
36 |
my $NEW_ARGS = { |
37 |
0 => {data_source => 'dbi:SQLite:dbname=:memory:'} |
|
38 |
}; |
|
39 |
|
|
40 |
# Variables for test |
|
cleanup
|
41 |
my $dbi; |
42 |
my $sth; |
|
43 |
my $tmpl; |
|
add cahce tests
|
44 |
my @tmpls; |
cleanup#
|
45 |
my $select_tmpl; |
46 |
my $insert_tmpl; |
|
add tests
|
47 |
my $update_tmpl; |
cleanup
|
48 |
my $params; |
49 |
my $sql; |
|
50 |
my $result; |
|
51 |
my @rows; |
|
52 |
my $rows; |
|
add tests
|
53 |
my $query; |
add cahce tests
|
54 |
my @queries; |
cleanup#
|
55 |
my $select_query; |
56 |
my $insert_query; |
|
add tests
|
57 |
my $update_query; |
add prepare
|
58 |
my $ret_val; |
cleanup#
|
59 |
|
cleanup
|
60 |
|
cleanup
|
61 |
test 'disconnect'; |
add tests
|
62 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
63 |
$dbi->connect; |
64 |
$dbi->disconnect; |
|
65 |
ok(!$dbi->dbh, $test); |
|
add tests
|
66 |
|
add tests
|
67 |
|
cleanup
|
68 |
test 'connected'; |
add tests
|
69 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
cleanup
|
70 |
ok(!$dbi->connected, "$test : not connected"); |
71 |
$dbi->connect; |
|
72 |
ok($dbi->connected, "$test : connected"); |
|
73 |
|
|
add tests
|
74 |
|
75 |
test 'preapare'; |
|
add tests
|
76 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
77 |
$sth = $dbi->prepare($CREATE_TABLE->{0}); |
78 |
ok($sth, "$test : auto connect"); |
|
79 |
$sth->execute; |
|
80 |
$sth = $dbi->prepare($DROP_TABLE->{0}); |
|
81 |
ok($sth, "$test : basic"); |
|
82 |
|
|
83 |
|
|
84 |
test 'do'; |
|
add tests
|
85 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
86 |
$ret_val = $dbi->do($CREATE_TABLE->{0}); |
87 |
ok(defined $ret_val, "$test : auto connect"); |
|
88 |
$ret_val = $dbi->do($DROP_TABLE->{0}); |
|
89 |
ok(defined $ret_val, "$test : basic"); |
|
90 |
|
|
91 |
|
|
cleanup
|
92 |
# Prepare table |
add tests
|
93 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
cleanup
|
94 |
$dbi->connect; |
add prepare
|
95 |
$dbi->do($CREATE_TABLE->{0}); |
96 |
$sth = $dbi->prepare("insert into table1 (key1, key2) values (?, ?);"); |
|
cleanup
|
97 |
$sth->execute(1, 2); |
98 |
$sth->execute(3, 4); |
|
add test
|
99 |
|
add test module
|
100 |
|
add tests
|
101 |
test 'DBI::Custom::Result test'; |
102 |
$tmpl = "select key1, key2 from table1"; |
|
103 |
$query = $dbi->create_query($tmpl); |
|
104 |
$result = $dbi->execute($query); |
|
cleanup
|
105 |
|
106 |
@rows = (); |
|
107 |
while (my $row = $result->fetch) { |
|
108 |
push @rows, [@$row]; |
|
add test module
|
109 |
} |
add tests
|
110 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch scalar context"); |
cleanup
|
111 |
|
add tests
|
112 |
$result = $dbi->execute($query); |
cleanup
|
113 |
@rows = (); |
114 |
while (my @row = $result->fetch) { |
|
115 |
push @rows, [@row]; |
|
add test module
|
116 |
} |
add tests
|
117 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch list context"); |
add test module
|
118 |
|
add tests
|
119 |
$result = $dbi->execute($query); |
cleanup
|
120 |
@rows = (); |
121 |
while (my $row = $result->fetch_hash) { |
|
122 |
push @rows, {%$row}; |
|
add test module
|
123 |
} |
add tests
|
124 |
is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : fetch_hash scalar context"); |
cleanup
|
125 |
|
add tests
|
126 |
$result = $dbi->execute($query); |
cleanup
|
127 |
@rows = (); |
128 |
while (my %row = $result->fetch_hash) { |
|
129 |
push @rows, {%row}; |
|
add test module
|
130 |
} |
add tests
|
131 |
is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : fetch hash list context"); |
add test module
|
132 |
|
add tests
|
133 |
$result = $dbi->execute($query); |
cleanup
|
134 |
$rows = $result->fetch_all; |
add tests
|
135 |
is_deeply($rows, [[1, 2], [3, 4]], "$test : fetch_all scalar context"); |
cleanup
|
136 |
|
add tests
|
137 |
$result = $dbi->execute($query); |
cleanup
|
138 |
@rows = $result->fetch_all; |
add tests
|
139 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch_all list context"); |
cleanup
|
140 |
|
add tests
|
141 |
$result = $dbi->execute($query); |
cleanup
|
142 |
@rows = $result->fetch_all_hash; |
add tests
|
143 |
is_deeply($rows, [[1, 2], [3, 4]], "$test : fetch_all_hash scalar context"); |
cleanup
|
144 |
|
add tests
|
145 |
$result = $dbi->execute($query); |
cleanup
|
146 |
@rows = $result->fetch_all; |
add tests
|
147 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch_all_hash list context"); |
cleanup
|
148 |
|
add tests
|
149 |
|
add tests
|
150 |
test 'Insert query return value'; |
cleanup
|
151 |
$dbi->do($DROP_TABLE->{0}); |
add tests
|
152 |
$dbi->do($CREATE_TABLE->{0}); |
153 |
$tmpl = "insert into table1 {insert key1 key2}"; |
|
154 |
$query = $dbi->create_query($tmpl); |
|
155 |
$ret_val = $dbi->execute($query, {key1 => 1, key2 => 2}); |
|
156 |
ok($ret_val, $test); |
|
157 |
|
|
add tests
|
158 |
|
159 |
test 'Direct execute'; |
|
cleanup
|
160 |
$dbi->do($DROP_TABLE->{0}); |
add tests
|
161 |
$dbi->do($CREATE_TABLE->{0}); |
162 |
$insert_tmpl = "insert into table1 {insert key1 key2}"; |
|
163 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2}, sub { |
|
164 |
my $query = shift; |
|
165 |
$query->bind_filter(sub { |
|
166 |
my ($key, $value) = @_; |
|
167 |
if ($key eq 'key2') { |
|
168 |
return $value + 1; |
|
169 |
} |
|
170 |
return $value; |
|
171 |
}); |
|
172 |
}); |
|
173 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
174 |
$rows = $result->fetch_all_hash; |
|
175 |
is_deeply($rows, [{key1 => 1, key2 => 3}], $test); |
|
176 |
|
|
177 |
|
|
add tests
|
178 |
test 'Filter basic'; |
cleanup
|
179 |
$dbi->do($DROP_TABLE->{0}); |
add tests
|
180 |
$dbi->do($CREATE_TABLE->{0}); |
cleanup#
|
181 |
|
add tests
|
182 |
$insert_tmpl = "insert into table1 {insert key1 key2};"; |
add prepare
|
183 |
$insert_query = $dbi->create_query($insert_tmpl); |
184 |
$insert_query->bind_filter(sub { |
|
add tests
|
185 |
my ($key, $value, $table, $column) = @_; |
186 |
if ($key eq 'key1' && $table eq '' && $column eq 'key1') { |
|
add prepare
|
187 |
return $value * 2; |
cleanup#
|
188 |
} |
189 |
return $value; |
|
190 |
}); |
|
add tests
|
191 |
$dbi->execute($insert_query, {key1 => 1, key2 => 2}); |
192 |
$select_query = $dbi->create_query($SELECT_TMPL->{0}); |
|
add prepare
|
193 |
$select_query->fetch_filter(sub { |
add tests
|
194 |
my ($key, $value, $type, $sth, $i) = @_; |
195 |
if ($key eq 'key2' && $type =~ /char/ && $sth->can('execute') && $i == 1) { |
|
add prepare
|
196 |
return $value * 3; |
197 |
} |
|
198 |
return $value; |
|
199 |
}); |
|
200 |
$result = $dbi->execute($select_query); |
|
201 |
$rows = $result->fetch_all_hash; |
|
add tests
|
202 |
is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : bind_filter fetch_filter"); |
cleanup#
|
203 |
|
add tests
|
204 |
$dbi->do("delete from table1;"); |
205 |
$insert_query->no_bind_filters('key1'); |
|
206 |
$select_query->no_fetch_filters('key2'); |
|
207 |
$dbi->execute($insert_query, {key1 => 1, key2 => 2}); |
|
208 |
$result = $dbi->execute($select_query); |
|
209 |
$rows = $result->fetch_all_hash; |
|
add tests
|
210 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : no_fetch_filters no_bind_filters"); |
add tests
|
211 |
|
cleanup
|
212 |
$dbi->do($DROP_TABLE->{0}); |
add tests
|
213 |
$dbi->do($CREATE_TABLE->{0}); |
214 |
$insert_tmpl = "insert into table1 {insert table1.key1 table1.key2}"; |
|
215 |
$insert_query = $dbi->create_query($insert_tmpl); |
|
216 |
$insert_query->bind_filter(sub { |
|
217 |
my ($key, $value, $table, $column) = @_; |
|
218 |
if ($key eq 'table1.key1' && $table eq 'table1' && $column eq 'key1') { |
|
219 |
return $value * 3; |
|
220 |
} |
|
221 |
return $value; |
|
222 |
}); |
|
223 |
$dbi->execute($insert_query, {table1 => {key1 => 1, key2 => 2}}); |
|
224 |
$select_query = $dbi->create_query($SELECT_TMPL->{0}); |
|
225 |
$result = $dbi->execute($select_query); |
|
226 |
$rows = $result->fetch_all_hash; |
|
227 |
is_deeply($rows, [{key1 => 3, key2 => 2}], "$test : insert with table name"); |
|
228 |
|
|
add tests
|
229 |
test 'Filter in'; |
230 |
$insert_tmpl = "insert into table1 {insert key1 key2};"; |
|
231 |
$insert_query = $dbi->create_query($insert_tmpl); |
|
232 |
$dbi->execute($insert_query, {key1 => 2, key2 => 4}); |
|
233 |
$select_tmpl = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}"; |
|
234 |
$select_query = $dbi->create_query($select_tmpl); |
|
235 |
$select_query->bind_filter(sub { |
|
236 |
my ($key, $value, $table, $column) = @_; |
|
237 |
if ($key eq 'table1.key1' && $table eq 'table1' && $column eq 'key1' || $key eq 'table1.key2') { |
|
238 |
return $value * 2; |
|
239 |
} |
|
240 |
return $value; |
|
241 |
}); |
|
242 |
$result = $dbi->execute($select_query, {table1 => {key1 => [1,5], key2 => [2,5]}}); |
|
243 |
$rows = $result->fetch_all_hash; |
|
244 |
is_deeply($rows, [{key1 => 2, key2 => 4}], "$test : bind_filter"); |
|
245 |
|
|
add tests
|
246 |
|
add tests
|
247 |
test 'DBI::Custom::SQL::Template basic tag'; |
cleanup
|
248 |
$dbi->do($DROP_TABLE->{0}); |
add tests
|
249 |
$dbi->do($CREATE_TABLE->{1}); |
250 |
$sth = $dbi->prepare("insert into table1 (key1, key2, key3, key4, key5) values (?, ?, ?, ?, ?);"); |
|
251 |
$sth->execute(1, 2, 3, 4, 5); |
|
252 |
$sth->execute(6, 7, 8, 9, 10); |
|
add tests
|
253 |
|
add tests
|
254 |
$tmpl = "select * from table1 where {= key1} and {<> key2} and {< key3} and {> key4} and {>= key5};"; |
255 |
$query = $dbi->create_query($tmpl); |
|
256 |
$result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}); |
|
cleanup
|
257 |
$rows = $result->fetch_all_hash; |
add tests
|
258 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1"); |
cleanup
|
259 |
|
add tests
|
260 |
$tmpl = "select * from table1 where {= table1.key1} and {<> table1.key2} and {< table1.key3} and {> table1.key4} and {>= table1.key5};"; |
261 |
$query = $dbi->create_query($tmpl); |
|
262 |
$result = $dbi->execute($query, {table1 => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}}); |
|
263 |
$rows = $result->fetch_all_hash; |
|
264 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1 with table"); |
|
265 |
|
|
266 |
$tmpl = "select * from table1 where {= table1.key1} and {<> table1.key2} and {< table1.key3} and {> table1.key4} and {>= table1.key5};"; |
|
267 |
$query = $dbi->create_query($tmpl); |
|
268 |
$result = $dbi->execute($query, {'table1.key1' => 1, 'table1.key2' => 3, 'table1.key3' => 4, 'table1.key4' => 3, 'table1.key5' => 5}); |
|
269 |
$rows = $result->fetch_all_hash; |
|
270 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1 with table dot"); |
|
271 |
|
|
add tests
|
272 |
$tmpl = "select * from table1 where {<= key1} and {like key2};"; |
273 |
$query = $dbi->create_query($tmpl); |
|
274 |
$result = $dbi->execute($query, {key1 => 1, key2 => '%2%'}); |
|
275 |
$rows = $result->fetch_all_hash; |
|
276 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2"); |
|
cleanup
|
277 |
|
add tests
|
278 |
$tmpl = "select * from table1 where {<= table1.key1} and {like table1.key2};"; |
279 |
$query = $dbi->create_query($tmpl); |
|
280 |
$result = $dbi->execute($query, {table1 => {key1 => 1, key2 => '%2%'}}); |
|
281 |
$rows = $result->fetch_all_hash; |
|
282 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table"); |
|
283 |
|
|
284 |
$tmpl = "select * from table1 where {<= table1.key1} and {like table1.key2};"; |
|
285 |
$query = $dbi->create_query($tmpl); |
|
286 |
$result = $dbi->execute($query, {'table1.key1' => 1, 'table1.key2' => '%2%'}); |
|
287 |
$rows = $result->fetch_all_hash; |
|
288 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table dot"); |
|
289 |
|
|
290 |
|
|
add tests
|
291 |
test 'DIB::Custom::SQL::Template in tag'; |
cleanup
|
292 |
$dbi->do($DROP_TABLE->{0}); |
add tests
|
293 |
$dbi->do($CREATE_TABLE->{1}); |
294 |
$sth = $dbi->prepare("insert into table1 (key1, key2, key3, key4, key5) values (?, ?, ?, ?, ?);"); |
|
295 |
$sth->execute(1, 2, 3, 4, 5); |
|
296 |
$sth->execute(6, 7, 8, 9, 10); |
|
297 |
|
|
298 |
$tmpl = "select * from table1 where {in key1 2};"; |
|
299 |
$query = $dbi->create_query($tmpl); |
|
300 |
$result = $dbi->execute($query, {key1 => [9, 1]}); |
|
301 |
$rows = $result->fetch_all_hash; |
|
302 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic"); |
|
303 |
|
|
304 |
$tmpl = "select * from table1 where {in table1.key1 2};"; |
|
305 |
$query = $dbi->create_query($tmpl); |
|
306 |
$result = $dbi->execute($query, {table1 => {key1 => [9, 1]}}); |
|
307 |
$rows = $result->fetch_all_hash; |
|
308 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table"); |
|
add tests
|
309 |
|
add tests
|
310 |
$tmpl = "select * from table1 where {in table1.key1 2};"; |
311 |
$query = $dbi->create_query($tmpl); |
|
312 |
$result = $dbi->execute($query, {'table1.key1' => [9, 1]}); |
|
313 |
$rows = $result->fetch_all_hash; |
|
314 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table dot"); |
|
add tests
|
315 |
|
cleanup
|
316 |
|
add tests
|
317 |
test 'DBI::Custom::SQL::Template insert tag'; |
add tests
|
318 |
$dbi->do("delete from table1"); |
319 |
$insert_tmpl = 'insert into table1 {insert key1 key2 key3 key4 key5}'; |
|
320 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
cleanup
|
321 |
|
add tests
|
322 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
add tests
|
323 |
$rows = $result->fetch_all_hash; |
add tests
|
324 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic"); |
cleanup
|
325 |
|
add tests
|
326 |
$dbi->do("delete from table1"); |
327 |
$dbi->execute($insert_tmpl, {'#insert' => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}); |
|
328 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
329 |
$rows = $result->fetch_all_hash; |
|
add tests
|
330 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert"); |
add tests
|
331 |
|
332 |
$dbi->do("delete from table1"); |
|
333 |
$insert_tmpl = 'insert into table1 {insert table1.key1 table1.key2 table1.key3 table1.key4 table1.key5}'; |
|
334 |
$dbi->execute($insert_tmpl, {table1 => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}); |
|
335 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
336 |
$rows = $result->fetch_all_hash; |
|
add tests
|
337 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table name"); |
338 |
|
|
add tests
|
339 |
$dbi->do("delete from table1"); |
340 |
$insert_tmpl = 'insert into table1 {insert table1.key1 table1.key2 table1.key3 table1.key4 table1.key5}'; |
|
341 |
$dbi->execute($insert_tmpl, {'table1.key1' => 1, 'table1.key2' => 2, 'table1.key3' => 3, 'table1.key4' => 4, 'table1.key5' => 5}); |
|
342 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
343 |
$rows = $result->fetch_all_hash; |
|
344 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table name dot"); |
|
add tests
|
345 |
|
346 |
$dbi->do("delete from table1"); |
|
347 |
$dbi->execute($insert_tmpl, {'#insert' => {table1 => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}}); |
|
348 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
349 |
$rows = $result->fetch_all_hash; |
|
add tests
|
350 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name"); |
add tests
|
351 |
|
add tests
|
352 |
$dbi->do("delete from table1"); |
353 |
$dbi->execute($insert_tmpl, {'#insert' => {'table1.key1' => 1, 'table1.key2' => 2, 'table1.key3' => 3, 'table1.key4' => 4, 'table1.key5' => 5}}); |
|
354 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
355 |
$rows = $result->fetch_all_hash; |
|
356 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name dot"); |
|
357 |
|
|
add tests
|
358 |
|
add tests
|
359 |
test 'DBI::Custom::SQL::Template update tag'; |
add tests
|
360 |
$dbi->do("delete from table1"); |
361 |
$insert_tmpl = "insert into table1 {insert key1 key2 key3 key4 key5}"; |
|
362 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
363 |
$dbi->execute($insert_tmpl, {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
364 |
|
|
365 |
$update_tmpl = 'update table1 {update key1 key2 key3 key4} where {= key5}'; |
|
366 |
$dbi->execute($update_tmpl, {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5}); |
|
367 |
|
|
368 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
369 |
$rows = $result->fetch_all_hash; |
|
370 |
is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5}, |
|
add tests
|
371 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : basic"); |
add tests
|
372 |
|
add tests
|
373 |
$dbi->execute($update_tmpl, {'#update' => {key1 => 2, key2 => 2, key3 => 2, key4 => 2}, key5 => 5}); |
add tests
|
374 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
375 |
$rows = $result->fetch_all_hash; |
|
add tests
|
376 |
is_deeply($rows, [{key1 => 2, key2 => 2, key3 => 2, key4 => 2, key5 => 5}, |
377 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : #update"); |
|
add tests
|
378 |
|
add tests
|
379 |
$update_tmpl = 'update table1 {update table1.key1 table1.key2 table1.key3 table1.key4} where {= table1.key5}'; |
380 |
$dbi->execute($update_tmpl, {table1 => {key1 => 3, key2 => 3, key3 => 3, key4 => 3, key5 => 5}}); |
|
add tests
|
381 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
382 |
$rows = $result->fetch_all_hash; |
|
add tests
|
383 |
is_deeply($rows, [{key1 => 3, key2 => 3, key3 => 3, key4 => 3, key5 => 5}, |
384 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : with table name"); |
|
add tests
|
385 |
|
add tests
|
386 |
$update_tmpl = 'update table1 {update table1.key1 table1.key2 table1.key3 table1.key4} where {= table1.key5}'; |
387 |
$dbi->execute($update_tmpl, {'table1.key1' => 4, 'table1.key2' => 4, 'table1.key3' => 4, 'table1.key4' => 4, 'table1.key5' => 5}); |
|
add tests
|
388 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
389 |
$rows = $result->fetch_all_hash; |
|
add tests
|
390 |
is_deeply($rows, [{key1 => 4, key2 => 4, key3 => 4, key4 => 4, key5 => 5}, |
add tests
|
391 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : with table name dot"); |
cleanup
|
392 |
|
add tests
|
393 |
$dbi->execute($update_tmpl, {'#update' => {table1 => {key1 => 5, key2 => 5, key3 => 5, key4 => 5}}, table1 => {key5 => 5}}); |
394 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
395 |
$rows = $result->fetch_all_hash; |
|
396 |
is_deeply($rows, [{key1 => 5, key2 => 5, key3 => 5, key4 => 5, key5 => 5}, |
|
add tests
|
397 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : update tag #update with table name"); |
cleanup
|
398 |
|
add tests
|
399 |
$dbi->execute($update_tmpl, {'#update' => {'table1.key1' => 6, 'table1.key2' => 6, 'table1.key3' => 6, 'table1.key4' => 6}, 'table1.key5' => 5}); |
400 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
401 |
$rows = $result->fetch_all_hash; |
|
402 |
is_deeply($rows, [{key1 => 6, key2 => 6, key3 => 6, key4 => 6, key5 => 5}, |
|
add tests
|
403 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : update tag #update with table name dot"); |
add tests
|
404 |
|
cleanup
|
405 |
|
406 |
test 'run_tansaction'; |
|
407 |
$dbi->do($DROP_TABLE->{0}); |
|
408 |
$dbi->do($CREATE_TABLE->{0}); |
|
409 |
$dbi->run_tranzaction(sub { |
|
410 |
$insert_tmpl = 'insert into table1 {insert key1 key2}'; |
|
411 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2}); |
|
412 |
$dbi->execute($insert_tmpl, {key1 => 3, key2 => 4}); |
|
413 |
}); |
|
414 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
415 |
$rows = $result->fetch_all_hash; |
|
416 |
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : commit"); |
|
417 |
|
|
418 |
$dbi->do($DROP_TABLE->{0}); |
|
419 |
$dbi->do($CREATE_TABLE->{0}); |
|
420 |
$dbi->dbh->{RaiseError} = 0; |
|
421 |
eval{ |
|
422 |
$dbi->run_tranzaction(sub { |
|
423 |
$insert_tmpl = 'insert into table1 {insert key1 key2}'; |
|
424 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2}); |
|
425 |
die "Fatal Error"; |
|
426 |
$dbi->execute($insert_tmpl, {key1 => 3, key2 => 4}); |
|
427 |
}) |
|
428 |
}; |
|
429 |
like($@, qr/Fatal Error.*Rollback is success/ms, "$test : Rollback success message"); |
|
430 |
ok(!$dbi->dbh->{RaiseError}, "$test : restore RaiseError value"); |
|
431 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
432 |
$rows = $result->fetch_all_hash; |
|
433 |
is_deeply($rows, [], "$test : rollback"); |
|
434 |
|
|
435 |
|
|
add tests
|
436 |
test 'Error case'; |
437 |
$dbi = DBI::Custom->new; |
|
438 |
eval{$dbi->run_tranzaction}; |
|
439 |
like($@, qr/Not yet connect to database/, "$test : Yet Connected"); |
|
440 |
|
|
441 |
$dbi = DBI::Custom->new(data_source => 'dbi:SQLit'); |
|
442 |
eval{$dbi->connect;}; |
|
443 |
ok($@, "$test : connect error"); |
|
444 |
|
|
add tests
|
445 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
446 |
$dbi->connect; |
447 |
$dbi->dbh->{AutoCommit} = 0; |
|
448 |
eval{$dbi->run_tranzaction()}; |
|
449 |
like($@, qr/AutoCommit must be true before tranzaction start/, |
|
450 |
"$test : run_tranzaction auto commit is false"); |
|
451 |
|
|
add tests
|
452 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
453 |
$sql = 'laksjdf'; |
454 |
eval{$dbi->prepare($sql)}; |
|
455 |
like($@, qr/$sql/, "$test : prepare fail"); |
|
456 |
|
|
add tests
|
457 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
458 |
$sql = 'laksjdf'; |
459 |
eval{$dbi->do($sql, qw/1 2 3/)}; |
|
460 |
like($@, qr/$sql/, "$test : do fail"); |
|
461 |
|
|
add tests
|
462 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
463 |
eval{$dbi->create_query("{p }")}; |
464 |
ok($@, "$test : create_query invalid SQL template"); |
|
465 |
|
|
add tests
|
466 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
add tests
|
467 |
$dbi->do($CREATE_TABLE->{0}); |
468 |
$query = $dbi->create_query("select * from table1 where {= key1}"); |
|
469 |
eval{$dbi->execute($query, {key2 => 1})}; |
|
470 |
like($@, qr/Corresponding key is not found in your parameters/, |
|
471 |
"$test : execute corresponding key not found"); |
|
472 |
|
|
add tests
|
473 |
|
474 |
test 'insert'; |
|
475 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
476 |
$dbi->do($CREATE_TABLE->{0}); |
|
477 |
$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
478 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
|
479 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
480 |
$rows = $result->fetch_all_hash; |
|
481 |
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : basic"); |
|
482 |
|
|
483 |
$dbi->do('delete from table1'); |
|
484 |
$dbi->insert('table1', {key1 => 1, key2 => 2}, sub { |
|
485 |
my $query = shift; |
|
486 |
$query->bind_filter(sub { |
|
487 |
my ($key, $value) = @_; |
|
488 |
if ($key eq 'key1') { |
|
489 |
return $value * 3; |
|
490 |
} |
|
491 |
return $value; |
|
492 |
}); |
|
493 |
}); |
|
494 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
495 |
$rows = $result->fetch_all_hash; |
|
496 |
is_deeply($rows, [{key1 => 3, key2 => 2}], "$test : edit_query_callback"); |
|
497 |
|
|
add tests
|
498 |
|
499 |
test 'insert error'; |
|
add tests
|
500 |
eval{$dbi->insert('table1')}; |
add tests
|
501 |
like($@, qr/Key-value pairs for insert must be specified to 'insert' second argument/, "$test : insert key-value not specifed"); |
add tests
|
502 |
|
503 |
eval{$dbi->insert('table1', {key1 => 1, key2 => 2}, 'aaa')}; |
|
504 |
like($@, qr/Query edit callback must be code reference/, "$test : query edit callback not code ref"); |
|
add tests
|
505 |
|
506 |
|
|
507 |
test 'update'; |
|
508 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
509 |
$dbi->do($CREATE_TABLE->{1}); |
|
510 |
$dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
511 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
512 |
$dbi->update('table1', {key2 => 11}, {key1 => 1}); |
|
513 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
514 |
$rows = $result->fetch_all_hash; |
|
515 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5}, |
|
516 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
517 |
"$test : basic"); |
|
518 |
|
|
519 |
$dbi->do("delete from table1"); |
|
520 |
$dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
521 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
add tests
|
522 |
$dbi->update('table1', {key2 => 12}, {key2 => 2, key3 => 3}); |
add tests
|
523 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
524 |
$rows = $result->fetch_all_hash; |
|
525 |
is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5}, |
|
526 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
527 |
"$test : update key same as search key"); |
|
528 |
|
|
529 |
$dbi->do("delete from table1"); |
|
530 |
$dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
531 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
532 |
$dbi->update('table1', {key2 => 11}, {key1 => 1}, sub { |
|
533 |
my $query = shift; |
|
534 |
$query->bind_filter(sub { |
|
535 |
my ($key, $value) = @_; |
|
536 |
if ($key eq 'key2') { |
|
537 |
return $value * 2; |
|
538 |
} |
|
539 |
return $value; |
|
540 |
}); |
|
541 |
}); |
|
542 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
543 |
$rows = $result->fetch_all_hash; |
|
544 |
is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5}, |
|
545 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
546 |
"$test : query edit callback"); |
|
547 |
|
|
548 |
|
|
549 |
test 'update error'; |
|
550 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
551 |
$dbi->do($CREATE_TABLE->{1}); |
|
552 |
eval{$dbi->update('table1')}; |
|
553 |
like($@, qr/Key-value pairs for update must be specified to 'update' second argument/, |
|
554 |
"$test : update key-value pairs not specified"); |
|
555 |
|
|
556 |
eval{$dbi->update('table1', {key2 => 1})}; |
|
557 |
like($@, qr/Key-value pairs for where clause must be specified to 'update' third argument/, |
|
558 |
"$test : where key-value pairs not specified"); |
|
559 |
|
|
560 |
eval{$dbi->update('table1', {key2 => 1}, {key2 => 3}, 'aaa')}; |
|
561 |
like($@, qr/Query edit callback must be code reference/, |
|
562 |
"$test : query edit callback not code reference"); |
|
563 |
|
|
564 |
|
|
565 |
test 'update_all'; |
|
566 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
567 |
$dbi->do($CREATE_TABLE->{1}); |
|
568 |
$dbi->insert('table1', {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
569 |
$dbi->insert('table1', {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
570 |
$dbi->update_all('table1', {key2 => 10}, sub { |
|
571 |
my $query = shift; |
|
572 |
$query->bind_filter(sub { |
|
573 |
my ($key, $value) = @_; |
|
574 |
return $value * 2; |
|
575 |
}) |
|
576 |
}); |
|
577 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
578 |
$rows = $result->fetch_all_hash; |
|
579 |
is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5}, |
|
580 |
{key1 => 6, key2 => 20, key3 => 8, key4 => 9, key5 => 10}], |
|
581 |
"$test : query edit callback"); |
|
582 |
|
|
583 |
|
|
584 |
test 'delete'; |
|
585 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
586 |
$dbi->do($CREATE_TABLE->{0}); |
|
587 |
$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
588 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
|
589 |
$dbi->delete('table1', {key1 => 1}); |
|
590 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
591 |
$rows = $result->fetch_all_hash; |
|
592 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : basic"); |
|
593 |
|
|
594 |
$dbi->do("delete from table1;"); |
|
595 |
$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
596 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
|
597 |
$dbi->delete('table1', {key2 => 1}, sub { |
|
598 |
my $query = shift; |
|
599 |
$query->bind_filter(sub { |
|
600 |
my ($key, $value) = @_; |
|
601 |
return $value * 2; |
|
602 |
}); |
|
603 |
}); |
|
604 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
605 |
$rows = $result->fetch_all_hash; |
|
606 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : query edit callback"); |
|
607 |
|
|
add tests
|
608 |
$dbi->delete_all('table1'); |
609 |
$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
610 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
|
611 |
$dbi->delete('table1', {key1 => 1, key2 => 2}); |
|
612 |
$rows = $dbi->select('table1')->fetch_all_hash; |
|
613 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : delete multi key"); |
|
614 |
|
|
615 |
|
|
add tests
|
616 |
test 'delete error'; |
617 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
618 |
$dbi->do($CREATE_TABLE->{0}); |
|
619 |
eval{$dbi->delete('table1')}; |
|
620 |
like($@, qr/Key-value pairs for where clause must be specified to 'delete' second argument/, |
|
621 |
"$test : where key-value pairs not specified"); |
|
622 |
|
|
623 |
eval{$dbi->delete('table1', {key1 => 1}, 'aaa')}; |
|
624 |
like($@, qr/Query edit callback must be code reference/, |
|
625 |
"$test : query edit callback not code ref"); |
|
626 |
|
|
627 |
|
|
628 |
test 'delete_all'; |
|
629 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
630 |
$dbi->do($CREATE_TABLE->{0}); |
|
631 |
$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
632 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
|
633 |
$dbi->delete_all('table1'); |
|
634 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
635 |
$rows = $result->fetch_all_hash; |
|
636 |
is_deeply($rows, [], "$test : basic"); |
|
637 |
|
|
638 |
|
|
add select
|
639 |
test 'select'; |
640 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
641 |
$dbi->do($CREATE_TABLE->{0}); |
|
642 |
$dbi->insert('table1', {key1 => 1, key2 => 2}); |
|
643 |
$dbi->insert('table1', {key1 => 3, key2 => 4}); |
|
add tests
|
644 |
$rows = $dbi->select('table1')->fetch_all_hash; |
add select
|
645 |
is_deeply($rows, [{key1 => 1, key2 => 2}, |
646 |
{key1 => 3, key2 => 4}], "$test : table"); |
|
647 |
|
|
add tests
|
648 |
$rows = $dbi->select('table1', ['key1'])->fetch_all_hash; |
649 |
is_deeply($rows, [{key1 => 1}, {key1 => 3}], "$test : table and columns and where key"); |
|
650 |
|
|
651 |
$rows = $dbi->select('table1', {key1 => 1})->fetch_all_hash; |
|
652 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : table and columns and where key"); |
|
653 |
|
|
654 |
$rows = $dbi->select('table1', ['key1'], {key1 => 3})->fetch_all_hash; |
|
655 |
is_deeply($rows, [{key1 => 3}], "$test : table and columns and where key"); |
|
add tests
|
656 |
|
657 |
$rows = $dbi->select('table1', "order by key1 desc limit 1")->fetch_all_hash; |
|
658 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "$test : append statement"); |
|
659 |
|
|
660 |
$rows = $dbi->select('table1', {key1 => 2}, sub { |
|
661 |
my $query = shift; |
|
662 |
$query->bind_filter(sub { |
|
663 |
my ($key, $value) = @_; |
|
664 |
if ($key eq 'key1') { |
|
665 |
return $value - 1; |
|
666 |
} |
|
667 |
return $value; |
|
668 |
}); |
|
669 |
})->fetch_all_hash; |
|
670 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : query edit call back"); |
|
671 |
|
|
672 |
$dbi->do($CREATE_TABLE->{2}); |
|
673 |
$dbi->insert('table2', {key1 => 1, key3 => 5}); |
|
674 |
$rows = $dbi->select([qw/table1 table2/], |
|
675 |
['table1.key1 as table1_key1', 'table2.key1 as table2_key1', 'key2', 'key3'], |
|
676 |
{'table1.key2' => 2}, |
|
677 |
"where table1.key1 = table2.key1")->fetch_all_hash; |
|
add cahce tests
|
678 |
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "$test : join"); |
679 |
|
|
680 |
test 'Cache'; |
|
681 |
$dbi = DBI::Custom->new($NEW_ARGS->{0}); |
|
682 |
DBI::Custom->query_cache_max(2); |
|
683 |
$dbi->do($CREATE_TABLE->{0}); |
|
684 |
DBI::Custom->delete_class_attr('_query_caches'); |
|
685 |
DBI::Custom->delete_class_attr('_query_cache_keys'); |
|
686 |
$tmpls[0] = "insert into table1 {insert key1 key2}"; |
|
687 |
$queries[0] = $dbi->create_query($tmpls[0]); |
|
688 |
is(DBI::Custom->_query_caches->{$tmpls[0]}{sql}, $queries[0]->sql, "$test : sql first"); |
|
689 |
is(DBI::Custom->_query_caches->{$tmpls[0]}{key_infos}, $queries[0]->key_infos, "$test : key_infos first"); |
|
690 |
is_deeply(DBI::Custom->_query_cache_keys, [@tmpls], "$test : cache key first"); |
|
691 |
|
|
692 |
$tmpls[1] = "select * from table1"; |
|
693 |
$queries[1] = $dbi->create_query($tmpls[1]); |
|
694 |
is(DBI::Custom->_query_caches->{$tmpls[0]}{sql}, $queries[0]->sql, "$test : sql first"); |
|
695 |
is(DBI::Custom->_query_caches->{$tmpls[0]}{key_infos}, $queries[0]->key_infos, "$test : key_infos first"); |
|
696 |
is(DBI::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql second"); |
|
697 |
is(DBI::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos second"); |
|
698 |
is_deeply(DBI::Custom->_query_cache_keys, [@tmpls], "$test : cache key second"); |
|
699 |
|
|
700 |
$tmpls[2] = "select key1, key2 from table1"; |
|
701 |
$queries[2] = $dbi->create_query($tmpls[2]); |
|
702 |
ok(!exists DBI::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key"); |
|
703 |
is(DBI::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key"); |
|
704 |
is(DBI::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key"); |
|
705 |
is(DBI::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key"); |
|
706 |
is(DBI::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key"); |
|
707 |
is_deeply(DBI::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
|
708 |
|
|
709 |
$queries[1] = $dbi->create_query($tmpls[1]); |
|
710 |
ok(!exists DBI::Custom->_query_caches->{$tmpls[0]}, "$test : cache overflow deleted key"); |
|
711 |
is(DBI::Custom->_query_caches->{$tmpls[1]}{sql}, $queries[1]->sql, "$test : sql cache overflow deleted key"); |
|
712 |
is(DBI::Custom->_query_caches->{$tmpls[1]}{key_infos}, $queries[1]->key_infos, "$test : key_infos cache overflow deleted key"); |
|
713 |
is(DBI::Custom->_query_caches->{$tmpls[2]}{sql}, $queries[2]->sql, "$test : sql cache overflow deleted key"); |
|
714 |
is(DBI::Custom->_query_caches->{$tmpls[2]}{key_infos}, $queries[2]->key_infos, "$test : key_infos cache overflow deleted key"); |
|
715 |
is_deeply(DBI::Custom->_query_cache_keys, [@tmpls[1, 2]], "$test : cache key third"); |
|
716 |
|