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 |
|
cleanup#
|
21 |
# Varialbes for test |
add prepare
|
22 |
our $CREATE_TABLE = { |
add tests
|
23 |
0 => 'create table table1 (key1 char(255), key2 char(255));', |
24 |
1 => 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));' |
|
add prepare
|
25 |
}; |
26 |
|
|
add tests
|
27 |
our $SELECT_TMPL = { |
add tests
|
28 |
0 => 'select * from table1;' |
add tests
|
29 |
}; |
30 |
|
|
cleanup
|
31 |
my $dbi; |
32 |
my $sth; |
|
33 |
my $tmpl; |
|
cleanup#
|
34 |
my $select_tmpl; |
35 |
my $insert_tmpl; |
|
add tests
|
36 |
my $update_tmpl; |
cleanup
|
37 |
my $params; |
38 |
my $sql; |
|
39 |
my $result; |
|
40 |
my @rows; |
|
41 |
my $rows; |
|
add tests
|
42 |
my $query; |
cleanup#
|
43 |
my $select_query; |
44 |
my $insert_query; |
|
add tests
|
45 |
my $update_query; |
add prepare
|
46 |
my $ret_val; |
cleanup#
|
47 |
|
cleanup
|
48 |
|
49 |
|
|
add tests
|
50 |
test 'Disconnect'; |
51 |
$dbi = DBI::Custom->new(data_source => 'dbi:SQLite:dbname=:memory:'); |
|
52 |
$dbi->connect; |
|
53 |
$dbi->disconnect; |
|
54 |
ok(!$dbi->dbh, $test); |
|
add tests
|
55 |
|
cleanup
|
56 |
# Prepare table |
57 |
$dbi = DBI::Custom->new(data_source => 'dbi:SQLite:dbname=:memory:'); |
|
58 |
$dbi->connect; |
|
add prepare
|
59 |
$dbi->do($CREATE_TABLE->{0}); |
60 |
$sth = $dbi->prepare("insert into table1 (key1, key2) values (?, ?);"); |
|
cleanup
|
61 |
$sth->execute(1, 2); |
62 |
$sth->execute(3, 4); |
|
add test
|
63 |
|
add test module
|
64 |
|
add tests
|
65 |
test 'DBI::Custom::Result test'; |
66 |
$tmpl = "select key1, key2 from table1"; |
|
67 |
$query = $dbi->create_query($tmpl); |
|
68 |
$result = $dbi->execute($query); |
|
cleanup
|
69 |
|
70 |
@rows = (); |
|
71 |
while (my $row = $result->fetch) { |
|
72 |
push @rows, [@$row]; |
|
add test module
|
73 |
} |
add tests
|
74 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch scalar context"); |
cleanup
|
75 |
|
add tests
|
76 |
$result = $dbi->execute($query); |
cleanup
|
77 |
@rows = (); |
78 |
while (my @row = $result->fetch) { |
|
79 |
push @rows, [@row]; |
|
add test module
|
80 |
} |
add tests
|
81 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch list context"); |
add test module
|
82 |
|
add tests
|
83 |
$result = $dbi->execute($query); |
cleanup
|
84 |
@rows = (); |
85 |
while (my $row = $result->fetch_hash) { |
|
86 |
push @rows, {%$row}; |
|
add test module
|
87 |
} |
add tests
|
88 |
is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : fetch_hash scalar context"); |
cleanup
|
89 |
|
add tests
|
90 |
$result = $dbi->execute($query); |
cleanup
|
91 |
@rows = (); |
92 |
while (my %row = $result->fetch_hash) { |
|
93 |
push @rows, {%row}; |
|
add test module
|
94 |
} |
add tests
|
95 |
is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "$test : fetch hash list context"); |
add test module
|
96 |
|
add tests
|
97 |
$result = $dbi->execute($query); |
cleanup
|
98 |
$rows = $result->fetch_all; |
add tests
|
99 |
is_deeply($rows, [[1, 2], [3, 4]], "$test : fetch_all scalar context"); |
cleanup
|
100 |
|
add tests
|
101 |
$result = $dbi->execute($query); |
cleanup
|
102 |
@rows = $result->fetch_all; |
add tests
|
103 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch_all list context"); |
cleanup
|
104 |
|
add tests
|
105 |
$result = $dbi->execute($query); |
cleanup
|
106 |
@rows = $result->fetch_all_hash; |
add tests
|
107 |
is_deeply($rows, [[1, 2], [3, 4]], "$test : fetch_all_hash scalar context"); |
cleanup
|
108 |
|
add tests
|
109 |
$result = $dbi->execute($query); |
cleanup
|
110 |
@rows = $result->fetch_all; |
add tests
|
111 |
is_deeply(\@rows, [[1, 2], [3, 4]], "$test : fetch_all_hash list context"); |
cleanup
|
112 |
|
add tests
|
113 |
|
add tests
|
114 |
test 'Insert query return value'; |
115 |
$dbi->reconnect; |
|
116 |
$dbi->do($CREATE_TABLE->{0}); |
|
117 |
$tmpl = "insert into table1 {insert key1 key2}"; |
|
118 |
$query = $dbi->create_query($tmpl); |
|
119 |
$ret_val = $dbi->execute($query, {key1 => 1, key2 => 2}); |
|
120 |
ok($ret_val, $test); |
|
121 |
|
|
add tests
|
122 |
|
123 |
test 'Direct execute'; |
|
124 |
$dbi->reconnect; |
|
125 |
$dbi->do($CREATE_TABLE->{0}); |
|
126 |
$insert_tmpl = "insert into table1 {insert key1 key2}"; |
|
127 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2}, sub { |
|
128 |
my $query = shift; |
|
129 |
$query->bind_filter(sub { |
|
130 |
my ($key, $value) = @_; |
|
131 |
if ($key eq 'key2') { |
|
132 |
return $value + 1; |
|
133 |
} |
|
134 |
return $value; |
|
135 |
}); |
|
136 |
}); |
|
137 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
138 |
$rows = $result->fetch_all_hash; |
|
139 |
is_deeply($rows, [{key1 => 1, key2 => 3}], $test); |
|
140 |
|
|
141 |
|
|
add tests
|
142 |
test 'Filter basic'; |
cleanup#
|
143 |
$dbi->reconnect; |
add tests
|
144 |
$dbi->do($CREATE_TABLE->{0}); |
cleanup#
|
145 |
|
add tests
|
146 |
$insert_tmpl = "insert into table1 {insert key1 key2};"; |
add prepare
|
147 |
$insert_query = $dbi->create_query($insert_tmpl); |
148 |
$insert_query->bind_filter(sub { |
|
add tests
|
149 |
my ($key, $value, $table, $column) = @_; |
150 |
if ($key eq 'key1' && $table eq '' && $column eq 'key1') { |
|
add prepare
|
151 |
return $value * 2; |
cleanup#
|
152 |
} |
153 |
return $value; |
|
154 |
}); |
|
add tests
|
155 |
$dbi->execute($insert_query, {key1 => 1, key2 => 2}); |
156 |
$select_query = $dbi->create_query($SELECT_TMPL->{0}); |
|
add prepare
|
157 |
$select_query->fetch_filter(sub { |
add tests
|
158 |
my ($key, $value, $type, $sth, $i) = @_; |
159 |
if ($key eq 'key2' && $type =~ /char/ && $sth->can('execute') && $i == 1) { |
|
add prepare
|
160 |
return $value * 3; |
161 |
} |
|
162 |
return $value; |
|
163 |
}); |
|
164 |
$result = $dbi->execute($select_query); |
|
165 |
$rows = $result->fetch_all_hash; |
|
add tests
|
166 |
is_deeply($rows, [{key1 => 2, key2 => 6}], "$test : bind_filter fetch_filter"); |
cleanup#
|
167 |
|
add tests
|
168 |
$dbi->do("delete from table1;"); |
169 |
$insert_query->no_bind_filters('key1'); |
|
170 |
$select_query->no_fetch_filters('key2'); |
|
171 |
$dbi->execute($insert_query, {key1 => 1, key2 => 2}); |
|
172 |
$result = $dbi->execute($select_query); |
|
173 |
$rows = $result->fetch_all_hash; |
|
add tests
|
174 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "$test : no_fetch_filters no_bind_filters"); |
add tests
|
175 |
|
add tests
|
176 |
$dbi->reconnect; |
177 |
$dbi->do($CREATE_TABLE->{0}); |
|
178 |
$insert_tmpl = "insert into table1 {insert table1.key1 table1.key2}"; |
|
179 |
$insert_query = $dbi->create_query($insert_tmpl); |
|
180 |
$insert_query->bind_filter(sub { |
|
181 |
my ($key, $value, $table, $column) = @_; |
|
182 |
if ($key eq 'table1.key1' && $table eq 'table1' && $column eq 'key1') { |
|
183 |
return $value * 3; |
|
184 |
} |
|
185 |
return $value; |
|
186 |
}); |
|
187 |
$dbi->execute($insert_query, {table1 => {key1 => 1, key2 => 2}}); |
|
188 |
$select_query = $dbi->create_query($SELECT_TMPL->{0}); |
|
189 |
$result = $dbi->execute($select_query); |
|
190 |
$rows = $result->fetch_all_hash; |
|
191 |
is_deeply($rows, [{key1 => 3, key2 => 2}], "$test : insert with table name"); |
|
192 |
|
|
add tests
|
193 |
test 'Filter in'; |
194 |
$insert_tmpl = "insert into table1 {insert key1 key2};"; |
|
195 |
$insert_query = $dbi->create_query($insert_tmpl); |
|
196 |
$dbi->execute($insert_query, {key1 => 2, key2 => 4}); |
|
197 |
$select_tmpl = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}"; |
|
198 |
$select_query = $dbi->create_query($select_tmpl); |
|
199 |
$select_query->bind_filter(sub { |
|
200 |
my ($key, $value, $table, $column) = @_; |
|
201 |
if ($key eq 'table1.key1' && $table eq 'table1' && $column eq 'key1' || $key eq 'table1.key2') { |
|
202 |
return $value * 2; |
|
203 |
} |
|
204 |
return $value; |
|
205 |
}); |
|
206 |
$result = $dbi->execute($select_query, {table1 => {key1 => [1,5], key2 => [2,5]}}); |
|
207 |
$rows = $result->fetch_all_hash; |
|
208 |
is_deeply($rows, [{key1 => 2, key2 => 4}], "$test : bind_filter"); |
|
209 |
|
|
add tests
|
210 |
|
add tests
|
211 |
test 'DBI::Custom::SQL::Template basic tag'; |
add tests
|
212 |
$dbi->reconnect; |
213 |
$dbi->do($CREATE_TABLE->{1}); |
|
214 |
$sth = $dbi->prepare("insert into table1 (key1, key2, key3, key4, key5) values (?, ?, ?, ?, ?);"); |
|
215 |
$sth->execute(1, 2, 3, 4, 5); |
|
216 |
$sth->execute(6, 7, 8, 9, 10); |
|
add tests
|
217 |
|
add tests
|
218 |
$tmpl = "select * from table1 where {= key1} and {<> key2} and {< key3} and {> key4} and {>= key5};"; |
219 |
$query = $dbi->create_query($tmpl); |
|
220 |
$result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}); |
|
cleanup
|
221 |
$rows = $result->fetch_all_hash; |
add tests
|
222 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1"); |
cleanup
|
223 |
|
add tests
|
224 |
$tmpl = "select * from table1 where {= table1.key1} and {<> table1.key2} and {< table1.key3} and {> table1.key4} and {>= table1.key5};"; |
225 |
$query = $dbi->create_query($tmpl); |
|
226 |
$result = $dbi->execute($query, {table1 => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}}); |
|
227 |
$rows = $result->fetch_all_hash; |
|
228 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1 with table"); |
|
229 |
|
|
230 |
$tmpl = "select * from table1 where {= table1.key1} and {<> table1.key2} and {< table1.key3} and {> table1.key4} and {>= table1.key5};"; |
|
231 |
$query = $dbi->create_query($tmpl); |
|
232 |
$result = $dbi->execute($query, {'table1.key1' => 1, 'table1.key2' => 3, 'table1.key3' => 4, 'table1.key4' => 3, 'table1.key5' => 5}); |
|
233 |
$rows = $result->fetch_all_hash; |
|
234 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag1 with table dot"); |
|
235 |
|
|
add tests
|
236 |
$tmpl = "select * from table1 where {<= key1} and {like key2};"; |
237 |
$query = $dbi->create_query($tmpl); |
|
238 |
$result = $dbi->execute($query, {key1 => 1, key2 => '%2%'}); |
|
239 |
$rows = $result->fetch_all_hash; |
|
240 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2"); |
|
cleanup
|
241 |
|
add tests
|
242 |
$tmpl = "select * from table1 where {<= table1.key1} and {like table1.key2};"; |
243 |
$query = $dbi->create_query($tmpl); |
|
244 |
$result = $dbi->execute($query, {table1 => {key1 => 1, key2 => '%2%'}}); |
|
245 |
$rows = $result->fetch_all_hash; |
|
246 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table"); |
|
247 |
|
|
248 |
$tmpl = "select * from table1 where {<= table1.key1} and {like table1.key2};"; |
|
249 |
$query = $dbi->create_query($tmpl); |
|
250 |
$result = $dbi->execute($query, {'table1.key1' => 1, 'table1.key2' => '%2%'}); |
|
251 |
$rows = $result->fetch_all_hash; |
|
252 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic tag2 with table dot"); |
|
253 |
|
|
254 |
|
|
add tests
|
255 |
test 'DIB::Custom::SQL::Template in tag'; |
256 |
$dbi->reconnect; |
|
257 |
$dbi->do($CREATE_TABLE->{1}); |
|
258 |
$sth = $dbi->prepare("insert into table1 (key1, key2, key3, key4, key5) values (?, ?, ?, ?, ?);"); |
|
259 |
$sth->execute(1, 2, 3, 4, 5); |
|
260 |
$sth->execute(6, 7, 8, 9, 10); |
|
261 |
|
|
262 |
$tmpl = "select * from table1 where {in key1 2};"; |
|
263 |
$query = $dbi->create_query($tmpl); |
|
264 |
$result = $dbi->execute($query, {key1 => [9, 1]}); |
|
265 |
$rows = $result->fetch_all_hash; |
|
266 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic"); |
|
267 |
|
|
268 |
$tmpl = "select * from table1 where {in table1.key1 2};"; |
|
269 |
$query = $dbi->create_query($tmpl); |
|
270 |
$result = $dbi->execute($query, {table1 => {key1 => [9, 1]}}); |
|
271 |
$rows = $result->fetch_all_hash; |
|
272 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table"); |
|
add tests
|
273 |
|
add tests
|
274 |
$tmpl = "select * from table1 where {in table1.key1 2};"; |
275 |
$query = $dbi->create_query($tmpl); |
|
276 |
$result = $dbi->execute($query, {'table1.key1' => [9, 1]}); |
|
277 |
$rows = $result->fetch_all_hash; |
|
278 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table dot"); |
|
add tests
|
279 |
|
cleanup
|
280 |
|
add tests
|
281 |
test 'DBI::Custom::SQL::Template insert tag'; |
add tests
|
282 |
$dbi->do("delete from table1"); |
283 |
$insert_tmpl = 'insert into table1 {insert key1 key2 key3 key4 key5}'; |
|
284 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
cleanup
|
285 |
|
add tests
|
286 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
add tests
|
287 |
$rows = $result->fetch_all_hash; |
add tests
|
288 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : basic"); |
cleanup
|
289 |
|
add tests
|
290 |
$dbi->do("delete from table1"); |
291 |
$dbi->execute($insert_tmpl, {'#insert' => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}); |
|
292 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
293 |
$rows = $result->fetch_all_hash; |
|
add tests
|
294 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert"); |
add tests
|
295 |
|
296 |
$dbi->do("delete from table1"); |
|
297 |
$insert_tmpl = 'insert into table1 {insert table1.key1 table1.key2 table1.key3 table1.key4 table1.key5}'; |
|
298 |
$dbi->execute($insert_tmpl, {table1 => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}); |
|
299 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
300 |
$rows = $result->fetch_all_hash; |
|
add tests
|
301 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table name"); |
302 |
|
|
add tests
|
303 |
$dbi->do("delete from table1"); |
304 |
$insert_tmpl = 'insert into table1 {insert table1.key1 table1.key2 table1.key3 table1.key4 table1.key5}'; |
|
305 |
$dbi->execute($insert_tmpl, {'table1.key1' => 1, 'table1.key2' => 2, 'table1.key3' => 3, 'table1.key4' => 4, 'table1.key5' => 5}); |
|
306 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
307 |
$rows = $result->fetch_all_hash; |
|
308 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : with table name dot"); |
|
add tests
|
309 |
|
310 |
$dbi->do("delete from table1"); |
|
311 |
$dbi->execute($insert_tmpl, {'#insert' => {table1 => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}}}); |
|
312 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
313 |
$rows = $result->fetch_all_hash; |
|
add tests
|
314 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name"); |
add tests
|
315 |
|
add tests
|
316 |
$dbi->do("delete from table1"); |
317 |
$dbi->execute($insert_tmpl, {'#insert' => {'table1.key1' => 1, 'table1.key2' => 2, 'table1.key3' => 3, 'table1.key4' => 4, 'table1.key5' => 5}}); |
|
318 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
319 |
$rows = $result->fetch_all_hash; |
|
320 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "$test : #insert with table name dot"); |
|
321 |
|
|
add tests
|
322 |
|
add tests
|
323 |
test 'DBI::Custom::SQL::Template update tag'; |
add tests
|
324 |
$dbi->do("delete from table1"); |
325 |
$insert_tmpl = "insert into table1 {insert key1 key2 key3 key4 key5}"; |
|
326 |
$dbi->execute($insert_tmpl, {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
327 |
$dbi->execute($insert_tmpl, {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
328 |
|
|
329 |
$update_tmpl = 'update table1 {update key1 key2 key3 key4} where {= key5}'; |
|
330 |
$dbi->execute($update_tmpl, {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5}); |
|
331 |
|
|
332 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
333 |
$rows = $result->fetch_all_hash; |
|
334 |
is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5}, |
|
add tests
|
335 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : basic"); |
add tests
|
336 |
|
add tests
|
337 |
$dbi->execute($update_tmpl, {'#update' => {key1 => 2, key2 => 2, key3 => 2, key4 => 2}, key5 => 5}); |
add tests
|
338 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
339 |
$rows = $result->fetch_all_hash; |
|
add tests
|
340 |
is_deeply($rows, [{key1 => 2, key2 => 2, key3 => 2, key4 => 2, key5 => 5}, |
341 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : #update"); |
|
add tests
|
342 |
|
add tests
|
343 |
$update_tmpl = 'update table1 {update table1.key1 table1.key2 table1.key3 table1.key4} where {= table1.key5}'; |
344 |
$dbi->execute($update_tmpl, {table1 => {key1 => 3, key2 => 3, key3 => 3, key4 => 3, key5 => 5}}); |
|
add tests
|
345 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
346 |
$rows = $result->fetch_all_hash; |
|
add tests
|
347 |
is_deeply($rows, [{key1 => 3, key2 => 3, key3 => 3, key4 => 3, key5 => 5}, |
348 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : with table name"); |
|
add tests
|
349 |
|
add tests
|
350 |
$update_tmpl = 'update table1 {update table1.key1 table1.key2 table1.key3 table1.key4} where {= table1.key5}'; |
351 |
$dbi->execute($update_tmpl, {'table1.key1' => 4, 'table1.key2' => 4, 'table1.key3' => 4, 'table1.key4' => 4, 'table1.key5' => 5}); |
|
add tests
|
352 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
353 |
$rows = $result->fetch_all_hash; |
|
add tests
|
354 |
is_deeply($rows, [{key1 => 4, key2 => 4, key3 => 4, key4 => 4, key5 => 5}, |
add tests
|
355 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : with table name dot"); |
cleanup
|
356 |
|
add tests
|
357 |
$dbi->execute($update_tmpl, {'#update' => {table1 => {key1 => 5, key2 => 5, key3 => 5, key4 => 5}}, table1 => {key5 => 5}}); |
358 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
359 |
$rows = $result->fetch_all_hash; |
|
360 |
is_deeply($rows, [{key1 => 5, key2 => 5, key3 => 5, key4 => 5, key5 => 5}, |
|
add tests
|
361 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : update tag #update with table name"); |
cleanup
|
362 |
|
add tests
|
363 |
$dbi->execute($update_tmpl, {'#update' => {'table1.key1' => 6, 'table1.key2' => 6, 'table1.key3' => 6, 'table1.key4' => 6}, 'table1.key5' => 5}); |
364 |
$result = $dbi->execute($SELECT_TMPL->{0}); |
|
365 |
$rows = $result->fetch_all_hash; |
|
366 |
is_deeply($rows, [{key1 => 6, key2 => 6, key3 => 6, key4 => 6, key5 => 5}, |
|
add tests
|
367 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "$test : update tag #update with table name dot"); |
add tests
|
368 |
|