removed register_format()
|
1 |
use Test::More; |
2 |
use strict; |
|
3 |
use warnings; |
|
4 | ||
5 |
use utf8; |
|
6 |
use Encode qw/encode_utf8 decode_utf8/; |
|
add experimental DBIx::Custo...
|
7 |
use Data::Dumper; |
removed register_format()
|
8 | |
separate DBIx::Custom type_r...
|
9 |
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/}; |
removed EXPERIMETNAL select(...
|
10 | |
removed register_format()
|
11 |
BEGIN { |
12 |
eval { require DBD::SQLite; 1 } |
|
13 |
or plan skip_all => 'DBD::SQLite required'; |
|
14 |
eval { DBD::SQLite->VERSION >= 1.25 } |
|
15 |
or plan skip_all => 'DBD::SQLite >= 1.25 required'; |
|
16 | ||
17 |
plan 'no_plan'; |
|
18 |
use_ok('DBIx::Custom'); |
|
19 |
} |
|
20 | ||
removed experimental base_ta...
|
21 |
use FindBin; |
22 |
use lib "$FindBin::Bin/dbix-custom-core-sqlite"; |
|
23 | ||
removed register_format()
|
24 |
# Function for test name |
table object call dbi object...
|
25 |
sub test { print "# $_[0]\n" } |
removed register_format()
|
26 | |
27 |
# Constant varialbes for test |
|
28 |
my $CREATE_TABLE = { |
|
29 |
0 => 'create table table1 (key1 char(255), key2 char(255));', |
|
30 |
1 => 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));', |
|
added experimental iterate_a...
|
31 |
2 => 'create table table2 (key1 char(255), key3 char(255));', |
- added experimental DBIx::C...
|
32 |
3 => 'create table table1 (key1 Date, key2 datetime);', |
33 |
4 => 'create table table3 (key3 int, key4 int);' |
|
removed register_format()
|
34 |
}; |
35 | ||
add tests
|
36 |
my $SELECT_SOURCES = { |
removed register_format()
|
37 |
0 => 'select * from table1;' |
38 |
}; |
|
39 | ||
40 |
my $DROP_TABLE = { |
|
41 |
0 => 'drop table table1' |
|
42 |
}; |
|
43 | ||
44 |
my $NEW_ARGS = { |
|
data_source is DEPRECATED! I...
|
45 |
0 => {dsn => 'dbi:SQLite:dbname=:memory:'} |
removed register_format()
|
46 |
}; |
47 | ||
48 |
# Variables |
|
49 |
my $dbi; |
|
50 |
my $sth; |
|
renamed build_query to creat...
|
51 |
my $source; |
52 |
my @sources; |
|
add tests
|
53 |
my $select_SOURCE; |
54 |
my $insert_SOURCE; |
|
55 |
my $update_SOURCE; |
|
added experimental update_pa...
|
56 |
my $param; |
removed register_format()
|
57 |
my $params; |
58 |
my $sql; |
|
59 |
my $result; |
|
60 |
my $row; |
|
61 |
my @rows; |
|
62 |
my $rows; |
|
63 |
my $query; |
|
64 |
my @queries; |
|
65 |
my $select_query; |
|
66 |
my $insert_query; |
|
67 |
my $update_query; |
|
68 |
my $ret_val; |
|
added experimental iterate_a...
|
69 |
my $infos; |
add feture. all model class ...
|
70 |
my $model; |
create_model() return model
|
71 |
my $model2; |
added experimental DBIx::Cus...
|
72 |
my $where; |
added experimental update_pa...
|
73 |
my $update_param; |
74 |
my $insert_param; |
|
added EXPERIMENTAL replace()...
|
75 |
my $join; |
removed register_format()
|
76 | |
77 |
# Prepare table |
|
78 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
79 |
$dbi->execute($CREATE_TABLE->{0}); |
|
80 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
81 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
82 | ||
83 |
test 'DBIx::Custom::Result test'; |
|
renamed build_query to creat...
|
84 |
$source = "select key1, key2 from table1"; |
85 |
$query = $dbi->create_query($source); |
|
removed register_format()
|
86 |
$result = $dbi->execute($query); |
87 | ||
88 |
@rows = (); |
|
89 |
while (my $row = $result->fetch) { |
|
90 |
push @rows, [@$row]; |
|
91 |
} |
|
cleanup
|
92 |
is_deeply(\@rows, [[1, 2], [3, 4]], "fetch"); |
removed register_format()
|
93 | |
94 |
$result = $dbi->execute($query); |
|
95 |
@rows = (); |
|
96 |
while (my $row = $result->fetch_hash) { |
|
97 |
push @rows, {%$row}; |
|
98 |
} |
|
cleanup
|
99 |
is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "fetch_hash"); |
removed register_format()
|
100 | |
101 |
$result = $dbi->execute($query); |
|
102 |
$rows = $result->fetch_all; |
|
cleanup
|
103 |
is_deeply($rows, [[1, 2], [3, 4]], "fetch_all"); |
removed register_format()
|
104 | |
105 |
$result = $dbi->execute($query); |
|
removed reconnect method
|
106 |
$rows = $result->fetch_hash_all; |
added EXPERIMENTAL select pr...
|
107 |
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "all"); |
removed register_format()
|
108 | |
109 |
test 'Insert query return value'; |
|
110 |
$dbi->execute($DROP_TABLE->{0}); |
|
111 |
$dbi->execute($CREATE_TABLE->{0}); |
|
renamed update tag to update...
|
112 |
$source = "insert into table1 {insert_param key1 key2}"; |
updated pod
|
113 |
$query = $dbi->execute($source, {}, query => 1); |
removed register_format()
|
114 |
$ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2}); |
cleanup
|
115 |
ok($ret_val); |
removed register_format()
|
116 | |
117 | ||
118 |
test 'Direct query'; |
|
119 |
$dbi->execute($DROP_TABLE->{0}); |
|
120 |
$dbi->execute($CREATE_TABLE->{0}); |
|
add tests
|
121 |
$insert_SOURCE = "insert into table1 {insert_param key1 key2}"; |
122 |
$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2}); |
|
123 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added EXPERIMENTAL select pr...
|
124 |
$rows = $result->all; |
cleanup
|
125 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
removed register_format()
|
126 | |
127 |
test 'Filter basic'; |
|
128 |
$dbi->execute($DROP_TABLE->{0}); |
|
129 |
$dbi->execute($CREATE_TABLE->{0}); |
|
130 |
$dbi->register_filter(twice => sub { $_[0] * 2}, |
|
131 |
three_times => sub { $_[0] * 3}); |
|
132 | ||
add tests
|
133 |
$insert_SOURCE = "insert into table1 {insert_param key1 key2};"; |
updated pod
|
134 |
$insert_query = $dbi->execute($insert_SOURCE, {}, query => 1); |
removed register_format()
|
135 |
$insert_query->filter({key1 => 'twice'}); |
136 |
$dbi->execute($insert_query, param => {key1 => 1, key2 => 2}); |
|
add tests
|
137 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
138 |
$rows = $result->filter({key2 => 'three_times'})->all; |
cleanup
|
139 |
is_deeply($rows, [{key1 => 2, key2 => 6}], "filter fetch_filter"); |
removed register_format()
|
140 |
$dbi->execute($DROP_TABLE->{0}); |
141 | ||
142 |
test 'Filter in'; |
|
143 |
$dbi->execute($CREATE_TABLE->{0}); |
|
add tests
|
144 |
$insert_SOURCE = "insert into table1 {insert_param key1 key2};"; |
updated pod
|
145 |
$insert_query = $dbi->execute($insert_SOURCE, {}, query => 1); |
removed register_format()
|
146 |
$dbi->execute($insert_query, param => {key1 => 2, key2 => 4}); |
add tests
|
147 |
$select_SOURCE = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}"; |
updated pod
|
148 |
$select_query = $dbi->execute($select_SOURCE,{}, query => 1); |
removed register_format()
|
149 |
$select_query->filter({'table1.key1' => 'twice'}); |
150 |
$result = $dbi->execute($select_query, param => {'table1.key1' => [1,5], 'table1.key2' => [2,4]}); |
|
added EXPERIMENTAL select pr...
|
151 |
$rows = $result->all; |
cleanup
|
152 |
is_deeply($rows, [{key1 => 2, key2 => 4}], "filter"); |
removed register_format()
|
153 | |
154 |
test 'DBIx::Custom::SQLTemplate basic tag'; |
|
155 |
$dbi->execute($DROP_TABLE->{0}); |
|
156 |
$dbi->execute($CREATE_TABLE->{1}); |
|
157 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
158 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
159 | ||
updated pod
|
160 |
$source = "select * from table1 where key1 = :key1 and {<> key2} and {< key3} and {> key4} and {>= key5};"; |
161 |
$query = $dbi->execute($source, {}, query => 1); |
|
removed register_format()
|
162 |
$result = $dbi->execute($query, param => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}); |
added EXPERIMENTAL select pr...
|
163 |
$rows = $result->all; |
cleanup
|
164 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1"); |
removed register_format()
|
165 | |
updated pod
|
166 |
$source = "select * from table1 where key1 = :key1 and {<> key2} and {< key3} and {> key4} and {>= key5};"; |
167 |
$query = $dbi->execute($source, {}, query => 1); |
|
execute method can second ar...
|
168 |
$result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5}); |
added EXPERIMENTAL select pr...
|
169 |
$rows = $result->all; |
execute method can second ar...
|
170 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1"); |
171 | ||
renamed build_query to creat...
|
172 |
$source = "select * from table1 where {<= key1} and {like key2};"; |
updated pod
|
173 |
$query = $dbi->execute($source, {}, query => 1); |
removed register_format()
|
174 |
$result = $dbi->execute($query, param => {key1 => 1, key2 => '%2%'}); |
added EXPERIMENTAL select pr...
|
175 |
$rows = $result->all; |
cleanup
|
176 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag2"); |
removed register_format()
|
177 | |
178 |
test 'DIB::Custom::SQLTemplate in tag'; |
|
179 |
$dbi->execute($DROP_TABLE->{0}); |
|
180 |
$dbi->execute($CREATE_TABLE->{1}); |
|
181 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
182 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
183 | ||
renamed build_query to creat...
|
184 |
$source = "select * from table1 where {in key1 2};"; |
updated pod
|
185 |
$query = $dbi->execute($source, {}, query => 1); |
removed register_format()
|
186 |
$result = $dbi->execute($query, param => {key1 => [9, 1]}); |
added EXPERIMENTAL select pr...
|
187 |
$rows = $result->all; |
cleanup
|
188 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic"); |
removed register_format()
|
189 | |
190 |
test 'DBIx::Custom::SQLTemplate insert tag'; |
|
191 |
$dbi->execute("delete from table1"); |
|
add tests
|
192 |
$insert_SOURCE = 'insert into table1 {insert_param key1 key2 key3 key4 key5}'; |
193 |
$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
removed register_format()
|
194 | |
add tests
|
195 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
196 |
$rows = $result->all; |
cleanup
|
197 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic"); |
removed register_format()
|
198 | |
199 |
test 'DBIx::Custom::SQLTemplate update tag'; |
|
200 |
$dbi->execute("delete from table1"); |
|
add tests
|
201 |
$insert_SOURCE = "insert into table1 {insert_param key1 key2 key3 key4 key5}"; |
202 |
$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
203 |
$dbi->execute($insert_SOURCE, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
removed register_format()
|
204 | |
add tests
|
205 |
$update_SOURCE = 'update table1 {update_param key1 key2 key3 key4} where {= key5}'; |
206 |
$dbi->execute($update_SOURCE, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5}); |
|
removed register_format()
|
207 | |
add tests
|
208 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
209 |
$rows = $result->all; |
removed register_format()
|
210 |
is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5}, |
cleanup
|
211 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "basic"); |
removed register_format()
|
212 | |
- update_param_tag is DEPREC...
|
213 | |
214 |
test 'parameter'; |
|
215 |
$dbi->execute($DROP_TABLE->{0}); |
|
216 |
$dbi->execute($CREATE_TABLE->{1}); |
|
217 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
218 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
219 | ||
220 |
$source = "select * from table1 where key1 = :key1 and key2 = :key2"; |
|
221 |
$result = $dbi->execute($source, param => {key1 => 1, key2 => 2}); |
|
added EXPERIMENTAL select pr...
|
222 |
$rows = $result->all; |
- update_param_tag is DEPREC...
|
223 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]); |
224 | ||
225 |
$source = "select * from table1 where key1 = \n:key1\n and key2 = :key2"; |
|
226 |
$result = $dbi->execute($source, param => {key1 => 1, key2 => 2}); |
|
added EXPERIMENTAL select pr...
|
227 |
$rows = $result->all; |
- update_param_tag is DEPREC...
|
228 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]); |
229 | ||
230 |
$source = "select * from table1 where key1 = :key1 or key1 = :key1"; |
|
231 |
$result = $dbi->execute($source, param => {key1 => [1, 2]}); |
|
added EXPERIMENTAL select pr...
|
232 |
$rows = $result->all; |
- update_param_tag is DEPREC...
|
233 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]); |
234 | ||
235 |
$source = "select * from table1 where key1 = :table1.key1 and key2 = :table1.key2"; |
|
236 |
$result = $dbi->execute( |
|
237 |
$source, |
|
238 |
param => {'table1.key1' => 1, 'table1.key2' => 1}, |
|
239 |
filter => {'table1.key2' => sub { $_[0] * 2 }} |
|
240 |
); |
|
added EXPERIMENTAL select pr...
|
241 |
$rows = $result->all; |
- update_param_tag is DEPREC...
|
242 |
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]); |
243 | ||
removed register_format()
|
244 |
test 'Error case'; |
data_source is DEPRECATED! I...
|
245 |
eval {DBIx::Custom->connect(dsn => 'dbi:SQLit')}; |
cleanup
|
246 |
ok($@, "connect error"); |
removed register_format()
|
247 | |
248 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
updated pod
|
249 |
eval{$dbi->execute("{p }", {}, query => 1)}; |
cleanup
|
250 |
ok($@, "create_query invalid SQL template"); |
removed register_format()
|
251 | |
252 |
test 'insert'; |
|
253 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
254 |
$dbi->execute($CREATE_TABLE->{0}); |
|
255 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
256 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
add tests
|
257 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
258 |
$rows = $result->all; |
cleanup
|
259 |
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic"); |
removed register_format()
|
260 | |
261 |
$dbi->execute('delete from table1'); |
|
262 |
$dbi->register_filter( |
|
263 |
twice => sub { $_[0] * 2 }, |
|
264 |
three_times => sub { $_[0] * 3 } |
|
265 |
); |
|
renamed default_query_filter...
|
266 |
$dbi->default_bind_filter('twice'); |
removed register_format()
|
267 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'}); |
add tests
|
268 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
269 |
$rows = $result->all; |
cleanup
|
270 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "filter"); |
renamed default_query_filter...
|
271 |
$dbi->default_bind_filter(undef); |
removed register_format()
|
272 | |
273 |
$dbi->execute($DROP_TABLE->{0}); |
|
274 |
$dbi->execute($CREATE_TABLE->{0}); |
|
275 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => ' '); |
|
added EXPERIMENTAL select pr...
|
276 |
$rows = $dbi->select(table => 'table1')->all; |
removed register_format()
|
277 |
is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append'); |
278 | ||
changed argument of tag proc...
|
279 |
eval{$dbi->insert(table => 'table1', noexist => 1)}; |
cleanup
|
280 |
like($@, qr/noexist/, "invalid"); |
changed argument of tag proc...
|
281 | |
select() where can't receive...
|
282 |
eval{$dbi->insert(table => 'table', param => {';' => 1})}; |
283 |
like($@, qr/safety/); |
|
changed argument of tag proc...
|
284 | |
added EXPERIMENTAL reserved_...
|
285 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
reserved_word_quote is DEPRE...
|
286 |
$dbi->quote('"'); |
added EXPERIMENTAL reserved_...
|
287 |
$dbi->execute('create table "table" ("select")'); |
288 |
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}}); |
|
289 |
$dbi->insert(table => 'table', param => {select => 1}); |
|
290 |
$result = $dbi->execute('select * from "table"'); |
|
added EXPERIMENTAL select pr...
|
291 |
$rows = $result->all; |
added EXPERIMENTAL reserved_...
|
292 |
is_deeply($rows, [{select => 2}], "reserved word"); |
293 | ||
- insert, insert_at, update,...
|
294 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
295 |
$dbi->execute($CREATE_TABLE->{0}); |
|
296 |
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1'); |
|
297 |
$dbi->insert({key1 => 3, key2 => 4}, table => 'table1'); |
|
298 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added EXPERIMENTAL select pr...
|
299 |
$rows = $result->all; |
- insert, insert_at, update,...
|
300 |
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic"); |
301 | ||
added EXPERIMENTAL insert, u...
|
302 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
303 |
$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))"); |
|
304 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
305 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4}, prefix => 'or replace'); |
|
306 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
307 |
$rows = $result->all; |
|
308 |
is_deeply($rows, [{key1 => 1, key2 => 4}], "basic"); |
|
309 | ||
removed register_format()
|
310 |
test 'update'; |
311 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
312 |
$dbi->execute($CREATE_TABLE->{1}); |
|
313 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
314 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
315 |
$dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}); |
|
add tests
|
316 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
317 |
$rows = $result->all; |
removed register_format()
|
318 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5}, |
319 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
cleanup
|
320 |
"basic"); |
removed register_format()
|
321 |
|
322 |
$dbi->execute("delete from table1"); |
|
323 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
324 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
325 |
$dbi->update(table => 'table1', param => {key2 => 12}, where => {key2 => 2, key3 => 3}); |
|
add tests
|
326 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
327 |
$rows = $result->all; |
removed register_format()
|
328 |
is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5}, |
329 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
cleanup
|
330 |
"update key same as search key"); |
removed register_format()
|
331 | |
add tests
|
332 |
$dbi->update(table => 'table1', param => {key2 => [12]}, where => {key2 => 2, key3 => 3}); |
333 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added EXPERIMENTAL select pr...
|
334 |
$rows = $result->all; |
add tests
|
335 |
is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5}, |
336 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
cleanup
|
337 |
"update key same as search key : param is array ref"); |
add tests
|
338 | |
removed register_format()
|
339 |
$dbi->execute("delete from table1"); |
340 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
341 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
342 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
343 |
$dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, |
|
many changed
|
344 |
filter => {key2 => sub { $_[0] * 2 }}); |
add tests
|
345 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
346 |
$rows = $result->all; |
removed register_format()
|
347 |
is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5}, |
348 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
cleanup
|
349 |
"filter"); |
removed register_format()
|
350 | |
351 |
$result = $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, append => ' '); |
|
352 | ||
changed argument of tag proc...
|
353 |
eval{$dbi->update(table => 'table1', noexist => 1)}; |
cleanup
|
354 |
like($@, qr/noexist/, "invalid"); |
changed argument of tag proc...
|
355 | |
356 |
eval{$dbi->update(table => 'table1')}; |
|
cleanup
|
357 |
like($@, qr/where/, "not contain where"); |
changed argument of tag proc...
|
358 | |
improved delete() and update...
|
359 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
360 |
$dbi->execute($CREATE_TABLE->{0}); |
|
361 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
362 |
$where = $dbi->where; |
|
- update_param_tag is DEPREC...
|
363 |
$where->clause(['and', 'key1 = :key1', 'key2 = :key2']); |
improved delete() and update...
|
364 |
$where->param({key1 => 1, key2 => 2}); |
365 |
$dbi->update(table => 'table1', param => {key1 => 3}, where => $where); |
|
366 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
367 |
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where'); |
where can recieve array refr...
|
368 | |
369 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
370 |
$dbi->execute($CREATE_TABLE->{0}); |
|
371 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
372 |
$dbi->update( |
|
373 |
table => 'table1', |
|
374 |
param => {key1 => 3}, |
|
375 |
where => [ |
|
updated pod
|
376 |
['and', 'key1 = :key1', 'key2 = :key2'], |
where can recieve array refr...
|
377 |
{key1 => 1, key2 => 2} |
378 |
] |
|
379 |
); |
|
380 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
381 |
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where'); |
improved delete() and update...
|
382 | |
383 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
384 |
$dbi->execute($CREATE_TABLE->{0}); |
|
385 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
386 |
$where = $dbi->where; |
|
updated pod
|
387 |
$where->clause(['and', 'key2 = :key2']); |
improved delete() and update...
|
388 |
$where->param({key2 => 2}); |
389 |
$dbi->update(table => 'table1', param => {key1 => 3}, where => $where); |
|
390 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
391 |
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where'); |
changed argument of tag proc...
|
392 | |
select() where can't receive...
|
393 |
eval{$dbi->update(table => 'table1', param => {';' => 1})}; |
394 |
like($@, qr/safety/); |
|
395 | ||
396 |
eval{$dbi->update(table => 'table1', param => {'key1' => 1}, where => {';' => 1})}; |
|
397 |
like($@, qr/safety/); |
|
398 | ||
added EXPERIMENTAL reserved_...
|
399 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
reserved_word_quote is DEPRE...
|
400 |
$dbi->quote('"'); |
added EXPERIMENTAL reserved_...
|
401 |
$dbi->execute('create table "table" ("select", "update")'); |
402 |
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}}); |
|
403 |
$dbi->apply_filter('table', update => {out => sub { $_[0] * 3}}); |
|
404 |
$dbi->insert(table => 'table', param => {select => 1}); |
|
405 |
$dbi->update(table => 'table', where => {select => 1}, param => {update => 2}); |
|
406 |
$result = $dbi->execute('select * from "table"'); |
|
added EXPERIMENTAL select pr...
|
407 |
$rows = $result->all; |
added EXPERIMENTAL reserved_...
|
408 |
is_deeply($rows, [{select => 2, update => 6}], "reserved word"); |
409 | ||
410 |
eval {$dbi->update_all(table => 'table', param => {';' => 2}) }; |
|
411 |
like($@, qr/safety/); |
|
412 | ||
413 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
414 |
$dbi->reserved_word_quote('"'); |
|
415 |
$dbi->execute('create table "table" ("select", "update")'); |
|
416 |
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}}); |
|
417 |
$dbi->apply_filter('table', update => {out => sub { $_[0] * 3}}); |
|
418 |
$dbi->insert(table => 'table', param => {select => 1}); |
|
419 |
$dbi->update(table => 'table', where => {'table.select' => 1}, param => {update => 2}); |
|
420 |
$result = $dbi->execute('select * from "table"'); |
|
added EXPERIMENTAL select pr...
|
421 |
$rows = $result->all; |
added EXPERIMENTAL reserved_...
|
422 |
is_deeply($rows, [{select => 2, update => 6}], "reserved word"); |
423 | ||
- insert, insert_at, update,...
|
424 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
425 |
$dbi->execute($CREATE_TABLE->{1}); |
|
426 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
427 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
428 |
$dbi->update({key2 => 11}, table => 'table1', where => {key1 => 1}); |
|
429 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added EXPERIMENTAL select pr...
|
430 |
$rows = $result->all; |
- insert, insert_at, update,...
|
431 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5}, |
432 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
433 |
"basic"); |
|
434 | ||
added EXPERIMENTAL insert, u...
|
435 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
436 |
$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))"); |
|
437 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
438 |
$dbi->update(table => 'table1', param => {key2 => 4}, |
|
439 |
where => {key1 => 1}, prefix => 'or replace'); |
|
440 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
441 |
$rows = $result->all; |
|
442 |
is_deeply($rows, [{key1 => 1, key2 => 4}], "basic"); |
|
443 | ||
removed register_format()
|
444 |
test 'update_all'; |
445 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
446 |
$dbi->execute($CREATE_TABLE->{1}); |
|
447 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
448 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
449 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
450 |
$dbi->update_all(table => 'table1', param => {key2 => 10}, filter => {key2 => 'twice'}); |
|
add tests
|
451 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
452 |
$rows = $result->all; |
removed register_format()
|
453 |
is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5}, |
454 |
{key1 => 6, key2 => 20, key3 => 8, key4 => 9, key5 => 10}], |
|
cleanup
|
455 |
"filter"); |
removed register_format()
|
456 | |
457 | ||
458 |
test 'delete'; |
|
459 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
460 |
$dbi->execute($CREATE_TABLE->{0}); |
|
461 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
462 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
463 |
$dbi->delete(table => 'table1', where => {key1 => 1}); |
|
add tests
|
464 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
465 |
$rows = $result->all; |
cleanup
|
466 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "basic"); |
removed register_format()
|
467 | |
468 |
$dbi->execute("delete from table1;"); |
|
469 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
470 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
471 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
472 |
$dbi->delete(table => 'table1', where => {key2 => 1}, filter => {key2 => 'twice'}); |
|
add tests
|
473 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
474 |
$rows = $result->all; |
cleanup
|
475 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "filter"); |
removed register_format()
|
476 | |
477 |
$dbi->delete(table => 'table1', where => {key1 => 1}, append => ' '); |
|
478 | ||
479 |
$dbi->delete_all(table => 'table1'); |
|
480 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
481 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
482 |
$dbi->delete(table => 'table1', where => {key1 => 1, key2 => 2}); |
|
added EXPERIMENTAL select pr...
|
483 |
$rows = $dbi->select(table => 'table1')->all; |
cleanup
|
484 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "delete multi key"); |
removed register_format()
|
485 | |
changed argument of tag proc...
|
486 |
eval{$dbi->delete(table => 'table1', noexist => 1)}; |
cleanup
|
487 |
like($@, qr/noexist/, "invalid"); |
changed argument of tag proc...
|
488 | |
improved delete() and update...
|
489 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
490 |
$dbi->execute($CREATE_TABLE->{0}); |
|
491 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
492 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
493 |
$where = $dbi->where; |
|
updated pod
|
494 |
$where->clause(['and', 'key1 = :key1', 'key2 = :key2']); |
improved delete() and update...
|
495 |
$where->param({ke1 => 1, key2 => 2}); |
496 |
$dbi->delete(table => 'table1', where => $where); |
|
497 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
498 |
is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where'); |
changed argument of tag proc...
|
499 | |
where can recieve array refr...
|
500 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
501 |
$dbi->execute($CREATE_TABLE->{0}); |
|
502 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
503 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
504 |
$dbi->delete( |
|
505 |
table => 'table1', |
|
506 |
where => [ |
|
updated pod
|
507 |
['and', 'key1 = :key1', 'key2 = :key2'], |
where can recieve array refr...
|
508 |
{ke1 => 1, key2 => 2} |
509 |
] |
|
510 |
); |
|
511 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
512 |
is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where'); |
where can recieve array refr...
|
513 | |
added EXPERIMENTAL insert, u...
|
514 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
515 |
$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))"); |
|
516 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
517 |
$dbi->delete(table => 'table1', where => {key1 => 1}, prefix => ' '); |
|
518 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
519 |
$rows = $result->all; |
|
520 |
is_deeply($rows, [], "basic"); |
|
521 | ||
removed register_format()
|
522 |
test 'delete error'; |
523 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
524 |
$dbi->execute($CREATE_TABLE->{0}); |
|
525 |
eval{$dbi->delete(table => 'table1')}; |
|
make delete() using where ob...
|
526 |
like($@, qr/"where" must be specified/, |
cleanup
|
527 |
"where key-value pairs not specified"); |
removed register_format()
|
528 | |
select() where can't receive...
|
529 |
eval{$dbi->delete(table => 'table1', where => {';' => 1})}; |
530 |
like($@, qr/safety/); |
|
531 | ||
added EXPERIMENTAL reserved_...
|
532 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
reserved_word_quote is DEPRE...
|
533 |
$dbi->quote('"'); |
added EXPERIMENTAL reserved_...
|
534 |
$dbi->execute('create table "table" ("select", "update")'); |
535 |
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}}); |
|
536 |
$dbi->insert(table => 'table', param => {select => 1}); |
|
537 |
$dbi->delete(table => 'table', where => {select => 1}); |
|
538 |
$result = $dbi->execute('select * from "table"'); |
|
added EXPERIMENTAL select pr...
|
539 |
$rows = $result->all; |
added EXPERIMENTAL reserved_...
|
540 |
is_deeply($rows, [], "reserved word"); |
541 | ||
removed register_format()
|
542 |
test 'delete_all'; |
543 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
544 |
$dbi->execute($CREATE_TABLE->{0}); |
|
545 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
546 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
547 |
$dbi->delete_all(table => 'table1'); |
|
add tests
|
548 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
549 |
$rows = $result->all; |
cleanup
|
550 |
is_deeply($rows, [], "basic"); |
removed register_format()
|
551 | |
552 | ||
553 |
test 'select'; |
|
554 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
555 |
$dbi->execute($CREATE_TABLE->{0}); |
|
556 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
557 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
added EXPERIMENTAL select pr...
|
558 |
$rows = $dbi->select(table => 'table1')->all; |
removed register_format()
|
559 |
is_deeply($rows, [{key1 => 1, key2 => 2}, |
cleanup
|
560 |
{key1 => 3, key2 => 4}], "table"); |
removed register_format()
|
561 | |
added EXPERIMENTAL select pr...
|
562 |
$rows = $dbi->select(table => 'table1', column => ['key1'])->all; |
cleanup
|
563 |
is_deeply($rows, [{key1 => 1}, {key1 => 3}], "table and columns and where key"); |
removed register_format()
|
564 | |
added EXPERIMENTAL select pr...
|
565 |
$rows = $dbi->select(table => 'table1', where => {key1 => 1})->all; |
cleanup
|
566 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "table and columns and where key"); |
removed register_format()
|
567 | |
added EXPERIMENTAL select pr...
|
568 |
$rows = $dbi->select(table => 'table1', column => ['key1'], where => {key1 => 3})->all; |
cleanup
|
569 |
is_deeply($rows, [{key1 => 3}], "table and columns and where key"); |
removed register_format()
|
570 | |
added EXPERIMENTAL select pr...
|
571 |
$rows = $dbi->select(table => 'table1', append => "order by key1 desc limit 1")->all; |
cleanup
|
572 |
is_deeply($rows, [{key1 => 3, key2 => 4}], "append statement"); |
removed register_format()
|
573 | |
574 |
$dbi->register_filter(decrement => sub { $_[0] - 1 }); |
|
update document
|
575 |
$rows = $dbi->select(table => 'table1', where => {key1 => 2}, filter => {key1 => 'decrement'}) |
added EXPERIMENTAL select pr...
|
576 |
->all; |
cleanup
|
577 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "filter"); |
removed register_format()
|
578 | |
579 |
$dbi->execute($CREATE_TABLE->{2}); |
|
580 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5}); |
|
581 |
$rows = $dbi->select( |
|
582 |
table => [qw/table1 table2/], |
|
select method column option ...
|
583 |
column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3', |
removed register_format()
|
584 |
where => {'table1.key2' => 2}, |
added commit method
|
585 |
relation => {'table1.key1' => 'table2.key1'} |
added EXPERIMENTAL select pr...
|
586 |
)->all; |
cleanup
|
587 |
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : exists where"); |
added commit method
|
588 | |
589 |
$rows = $dbi->select( |
|
590 |
table => [qw/table1 table2/], |
|
591 |
column => ['table1.key1 as table1_key1', 'table2.key1 as table2_key1', 'key2', 'key3'], |
|
592 |
relation => {'table1.key1' => 'table2.key1'} |
|
added EXPERIMENTAL select pr...
|
593 |
)->all; |
cleanup
|
594 |
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : no exists where"); |
removed register_format()
|
595 | |
changed argument of tag proc...
|
596 |
eval{$dbi->select(table => 'table1', noexist => 1)}; |
cleanup
|
597 |
like($@, qr/noexist/, "invalid"); |
changed argument of tag proc...
|
598 | |
added EXPERIMENTAL reserved_...
|
599 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
reserved_word_quote is DEPRE...
|
600 |
$dbi->quote('"'); |
added EXPERIMENTAL reserved_...
|
601 |
$dbi->execute('create table "table" ("select", "update")'); |
602 |
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}}); |
|
603 |
$dbi->insert(table => 'table', param => {select => 1, update => 2}); |
|
604 |
$result = $dbi->select(table => 'table', where => {select => 1}); |
|
added EXPERIMENTAL select pr...
|
605 |
$rows = $result->all; |
added EXPERIMENTAL reserved_...
|
606 |
is_deeply($rows, [{select => 2, update => 2}], "reserved word"); |
changed argument of tag proc...
|
607 | |
removed register_format()
|
608 |
test 'fetch filter'; |
609 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
610 |
$dbi->register_filter( |
|
611 |
twice => sub { $_[0] * 2 }, |
|
612 |
three_times => sub { $_[0] * 3 } |
|
613 |
); |
|
614 |
$dbi->default_fetch_filter('twice'); |
|
615 |
$dbi->execute($CREATE_TABLE->{0}); |
|
616 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
617 |
$result = $dbi->select(table => 'table1'); |
|
618 |
$result->filter({key1 => 'three_times'}); |
|
- added DBIx::Custom::Result...
|
619 |
$row = $result->one; |
cleanup
|
620 |
is_deeply($row, {key1 => 3, key2 => 4}, "default_fetch_filter and filter"); |
removed register_format()
|
621 | |
622 |
test 'filters'; |
|
623 |
$dbi = DBIx::Custom->new; |
|
624 | ||
update document
|
625 |
is($dbi->filters->{decode_utf8}->(encode_utf8('あ')), |
cleanup
|
626 |
'あ', "decode_utf8"); |
removed register_format()
|
627 | |
628 |
is($dbi->filters->{encode_utf8}->('あ'), |
|
cleanup
|
629 |
encode_utf8('あ'), "encode_utf8"); |
removed register_format()
|
630 | |
added commit method
|
631 |
test 'transaction'; |
632 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
633 |
$dbi->execute($CREATE_TABLE->{0}); |
|
removed DBIx::Custom commit ...
|
634 |
$dbi->dbh->begin_work; |
added commit method
|
635 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
636 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
removed DBIx::Custom commit ...
|
637 |
$dbi->dbh->commit; |
added commit method
|
638 |
$result = $dbi->select(table => 'table1'); |
- added DBIx::Custom::Result...
|
639 |
is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}], |
cleanup
|
640 |
"commit"); |
added commit method
|
641 | |
642 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
643 |
$dbi->execute($CREATE_TABLE->{0}); |
|
removed DBIx::Custom commit ...
|
644 |
$dbi->dbh->begin_work(0); |
added commit method
|
645 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
removed DBIx::Custom commit ...
|
646 |
$dbi->dbh->rollback; |
added commit method
|
647 | |
648 |
$result = $dbi->select(table => 'table1'); |
|
cleanup
|
649 |
ok(! $result->fetch_first, "rollback"); |
add cache attribute
|
650 | |
651 |
test 'cache'; |
|
652 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
removed from cache() and cac...
|
653 |
$dbi->cache(1); |
add cache attribute
|
654 |
$dbi->execute($CREATE_TABLE->{0}); |
updated pod
|
655 |
$source = 'select * from table1 where key1 = :key1 and key2 = :key2;'; |
656 |
$dbi->execute($source, {}, query => 1); |
|
renamed build_query to creat...
|
657 |
is_deeply($dbi->{_cached}->{$source}, |
add table tag
|
658 |
{sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2'], tables => []}, "cache"); |
add cache attribute
|
659 | |
660 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
661 |
$dbi->execute($CREATE_TABLE->{0}); |
|
662 |
$dbi->{_cached} = {}; |
|
663 |
$dbi->cache(0); |
|
664 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
665 |
is(scalar keys %{$dbi->{_cached}}, 0, 'not cache'); |
|
666 | ||
add tests
|
667 |
test 'execute'; |
668 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
669 |
$dbi->execute($CREATE_TABLE->{0}); |
|
removed experimental registe...
|
670 |
{ |
671 |
local $Carp::Verbose = 0; |
|
672 |
eval{$dbi->execute('select * frm table1')}; |
|
cleanup
|
673 |
like($@, qr/\Qselect * frm table1;/, "fail prepare"); |
674 |
like($@, qr/\.t /, "fail : not verbose"); |
|
removed experimental registe...
|
675 |
} |
676 |
{ |
|
677 |
local $Carp::Verbose = 1; |
|
678 |
eval{$dbi->execute('select * frm table1')}; |
|
cleanup
|
679 |
like($@, qr/Custom.*\.t /s, "fail : verbose"); |
removed experimental registe...
|
680 |
} |
add tests
|
681 | |
682 |
eval{$dbi->execute('select * from table1', no_exists => 1)}; |
|
improved error messages
|
683 |
like($@, qr/wrong/, "invald SQL"); |
add tests
|
684 | |
updated pod
|
685 |
$query = $dbi->execute('select * from table1 where key1 = :key1', {}, query => 1); |
add tests
|
686 |
$dbi->dbh->disconnect; |
687 |
eval{$dbi->execute($query, param => {key1 => {a => 1}})}; |
|
cleanup
|
688 |
ok($@, "execute fail"); |
add tests
|
689 | |
removed experimental registe...
|
690 |
{ |
691 |
local $Carp::Verbose = 0; |
|
updated pod
|
692 |
eval{$dbi->execute('select * from table1 where {0 key1}', {}, query => 1)}; |
cleanup
|
693 |
like($@, qr/\Q.t /, "caller spec : not vebose"); |
removed experimental registe...
|
694 |
} |
695 |
{ |
|
696 |
local $Carp::Verbose = 1; |
|
updated pod
|
697 |
eval{$dbi->execute('select * from table1 where {0 key1}', {}, query => 1)}; |
cleanup
|
698 |
like($@, qr/QueryBuilder.*\.t /s, "caller spec : not vebose"); |
removed experimental registe...
|
699 |
} |
cleanup
|
700 | |
701 | ||
702 |
test 'transaction'; |
|
703 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
704 |
$dbi->execute($CREATE_TABLE->{0}); |
|
705 | ||
706 |
$dbi->begin_work; |
|
707 | ||
708 |
eval { |
|
709 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
710 |
die "Error"; |
|
711 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
712 |
}; |
|
713 | ||
714 |
$dbi->rollback if $@; |
|
715 | ||
716 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
717 |
$rows = $result->all; |
cleanup
|
718 |
is_deeply($rows, [], "rollback"); |
cleanup
|
719 | |
720 |
$dbi->begin_work; |
|
721 | ||
722 |
eval { |
|
723 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
724 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
725 |
}; |
|
726 | ||
727 |
$dbi->commit unless $@; |
|
728 | ||
729 |
$result = $dbi->select(table => 'table1'); |
|
added EXPERIMENTAL select pr...
|
730 |
$rows = $result->all; |
cleanup
|
731 |
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "commit"); |
cleanup
|
732 | |
733 |
$dbi->dbh->{AutoCommit} = 0; |
|
734 |
eval{ $dbi->begin_work }; |
|
cleanup
|
735 |
ok($@, "exception"); |
cleanup
|
736 |
$dbi->dbh->{AutoCommit} = 1; |
737 | ||
added helper method
|
738 | |
renamed helper to method.
|
739 |
test 'method'; |
added helper method
|
740 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
renamed helper to method.
|
741 |
$dbi->method( |
added helper method
|
742 |
one => sub { 1 } |
743 |
); |
|
renamed helper to method.
|
744 |
$dbi->method( |
added helper method
|
745 |
two => sub { 2 } |
746 |
); |
|
renamed helper to method.
|
747 |
$dbi->method({ |
added helper method
|
748 |
twice => sub { |
749 |
my $self = shift; |
|
750 |
return $_[0] * 2; |
|
751 |
} |
|
752 |
}); |
|
753 | ||
cleanup
|
754 |
is($dbi->one, 1, "first"); |
755 |
is($dbi->two, 2, "second"); |
|
756 |
is($dbi->twice(5), 10 , "second"); |
|
added helper method
|
757 | |
758 |
eval {$dbi->XXXXXX}; |
|
autoload DBI method
|
759 |
ok($@, "not exists"); |
added helper method
|
760 | |
renamed auto_filter to apply...
|
761 |
test 'out filter'; |
added auto_filter method
|
762 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
763 |
$dbi->execute($CREATE_TABLE->{0}); |
|
764 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
765 |
$dbi->register_filter(three_times => sub { $_[0] * 3}); |
|
renamed auto_filter to apply...
|
766 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
767 |
'table1', 'key1' => {out => 'twice', in => 'three_times'}, |
768 |
'key2' => {out => 'three_times', in => 'twice'}); |
|
added auto_filter method
|
769 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
770 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
771 |
$row = $result->fetch_hash_first; |
|
cleanup
|
772 |
is_deeply($row, {key1 => 2, key2 => 6}, "insert"); |
renamed auto_filter to apply...
|
773 |
$result = $dbi->select(table => 'table1'); |
added tests
|
774 |
$row = $result->one; |
cleanup
|
775 |
is_deeply($row, {key1 => 6, key2 => 12}, "insert"); |
added auto_filter method
|
776 | |
fix bug : filter can't over...
|
777 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
778 |
$dbi->execute($CREATE_TABLE->{0}); |
|
779 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
780 |
$dbi->register_filter(three_times => sub { $_[0] * 3}); |
|
781 |
$dbi->apply_filter( |
|
782 |
'table1', 'key1' => {out => 'twice', in => 'three_times'}, |
|
783 |
'key2' => {out => 'three_times', in => 'twice'}); |
|
784 |
$dbi->apply_filter( |
|
785 |
'table1', 'key1' => {out => undef} |
|
786 |
); |
|
787 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
788 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added tests
|
789 |
$row = $result->one; |
fix bug : filter can't over...
|
790 |
is_deeply($row, {key1 => 1, key2 => 6}, "insert"); |
791 | ||
added auto_filter method
|
792 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
793 |
$dbi->execute($CREATE_TABLE->{0}); |
|
794 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
renamed auto_filter to apply...
|
795 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
796 |
'table1', 'key1' => {out => 'twice', in => 'twice'} |
added auto_filter method
|
797 |
); |
renamed auto_filter to apply...
|
798 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => undef}); |
added auto_filter method
|
799 |
$dbi->update(table => 'table1', param => {key1 => 2}, where => {key2 => 2}); |
800 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added tests
|
801 |
$row = $result->one; |
cleanup
|
802 |
is_deeply($row, {key1 => 4, key2 => 2}, "update"); |
added auto_filter method
|
803 | |
804 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
805 |
$dbi->execute($CREATE_TABLE->{0}); |
|
806 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
renamed auto_filter to apply...
|
807 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
808 |
'table1', 'key1' => {out => 'twice', in => 'twice'} |
added auto_filter method
|
809 |
); |
renamed auto_filter to apply...
|
810 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1=> undef}); |
added auto_filter method
|
811 |
$dbi->delete(table => 'table1', where => {key1 => 1}); |
812 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
|
added EXPERIMENTAL select pr...
|
813 |
$rows = $result->all; |
cleanup
|
814 |
is_deeply($rows, [], "delete"); |
added auto_filter method
|
815 | |
816 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
817 |
$dbi->execute($CREATE_TABLE->{0}); |
|
818 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
renamed auto_filter to apply...
|
819 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
820 |
'table1', 'key1' => {out => 'twice', in => 'twice'} |
added auto_filter method
|
821 |
); |
renamed auto_filter to apply...
|
822 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef}); |
added auto_filter method
|
823 |
$result = $dbi->select(table => 'table1', where => {key1 => 1}); |
824 |
$result->filter({'key2' => 'twice'}); |
|
added EXPERIMENTAL select pr...
|
825 |
$rows = $result->all; |
cleanup
|
826 |
is_deeply($rows, [{key1 => 4, key2 => 4}], "select"); |
added auto_filter method
|
827 | |
828 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
829 |
$dbi->execute($CREATE_TABLE->{0}); |
|
830 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
renamed auto_filter to apply...
|
831 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
832 |
'table1', 'key1' => {out => 'twice', in => 'twice'} |
added auto_filter method
|
833 |
); |
renamed auto_filter to apply...
|
834 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef}); |
updated pod
|
835 |
$result = $dbi->execute("select * from table1 where key1 = :key1 and key2 = :key2;", |
added auto_filter method
|
836 |
param => {key1 => 1, key2 => 2}, |
renamed auto_filter to apply...
|
837 |
table => ['table1']); |
added EXPERIMENTAL select pr...
|
838 |
$rows = $result->all; |
cleanup
|
839 |
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute"); |
added auto_filter method
|
840 | |
add table tag
|
841 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
842 |
$dbi->execute($CREATE_TABLE->{0}); |
|
843 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
844 |
$dbi->apply_filter( |
|
845 |
'table1', 'key1' => {out => 'twice', in => 'twice'} |
|
846 |
); |
|
847 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef}); |
|
updated pod
|
848 |
$result = $dbi->execute("select * from {table table1} where key1 = :key1 and key2 = :key2;", |
add table tag
|
849 |
param => {key1 => 1, key2 => 2}); |
added EXPERIMENTAL select pr...
|
850 |
$rows = $result->all; |
add table tag
|
851 |
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag"); |
852 | ||
added auto_filter method
|
853 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
854 |
$dbi->execute($CREATE_TABLE->{0}); |
|
855 |
$dbi->execute($CREATE_TABLE->{2}); |
|
856 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
857 |
$dbi->register_filter(three_times => sub { $_[0] * 3 }); |
|
renamed auto_filter to apply...
|
858 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
859 |
'table1', 'key2' => {out => 'twice', in => 'twice'} |
added auto_filter method
|
860 |
); |
renamed auto_filter to apply...
|
861 |
$dbi->apply_filter( |
renamed auto_filter to apply...
|
862 |
'table2', 'key3' => {out => 'three_times', in => 'three_times'} |
added auto_filter method
|
863 |
); |
renamed auto_filter to apply...
|
864 |
$dbi->insert(table => 'table1', param => {key1 => 5, key2 => 2}, filter => {key2 => undef}); |
865 |
$dbi->insert(table => 'table2', param => {key1 => 5, key3 => 6}, filter => {key3 => undef}); |
|
added auto_filter method
|
866 |
$result = $dbi->select( |
867 |
table => ['table1', 'table2'], |
|
868 |
column => ['key2', 'key3'], |
|
869 |
where => {'table1.key2' => 1, 'table2.key3' => 2}, relation => {'table1.key1' => 'table2.key1'}); |
|
870 | ||
871 |
$result->filter({'key2' => 'twice'}); |
|
added EXPERIMENTAL select pr...
|
872 |
$rows = $result->all; |
cleanup
|
873 |
is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join"); |
added auto_filter method
|
874 | |
875 |
$result = $dbi->select( |
|
876 |
table => ['table1', 'table2'], |
|
877 |
column => ['key2', 'key3'], |
|
878 |
where => {'key2' => 1, 'key3' => 2}, relation => {'table1.key1' => 'table2.key1'}); |
|
879 | ||
880 |
$result->filter({'key2' => 'twice'}); |
|
added EXPERIMENTAL select pr...
|
881 |
$rows = $result->all; |
cleanup
|
882 |
is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit"); |
added auto_filter method
|
883 | |
pod fix
|
884 |
test 'each_column'; |
added experimental iterate_a...
|
885 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
886 |
$dbi->execute($CREATE_TABLE->{2}); |
|
887 |
$dbi->execute($CREATE_TABLE->{3}); |
|
888 | ||
889 |
$infos = []; |
|
pod fix
|
890 |
$dbi->each_column(sub { |
removed experimental txn_sco...
|
891 |
my ($self, $table, $column, $cinfo) = @_; |
added experimental iterate_a...
|
892 |
|
893 |
if ($table =~ /^table/) { |
|
894 |
my $info = [$table, $column, $cinfo->{COLUMN_NAME}]; |
|
895 |
push @$infos, $info; |
|
896 |
} |
|
897 |
}); |
|
898 |
$infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos]; |
|
899 |
is_deeply($infos, |
|
900 |
[ |
|
901 |
['table1', 'key1', 'key1'], |
|
902 |
['table1', 'key2', 'key2'], |
|
903 |
['table2', 'key1', 'key1'], |
|
904 |
['table2', 'key3', 'key3'] |
|
905 |
] |
|
cleanup
|
906 |
|
added experimental iterate_a...
|
907 |
); |
added EXPERIMENTAL each_tabl...
|
908 |
test 'each_table'; |
909 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
910 |
$dbi->execute($CREATE_TABLE->{2}); |
|
911 |
$dbi->execute($CREATE_TABLE->{3}); |
|
912 | ||
913 |
$infos = []; |
|
914 |
$dbi->each_table(sub { |
|
915 |
my ($self, $table, $table_info) = @_; |
|
916 |
|
|
917 |
if ($table =~ /^table/) { |
|
918 |
my $info = [$table, $table_info->{TABLE_NAME}]; |
|
919 |
push @$infos, $info; |
|
920 |
} |
|
921 |
}); |
|
922 |
$infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos]; |
|
923 |
is_deeply($infos, |
|
924 |
[ |
|
925 |
['table1', 'table1'], |
|
926 |
['table2', 'table2'], |
|
927 |
] |
|
928 |
); |
|
added auto_filter method
|
929 | |
add examples
|
930 |
test 'limit'; |
931 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
932 |
$dbi->execute($CREATE_TABLE->{0}); |
|
933 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
934 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4}); |
|
935 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 6}); |
|
renamed DBIx::Custom::TagPro...
|
936 |
$dbi->register_tag( |
add examples
|
937 |
limit => sub { |
938 |
my ($count, $offset) = @_; |
|
939 |
|
|
940 |
my $s = ''; |
|
941 |
$s .= "limit $count"; |
|
942 |
$s .= " offset $offset" if defined $offset; |
|
943 |
|
|
944 |
return [$s, []]; |
|
945 |
} |
|
946 |
); |
|
947 |
$rows = $dbi->select( |
|
948 |
table => 'table1', |
|
949 |
where => {key1 => 1}, |
|
950 |
append => "order by key2 {limit 1 0}" |
|
added EXPERIMENTAL select pr...
|
951 |
)->all; |
cleanup
|
952 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
add examples
|
953 |
$rows = $dbi->select( |
954 |
table => 'table1', |
|
955 |
where => {key1 => 1}, |
|
956 |
append => "order by key2 {limit 2 1}" |
|
added EXPERIMENTAL select pr...
|
957 |
)->all; |
cleanup
|
958 |
is_deeply($rows, [{key1 => 1, key2 => 4},{key1 => 1, key2 => 6}]); |
add examples
|
959 |
$rows = $dbi->select( |
960 |
table => 'table1', |
|
961 |
where => {key1 => 1}, |
|
962 |
append => "order by key2 {limit 1}" |
|
added EXPERIMENTAL select pr...
|
963 |
)->all; |
cleanup
|
964 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
added insert, update, update...
|
965 | |
remove DBIx::Custom::Model
|
966 |
test 'connect super'; |
967 |
{ |
|
968 |
package MyDBI; |
|
969 |
|
|
970 |
use base 'DBIx::Custom'; |
|
971 |
sub connect { |
|
972 |
my $self = shift->SUPER::connect(@_); |
|
973 |
|
|
974 |
return $self; |
|
975 |
} |
|
976 |
|
|
977 |
sub new { |
|
cleanup
|
978 |
my $self = shift->SUPER::new(@_); |
remove DBIx::Custom::Model
|
979 |
|
980 |
return $self; |
|
981 |
} |
|
982 |
} |
|
983 | ||
984 |
$dbi = MyDBI->connect($NEW_ARGS->{0}); |
|
985 |
$dbi->execute($CREATE_TABLE->{0}); |
|
986 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
added tests
|
987 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
remove DBIx::Custom::Model
|
988 | |
989 |
$dbi = MyDBI->new($NEW_ARGS->{0}); |
|
cleanup
|
990 |
$dbi->connect; |
remove DBIx::Custom::Model
|
991 |
$dbi->execute($CREATE_TABLE->{0}); |
992 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
added tests
|
993 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
added experimental DBIx::Cus...
|
994 | |
cleanup
|
995 |
{ |
996 |
package MyDBI2; |
|
997 |
|
|
998 |
use base 'DBIx::Custom'; |
|
999 |
sub connect { |
|
1000 |
my $self = shift->SUPER::new(@_); |
|
1001 |
$self->connect; |
|
1002 |
|
|
1003 |
return $self; |
|
1004 |
} |
|
1005 |
} |
|
1006 | ||
1007 |
$dbi = MyDBI->connect($NEW_ARGS->{0}); |
|
1008 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1009 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
added tests
|
1010 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
added experimental DBIx::Cus...
|
1011 | |
1012 |
test 'end_filter'; |
|
1013 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1014 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1015 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1016 |
$result = $dbi->select(table => 'table1'); |
|
1017 |
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 }); |
|
1018 |
$result->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 }); |
|
1019 |
$row = $result->fetch_first; |
|
1020 |
is_deeply($row, [6, 40]); |
|
1021 | ||
all filter can receive array...
|
1022 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1023 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1024 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1025 |
$result = $dbi->select(table => 'table1'); |
|
1026 |
$result->filter([qw/key1 key2/] => sub { $_[0] * 2 }); |
|
1027 |
$result->end_filter([[qw/key1 key2/] => sub { $_[0] * 3 }]); |
|
1028 |
$row = $result->fetch_first; |
|
1029 |
is_deeply($row, [6, 12]); |
|
1030 | ||
1031 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1032 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1033 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1034 |
$result = $dbi->select(table => 'table1'); |
|
1035 |
$result->filter([[qw/key1 key2/] => sub { $_[0] * 2 }]); |
|
1036 |
$result->end_filter([qw/key1 key2/] => sub { $_[0] * 3 }); |
|
1037 |
$row = $result->fetch_first; |
|
1038 |
is_deeply($row, [6, 12]); |
|
1039 | ||
many changed
|
1040 |
$dbi->register_filter(five_times => sub { $_[0] * 5 }); |
added experimental DBIx::Cus...
|
1041 |
$result = $dbi->select(table => 'table1'); |
1042 |
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 }); |
|
many changed
|
1043 |
$result->end_filter({key1 => sub { $_[0] * 3 }, key2 => 'five_times' }); |
added tests
|
1044 |
$row = $result->one; |
added experimental DBIx::Cus...
|
1045 |
is_deeply($row, {key1 => 6, key2 => 40}); |
fix select method empty wher...
|
1046 | |
fix bug : filter can't over...
|
1047 |
$dbi->register_filter(five_times => sub { $_[0] * 5 }); |
1048 |
$dbi->apply_filter('table1', |
|
1049 |
key1 => {end => sub { $_[0] * 3 } }, |
|
1050 |
key2 => {end => 'five_times'} |
|
1051 |
); |
|
1052 |
$result = $dbi->select(table => 'table1'); |
|
1053 |
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 }); |
|
added tests
|
1054 |
$row = $result->one; |
fix bug : filter can't over...
|
1055 |
is_deeply($row, {key1 => 6, key2 => 40}, 'apply_filter'); |
1056 | ||
1057 |
$dbi->register_filter(five_times => sub { $_[0] * 5 }); |
|
1058 |
$dbi->apply_filter('table1', |
|
1059 |
key1 => {end => sub { $_[0] * 3 } }, |
|
1060 |
key2 => {end => 'five_times'} |
|
1061 |
); |
|
1062 |
$result = $dbi->select(table => 'table1'); |
|
1063 |
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 }); |
|
1064 |
$result->filter(key1 => undef); |
|
1065 |
$result->end_filter(key1 => undef); |
|
added tests
|
1066 |
$row = $result->one; |
fix bug : filter can't over...
|
1067 |
is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite'); |
fix select method empty wher...
|
1068 | |
added experimental DBIx::Cus...
|
1069 |
test 'remove_end_filter and remove_filter'; |
added experimental DBIx::Cus...
|
1070 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1071 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1072 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1073 |
$result = $dbi->select(table => 'table1'); |
|
added experimental DBIx::Cus...
|
1074 |
$row = $result |
1075 |
->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 }) |
|
1076 |
->remove_filter |
|
1077 |
->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 }) |
|
added experimental DBIx::Cus...
|
1078 |
->remove_end_filter |
1079 |
->fetch_first; |
|
added experimental DBIx::Cus...
|
1080 |
is_deeply($row, [1, 2]); |
added experimental DBIx::Cus...
|
1081 | |
fix select method empty wher...
|
1082 |
test 'empty where select'; |
1083 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1084 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1085 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1086 |
$result = $dbi->select(table => 'table1', where => {}); |
|
added tests
|
1087 |
$row = $result->one; |
fix select method empty wher...
|
1088 |
is_deeply($row, {key1 => 1, key2 => 2}); |
1089 | ||
added experimental sugar met...
|
1090 |
test 'select query option'; |
1091 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1092 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1093 |
$query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1); |
|
1094 |
is(ref $query, 'DBIx::Custom::Query'); |
|
1095 |
$query = $dbi->update(table => 'table1', where => {key1 => 1}, param => {key2 => 2}, query => 1); |
|
1096 |
is(ref $query, 'DBIx::Custom::Query'); |
|
1097 |
$query = $dbi->delete(table => 'table1', where => {key1 => 1}, query => 1); |
|
1098 |
is(ref $query, 'DBIx::Custom::Query'); |
|
1099 |
$query = $dbi->select(table => 'table1', where => {key1 => 1, key2 => 2}, query => 1); |
|
1100 |
is(ref $query, 'DBIx::Custom::Query'); |
|
1101 | ||
added experimental DBIx::Cus...
|
1102 |
test 'DBIx::Custom::Where'; |
experimental extended select...
|
1103 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1104 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1105 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1106 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
updated pod
|
1107 |
$where = $dbi->where->clause(['and', 'key1 = :key1', 'key2 = :key2']); |
1108 |
is("$where", "where ( key1 = :key1 and key2 = :key2 )", 'no param'); |
|
renamed DBIx::Custom::TagPro...
|
1109 | |
added experimental DBIx::Cus...
|
1110 |
$where = $dbi->where |
updated pod
|
1111 |
->clause(['and', 'key1 = :key1', 'key2 = :key2']) |
added experimental DBIx::Cus...
|
1112 |
->param({key1 => 1}); |
added test
|
1113 | |
experimental extended select...
|
1114 |
$result = $dbi->select( |
1115 |
table => 'table1', |
|
added experimental DBIx::Cus...
|
1116 |
where => $where |
experimental extended select...
|
1117 |
); |
added EXPERIMENTAL select pr...
|
1118 |
$row = $result->all; |
experimental extended select...
|
1119 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
1120 | ||
where can recieve array refr...
|
1121 |
$result = $dbi->select( |
1122 |
table => 'table1', |
|
1123 |
where => [ |
|
updated pod
|
1124 |
['and', 'key1 = :key1', 'key2 = :key2'], |
where can recieve array refr...
|
1125 |
{key1 => 1} |
1126 |
] |
|
1127 |
); |
|
added EXPERIMENTAL select pr...
|
1128 |
$row = $result->all; |
where can recieve array refr...
|
1129 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
1130 | ||
added experimental DBIx::Cus...
|
1131 |
$where = $dbi->where |
updated pod
|
1132 |
->clause(['and', 'key1 = :key1', 'key2 = :key2']) |
added experimental DBIx::Cus...
|
1133 |
->param({key1 => 1, key2 => 2}); |
experimental extended select...
|
1134 |
$result = $dbi->select( |
1135 |
table => 'table1', |
|
added experimental DBIx::Cus...
|
1136 |
where => $where |
experimental extended select...
|
1137 |
); |
added EXPERIMENTAL select pr...
|
1138 |
$row = $result->all; |
experimental extended select...
|
1139 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
1140 | ||
added experimental DBIx::Cus...
|
1141 |
$where = $dbi->where |
updated pod
|
1142 |
->clause(['and', 'key1 = :key1', 'key2 = :key2']) |
added experimental DBIx::Cus...
|
1143 |
->param({}); |
experimental extended select...
|
1144 |
$result = $dbi->select( |
1145 |
table => 'table1', |
|
added experimental DBIx::Cus...
|
1146 |
where => $where, |
experimental extended select...
|
1147 |
); |
added EXPERIMENTAL select pr...
|
1148 |
$row = $result->all; |
experimental extended select...
|
1149 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]); |
1150 | ||
added experimental DBIx::Cus...
|
1151 |
$where = $dbi->where |
updated pod
|
1152 |
->clause(['and', ['or', 'key1 > :key1', 'key1 < :key1'], 'key2 = :key2']) |
added experimental DBIx::Cus...
|
1153 |
->param({key1 => [0, 3], key2 => 2}); |
experimental extended select...
|
1154 |
$result = $dbi->select( |
1155 |
table => 'table1', |
|
added experimental DBIx::Cus...
|
1156 |
where => $where, |
added experimental not_exist...
|
1157 |
); |
added EXPERIMENTAL select pr...
|
1158 |
$row = $result->all; |
experimental extended select...
|
1159 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
1160 | ||
added experimental DBIx::Cus...
|
1161 |
$where = $dbi->where; |
1162 |
$result = $dbi->select( |
|
1163 |
table => 'table1', |
|
1164 |
where => $where |
|
1165 |
); |
|
added EXPERIMENTAL select pr...
|
1166 |
$row = $result->all; |
added experimental DBIx::Cus...
|
1167 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]); |
1168 | ||
experimental extended select...
|
1169 |
eval { |
added experimental DBIx::Cus...
|
1170 |
$where = $dbi->where |
added test
|
1171 |
->clause(['uuu']); |
experimental extended select...
|
1172 |
$result = $dbi->select( |
1173 |
table => 'table1', |
|
added experimental DBIx::Cus...
|
1174 |
where => $where |
experimental extended select...
|
1175 |
); |
1176 |
}; |
|
1177 |
ok($@); |
|
1178 | ||
added experimental DBIx::Cus...
|
1179 |
$where = $dbi->where; |
1180 |
is("$where", ''); |
|
1181 | ||
added test
|
1182 |
$where = $dbi->where |
updated pod
|
1183 |
->clause(['or', ('key1 = :key1') x 2]) |
added test
|
1184 |
->param({key1 => [1, 3]}); |
1185 |
$result = $dbi->select( |
|
1186 |
table => 'table1', |
|
1187 |
where => $where, |
|
1188 |
); |
|
added EXPERIMENTAL select pr...
|
1189 |
$row = $result->all; |
added test
|
1190 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]); |
1191 | ||
1192 |
$where = $dbi->where |
|
updated pod
|
1193 |
->clause(['or', ('key1 = :key1') x 2]) |
added test
|
1194 |
->param({key1 => [1]}); |
1195 |
$result = $dbi->select( |
|
1196 |
table => 'table1', |
|
1197 |
where => $where, |
|
1198 |
); |
|
added EXPERIMENTAL select pr...
|
1199 |
$row = $result->all; |
added test
|
1200 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
1201 | ||
1202 |
$where = $dbi->where |
|
updated pod
|
1203 |
->clause(['or', ('key1 = :key1') x 2]) |
added test
|
1204 |
->param({key1 => 1}); |
1205 |
$result = $dbi->select( |
|
1206 |
table => 'table1', |
|
1207 |
where => $where, |
|
1208 |
); |
|
added EXPERIMENTAL select pr...
|
1209 |
$row = $result->all; |
added test
|
1210 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
added experimental DBIx::Cus...
|
1211 | |
many changed
|
1212 |
$where = $dbi->where |
updated pod
|
1213 |
->clause('key1 = :key1') |
many changed
|
1214 |
->param({key1 => 1}); |
1215 |
$result = $dbi->select( |
|
1216 |
table => 'table1', |
|
1217 |
where => $where, |
|
1218 |
); |
|
added EXPERIMENTAL select pr...
|
1219 |
$row = $result->all; |
many changed
|
1220 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
1221 | ||
1222 |
$where = $dbi->where |
|
updated pod
|
1223 |
->clause('key1 = :key1 key2 = :key2') |
many changed
|
1224 |
->param({key1 => 1}); |
1225 |
eval{$where->to_string}; |
|
1226 |
like($@, qr/one column/); |
|
1227 | ||
added experimental not_exist...
|
1228 |
$where = $dbi->where |
updated pod
|
1229 |
->clause('key1 = :key1') |
added experimental not_exist...
|
1230 |
->param([]); |
1231 |
eval{$where->to_string}; |
|
1232 |
like($@, qr/Parameter/); |
|
1233 | ||
1234 |
$where = $dbi->where |
|
updated pod
|
1235 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1236 |
->param({key1 => [$dbi->not_exists, 1, 3]}); |
1237 |
$result = $dbi->select( |
|
1238 |
table => 'table1', |
|
1239 |
where => $where, |
|
1240 |
); |
|
added EXPERIMENTAL select pr...
|
1241 |
$row = $result->all; |
added experimental not_exist...
|
1242 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1243 | ||
1244 |
$where = $dbi->where |
|
updated pod
|
1245 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1246 |
->param({key1 => [1, $dbi->not_exists, 3]}); |
1247 |
$result = $dbi->select( |
|
1248 |
table => 'table1', |
|
1249 |
where => $where, |
|
1250 |
); |
|
added EXPERIMENTAL select pr...
|
1251 |
$row = $result->all; |
added experimental not_exist...
|
1252 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1253 | ||
1254 |
$where = $dbi->where |
|
updated pod
|
1255 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1256 |
->param({key1 => [1, 3, $dbi->not_exists]}); |
1257 |
$result = $dbi->select( |
|
1258 |
table => 'table1', |
|
1259 |
where => $where, |
|
1260 |
); |
|
added EXPERIMENTAL select pr...
|
1261 |
$row = $result->all; |
added experimental not_exist...
|
1262 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1263 | ||
1264 |
$where = $dbi->where |
|
updated pod
|
1265 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1266 |
->param({key1 => [1, $dbi->not_exists, $dbi->not_exists]}); |
1267 |
$result = $dbi->select( |
|
1268 |
table => 'table1', |
|
1269 |
where => $where, |
|
1270 |
); |
|
added EXPERIMENTAL select pr...
|
1271 |
$row = $result->all; |
added experimental not_exist...
|
1272 |
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists'); |
1273 | ||
1274 |
$where = $dbi->where |
|
updated pod
|
1275 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1276 |
->param({key1 => [$dbi->not_exists, 1, $dbi->not_exists]}); |
1277 |
$result = $dbi->select( |
|
1278 |
table => 'table1', |
|
1279 |
where => $where, |
|
1280 |
); |
|
added EXPERIMENTAL select pr...
|
1281 |
$row = $result->all; |
added experimental not_exist...
|
1282 |
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists'); |
1283 | ||
1284 |
$where = $dbi->where |
|
updated pod
|
1285 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1286 |
->param({key1 => [$dbi->not_exists, $dbi->not_exists, 1]}); |
1287 |
$result = $dbi->select( |
|
1288 |
table => 'table1', |
|
1289 |
where => $where, |
|
1290 |
); |
|
added EXPERIMENTAL select pr...
|
1291 |
$row = $result->all; |
added experimental not_exist...
|
1292 |
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists'); |
1293 | ||
1294 |
$where = $dbi->where |
|
updated pod
|
1295 |
->clause(['or', ('key1 = :key1') x 3]) |
added experimental not_exist...
|
1296 |
->param({key1 => [$dbi->not_exists, $dbi->not_exists, $dbi->not_exists]}); |
1297 |
$result = $dbi->select( |
|
1298 |
table => 'table1', |
|
1299 |
where => $where, |
|
1300 |
); |
|
added EXPERIMENTAL select pr...
|
1301 |
$row = $result->all; |
added experimental not_exist...
|
1302 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1303 | ||
make delete() using where ob...
|
1304 |
$where = $dbi->where |
updated pod
|
1305 |
->clause(['or', ('key1 = :key1') x 3]) |
make delete() using where ob...
|
1306 |
->param({key1 => []}); |
1307 |
$result = $dbi->select( |
|
1308 |
table => 'table1', |
|
1309 |
where => $where, |
|
1310 |
); |
|
added EXPERIMENTAL select pr...
|
1311 |
$row = $result->all; |
make delete() using where ob...
|
1312 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1313 | ||
1314 |
$where = $dbi->where |
|
1315 |
->clause(['and', '{> key1}', '{< key1}' ]) |
|
1316 |
->param({key1 => [2, $dbi->not_exists]}); |
|
1317 |
$result = $dbi->select( |
|
1318 |
table => 'table1', |
|
1319 |
where => $where, |
|
1320 |
); |
|
added EXPERIMENTAL select pr...
|
1321 |
$row = $result->all; |
make delete() using where ob...
|
1322 |
is_deeply($row, [{key1 => 3, key2 => 4}], 'not_exists'); |
1323 | ||
1324 |
$where = $dbi->where |
|
1325 |
->clause(['and', '{> key1}', '{< key1}' ]) |
|
1326 |
->param({key1 => [$dbi->not_exists, 2]}); |
|
1327 |
$result = $dbi->select( |
|
1328 |
table => 'table1', |
|
1329 |
where => $where, |
|
1330 |
); |
|
added EXPERIMENTAL select pr...
|
1331 |
$row = $result->all; |
make delete() using where ob...
|
1332 |
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists'); |
1333 | ||
1334 |
$where = $dbi->where |
|
1335 |
->clause(['and', '{> key1}', '{< key1}' ]) |
|
1336 |
->param({key1 => [$dbi->not_exists, $dbi->not_exists]}); |
|
1337 |
$result = $dbi->select( |
|
1338 |
table => 'table1', |
|
1339 |
where => $where, |
|
1340 |
); |
|
added EXPERIMENTAL select pr...
|
1341 |
$row = $result->all; |
make delete() using where ob...
|
1342 |
is_deeply($row, [{key1 => 1, key2 => 2},{key1 => 3, key2 => 4}], 'not_exists'); |
1343 | ||
1344 |
$where = $dbi->where |
|
1345 |
->clause(['and', '{> key1}', '{< key1}' ]) |
|
1346 |
->param({key1 => [0, 2]}); |
|
1347 |
$result = $dbi->select( |
|
1348 |
table => 'table1', |
|
1349 |
where => $where, |
|
1350 |
); |
|
added EXPERIMENTAL select pr...
|
1351 |
$row = $result->all; |
make delete() using where ob...
|
1352 |
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists'); |
1353 | ||
DBIx::Custom::Where clause a...
|
1354 |
$where = $dbi->where |
1355 |
->clause(['and', 'key1 is not null', 'key2 is not null' ]); |
|
1356 |
$result = $dbi->select( |
|
1357 |
table => 'table1', |
|
1358 |
where => $where, |
|
1359 |
); |
|
added EXPERIMENTAL select pr...
|
1360 |
$row = $result->all; |
DBIx::Custom::Where clause a...
|
1361 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists'); |
1362 | ||
improved error messages
|
1363 |
eval {$dbi->where(ppp => 1) }; |
1364 |
like($@, qr/invalid/); |
|
1365 | ||
fixed DBIx::Custom::Where to...
|
1366 |
$where = $dbi->where( |
1367 |
clause => ['and', ['or'], ['and', 'key1 = :key1', 'key2 = :key2']], |
|
1368 |
param => {key1 => 1, key2 => 2} |
|
1369 |
); |
|
1370 |
$result = $dbi->select( |
|
1371 |
table => 'table1', |
|
1372 |
where => $where, |
|
1373 |
); |
|
1374 |
$row = $result->all; |
|
1375 |
is_deeply($row, [{key1 => 1, key2 => 2}]); |
|
1376 | ||
1377 | ||
1378 |
$where = $dbi->where( |
|
1379 |
clause => ['and', ['or'], ['or', ':key1', ':key2']], |
|
1380 |
param => {} |
|
1381 |
); |
|
1382 |
$result = $dbi->select( |
|
1383 |
table => 'table1', |
|
1384 |
where => $where, |
|
1385 |
); |
|
1386 |
$row = $result->all; |
|
1387 |
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]); |
|
1388 | ||
1389 | ||
renamed dbi_options to dbi_o...
|
1390 |
test 'dbi_option default'; |
added experimental DBIx::Cus...
|
1391 |
$dbi = DBIx::Custom->new; |
renamed dbi_options to dbi_o...
|
1392 |
is_deeply($dbi->dbi_option, {}); |
added experimental DBIx::Cus...
|
1393 | |
added register_tag_processor
|
1394 |
test 'register_tag_processor'; |
1395 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1396 |
$dbi->register_tag_processor( |
|
1397 |
a => sub { 1 } |
|
1398 |
); |
|
1399 |
is($dbi->query_builder->tag_processors->{a}->(), 1); |
|
added experimental DBIx::Cus...
|
1400 | |
renamed DBIx::Custom::TagPro...
|
1401 |
test 'register_tag'; |
1402 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1403 |
$dbi->register_tag( |
|
1404 |
b => sub { 2 } |
|
1405 |
); |
|
1406 |
is($dbi->query_builder->tags->{b}->(), 2); |
|
1407 | ||
added table not specified ex...
|
1408 |
test 'table not specify exception'; |
1409 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1410 |
eval {$dbi->insert}; |
|
1411 |
like($@, qr/table/); |
|
1412 |
eval {$dbi->update}; |
|
1413 |
like($@, qr/table/); |
|
1414 |
eval {$dbi->delete}; |
|
1415 |
like($@, qr/table/); |
|
1416 |
eval {$dbi->select}; |
|
1417 |
like($@, qr/table/); |
|
many changed
|
1418 | |
1419 | ||
1420 |
test 'more tests'; |
|
1421 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1422 |
eval{$dbi->apply_filter('table', 'column', [])}; |
|
1423 |
like($@, qr/apply_filter/); |
|
1424 | ||
1425 |
eval{$dbi->apply_filter('table', 'column', {outer => 2})}; |
|
1426 |
like($@, qr/apply_filter/); |
|
1427 | ||
1428 |
$dbi->apply_filter( |
|
1429 | ||
1430 |
); |
|
1431 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1432 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1433 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1434 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
1435 |
$dbi->apply_filter('table1', 'key2', |
|
1436 |
{in => sub { $_[0] * 3 }, out => sub { $_[0] * 2 }}); |
|
added EXPERIMENTAL select pr...
|
1437 |
$rows = $dbi->select(table => 'table1', where => {key2 => 1})->all; |
many changed
|
1438 |
is_deeply($rows, [{key1 => 1, key2 => 6}]); |
1439 | ||
1440 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1441 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1442 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1443 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
1444 |
$dbi->apply_filter('table1', 'key2', {}); |
|
added EXPERIMENTAL select pr...
|
1445 |
$rows = $dbi->select(table => 'table1', where => {key2 => 2})->all; |
many changed
|
1446 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
1447 | ||
1448 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1449 |
eval {$dbi->apply_filter('table1', 'key2', {out => 'no'})}; |
|
1450 |
like($@, qr/not registered/); |
|
1451 |
eval {$dbi->apply_filter('table1', 'key2', {in => 'no'})}; |
|
1452 |
like($@, qr/not registered/); |
|
renamed helper to method.
|
1453 |
$dbi->method({one => sub { 1 }}); |
many changed
|
1454 |
is($dbi->one, 1); |
1455 | ||
1456 |
eval{DBIx::Custom->connect()}; |
|
cleanup
|
1457 |
like($@, qr/_connect/); |
many changed
|
1458 | |
1459 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1460 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1461 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
|
1462 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, |
|
1463 |
filter => {key1 => 'twice'}); |
|
added tests
|
1464 |
$row = $dbi->select(table => 'table1')->one; |
many changed
|
1465 |
is_deeply($row, {key1 => 2, key2 => 2}); |
1466 |
eval {$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, |
|
1467 |
filter => {key1 => 'no'}) }; |
|
1468 |
like($@, qr//); |
|
1469 | ||
1470 |
$dbi->register_filter(one => sub { }); |
|
1471 |
$dbi->default_fetch_filter('one'); |
|
1472 |
ok($dbi->default_fetch_filter); |
|
1473 |
$dbi->default_bind_filter('one'); |
|
1474 |
ok($dbi->default_bind_filter); |
|
1475 |
eval{$dbi->default_fetch_filter('no')}; |
|
1476 |
like($@, qr/not registered/); |
|
1477 |
eval{$dbi->default_bind_filter('no')}; |
|
1478 |
like($@, qr/not registered/); |
|
1479 |
$dbi->default_bind_filter(undef); |
|
1480 |
ok(!defined $dbi->default_bind_filter); |
|
1481 |
$dbi->default_fetch_filter(undef); |
|
1482 |
ok(!defined $dbi->default_fetch_filter); |
|
- update_param_tag is DEPREC...
|
1483 |
eval {$dbi->execute('select * from table1 {} {= author') }; |
many changed
|
1484 |
like($@, qr/Tag not finished/); |
1485 | ||
1486 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1487 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1488 |
$dbi->register_filter(one => sub { 1 }); |
|
1489 |
$result = $dbi->select(table => 'table1'); |
|
1490 |
eval {$result->filter(key1 => 'no')}; |
|
1491 |
like($@, qr/not registered/); |
|
1492 |
eval {$result->end_filter(key1 => 'no')}; |
|
1493 |
like($@, qr/not registered/); |
|
1494 |
$result->default_filter(undef); |
|
1495 |
ok(!defined $result->default_filter); |
|
1496 |
$result->default_filter('one'); |
|
1497 |
is($result->default_filter->(), 1); |
|
1498 | ||
renamed dbi_options to dbi_o...
|
1499 |
test 'dbi_option'; |
data_source is DEPRECATED! I...
|
1500 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:', |
renamed dbi_options to dbi_o...
|
1501 |
dbi_option => {PrintError => 1}); |
1502 |
ok($dbi->dbh->{PrintError}); |
|
data_source is DEPRECATED! I...
|
1503 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:', |
renamed dbi_options to dbi_o...
|
1504 |
dbi_options => {PrintError => 1}); |
1505 |
ok($dbi->dbh->{PrintError}); |
|
1506 | ||
added experimental DBIx::Cus...
|
1507 |
test 'DBIx::Custom::Result stash()'; |
1508 |
$result = DBIx::Custom::Result->new; |
|
1509 |
is_deeply($result->stash, {}, 'default'); |
|
1510 |
$result->stash->{foo} = 1; |
|
1511 |
is($result->stash->{foo}, 1, 'get and set'); |
|
table object call dbi object...
|
1512 | |
fix bug : filter can't over...
|
1513 |
test 'filter __ expression'; |
1514 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1515 |
$dbi->execute('create table company (id, name, location_id)'); |
|
1516 |
$dbi->execute('create table location (id, name)'); |
|
1517 |
$dbi->apply_filter('location', |
|
1518 |
name => {in => sub { uc $_[0] } } |
|
1519 |
); |
|
1520 | ||
1521 |
$dbi->insert(table => 'company', param => {id => 1, name => 'a', location_id => 2}); |
|
1522 |
$dbi->insert(table => 'location', param => {id => 2, name => 'b'}); |
|
1523 | ||
1524 |
$result = $dbi->select( |
|
1525 |
table => ['company', 'location'], relation => {'company.location_id' => 'location.id'}, |
|
1526 |
column => ['location.name as location__name'] |
|
1527 |
); |
|
1528 |
is($result->fetch_first->[0], 'B'); |
|
1529 | ||
add experimental DBIx::Custo...
|
1530 |
$result = $dbi->select( |
1531 |
table => 'company', relation => {'company.location_id' => 'location.id'}, |
|
1532 |
column => ['location.name as location__name'] |
|
1533 |
); |
|
1534 |
is($result->fetch_first->[0], 'B'); |
|
1535 | ||
added EXPERIMENTAL col metho...
|
1536 |
$result = $dbi->select( |
1537 |
table => 'company', relation => {'company.location_id' => 'location.id'}, |
|
1538 |
column => ['location.name as "location.name"'] |
|
1539 |
); |
|
1540 |
is($result->fetch_first->[0], 'B'); |
|
1541 | ||
add feture. all model class ...
|
1542 |
test 'Model class'; |
removed experimental base_ta...
|
1543 |
use MyDBI1; |
1544 |
$dbi = MyDBI1->connect($NEW_ARGS->{0}); |
|
1545 |
$dbi->execute("create table book (title, author)"); |
|
add feture. all model class ...
|
1546 |
$model = $dbi->model('book'); |
1547 |
$model->insert({title => 'a', author => 'b'}); |
|
added EXPERIMENTAL select pr...
|
1548 |
is_deeply($model->list->all, [{title => 'a', author => 'b'}], 'basic'); |
removed experimental base_ta...
|
1549 |
$dbi->execute("create table company (name)"); |
add feture. all model class ...
|
1550 |
$model = $dbi->model('company'); |
1551 |
$model->insert({name => 'a'}); |
|
added EXPERIMENTAL select pr...
|
1552 |
is_deeply($model->list->all, [{name => 'a'}], 'basic'); |
add models() attribute
|
1553 |
is($dbi->models->{'book'}, $dbi->model('book')); |
1554 |
is($dbi->models->{'company'}, $dbi->model('company')); |
|
removed experimental base_ta...
|
1555 | |
1556 |
{ |
|
1557 |
package MyDBI4; |
|
1558 | ||
1559 |
use strict; |
|
1560 |
use warnings; |
|
1561 | ||
1562 |
use base 'DBIx::Custom'; |
|
1563 | ||
1564 |
sub connect { |
|
1565 |
my $self = shift->SUPER::connect(@_); |
|
1566 |
|
|
add feture. all model class ...
|
1567 |
$self->include_model( |
1568 |
MyModel2 => [ |
|
removed experimental base_ta...
|
1569 |
'book', |
add experimental DBIx::Custo...
|
1570 |
{class => 'Company', name => 'company'} |
removed experimental base_ta...
|
1571 |
] |
1572 |
); |
|
1573 |
} |
|
1574 | ||
add feture. all model class ...
|
1575 |
package MyModel2::Base1; |
removed experimental base_ta...
|
1576 | |
1577 |
use strict; |
|
1578 |
use warnings; |
|
1579 | ||
add feture. all model class ...
|
1580 |
use base 'DBIx::Custom::Model'; |
removed experimental base_ta...
|
1581 | |
add feture. all model class ...
|
1582 |
package MyModel2::book; |
removed experimental base_ta...
|
1583 | |
1584 |
use strict; |
|
1585 |
use warnings; |
|
1586 | ||
add feture. all model class ...
|
1587 |
use base 'MyModel2::Base1'; |
removed experimental base_ta...
|
1588 | |
1589 |
sub insert { |
|
1590 |
my ($self, $param) = @_; |
|
1591 |
|
|
1592 |
return $self->SUPER::insert(param => $param); |
|
1593 |
} |
|
1594 | ||
1595 |
sub list { shift->select; } |
|
1596 | ||
add feture. all model class ...
|
1597 |
package MyModel2::Company; |
removed experimental base_ta...
|
1598 | |
1599 |
use strict; |
|
1600 |
use warnings; |
|
1601 | ||
add feture. all model class ...
|
1602 |
use base 'MyModel2::Base1'; |
removed experimental base_ta...
|
1603 | |
1604 |
sub insert { |
|
1605 |
my ($self, $param) = @_; |
|
1606 |
|
|
1607 |
return $self->SUPER::insert(param => $param); |
|
1608 |
} |
|
1609 | ||
1610 |
sub list { shift->select; } |
|
1611 |
} |
|
1612 |
$dbi = MyDBI4->connect($NEW_ARGS->{0}); |
|
1613 |
$dbi->execute("create table book (title, author)"); |
|
add feture. all model class ...
|
1614 |
$model = $dbi->model('book'); |
1615 |
$model->insert({title => 'a', author => 'b'}); |
|
added EXPERIMENTAL select pr...
|
1616 |
is_deeply($model->list->all, [{title => 'a', author => 'b'}], 'basic'); |
removed experimental base_ta...
|
1617 |
$dbi->execute("create table company (name)"); |
add feture. all model class ...
|
1618 |
$model = $dbi->model('company'); |
1619 |
$model->insert({name => 'a'}); |
|
added EXPERIMENTAL select pr...
|
1620 |
is_deeply($model->list->all, [{name => 'a'}], 'basic'); |
add feture. all model class ...
|
1621 | |
1622 |
{ |
|
1623 |
package MyDBI5; |
|
1624 | ||
1625 |
use strict; |
|
1626 |
use warnings; |
|
1627 | ||
1628 |
use base 'DBIx::Custom'; |
|
1629 | ||
1630 |
sub connect { |
|
1631 |
my $self = shift->SUPER::connect(@_); |
|
1632 |
|
|
1633 |
$self->include_model('MyModel4'); |
|
1634 |
} |
|
1635 |
} |
|
1636 |
$dbi = MyDBI5->connect($NEW_ARGS->{0}); |
|
1637 |
$dbi->execute("create table company (name)"); |
|
- added EXPERIMENTAL type() ...
|
1638 |
$dbi->execute("create table table1 (key1)"); |
add feture. all model class ...
|
1639 |
$model = $dbi->model('company'); |
1640 |
$model->insert({name => 'a'}); |
|
added EXPERIMENTAL select pr...
|
1641 |
is_deeply($model->list->all, [{name => 'a'}], 'include all model'); |
- added EXPERIMENTAL type() ...
|
1642 |
$dbi->insert(table => 'table1', param => {key1 => 1}); |
add feture. all model class ...
|
1643 |
$model = $dbi->model('book'); |
added EXPERIMENTAL select pr...
|
1644 |
is_deeply($model->list->all, [{key1 => 1}], 'include all model'); |
add feture. all model class ...
|
1645 | |
add DBIx::Custom::Model fore...
|
1646 |
test 'primary_key'; |
1647 |
use MyDBI1; |
|
1648 |
$dbi = MyDBI1->connect($NEW_ARGS->{0}); |
|
1649 |
$model = $dbi->model('book'); |
|
1650 |
$model->primary_key(['id', 'number']); |
|
1651 |
is_deeply($model->primary_key, ['id', 'number']); |
|
1652 | ||
add DBIx::Custom::Model colu...
|
1653 |
test 'columns'; |
1654 |
use MyDBI1; |
|
1655 |
$dbi = MyDBI1->connect($NEW_ARGS->{0}); |
|
1656 |
$model = $dbi->model('book'); |
|
1657 |
$model->columns(['id', 'number']); |
|
1658 |
is_deeply($model->columns, ['id', 'number']); |
|
add feture. all model class ...
|
1659 | |
add experimental setup_model...
|
1660 |
test 'setup_model'; |
1661 |
use MyDBI1; |
|
1662 |
$dbi = MyDBI1->connect($NEW_ARGS->{0}); |
|
1663 |
$dbi->execute('create table book (id)'); |
|
1664 |
$dbi->execute('create table company (id, name);'); |
|
1665 |
$dbi->execute('create table test (id, name, primary key (id, name));'); |
|
1666 |
$dbi->setup_model; |
|
1667 |
is_deeply($dbi->model('book')->columns, ['id']); |
|
1668 |
is_deeply($dbi->model('company')->columns, ['id', 'name']); |
|
add experimental update_at()...
|
1669 | |
1670 |
test 'delete_at'; |
|
1671 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1672 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1673 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1674 |
$dbi->delete_at( |
|
1675 |
table => 'table1', |
|
1676 |
primary_key => ['key1', 'key2'], |
|
1677 |
where => [1, 2], |
|
1678 |
); |
|
added EXPERIMENTAL select pr...
|
1679 |
is_deeply($dbi->select(table => 'table1')->all, []); |
add experimental update_at()...
|
1680 | |
1681 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1682 |
$dbi->delete_at( |
|
1683 |
table => 'table1', |
|
1684 |
primary_key => 'key1', |
|
1685 |
where => 1, |
|
1686 |
); |
|
added EXPERIMENTAL select pr...
|
1687 |
is_deeply($dbi->select(table => 'table1')->all, []); |
add experimental update_at()...
|
1688 | |
- added experimental DBIx::C...
|
1689 |
test 'insert_at'; |
1690 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1691 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1692 |
$dbi->insert_at( |
|
1693 |
primary_key => ['key1', 'key2'], |
|
1694 |
table => 'table1', |
|
1695 |
where => [1, 2], |
|
1696 |
param => {key3 => 3} |
|
1697 |
); |
|
added tests
|
1698 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
1699 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
1700 |
is($dbi->select(table => 'table1')->one->{key3}, 3); |
|
- added experimental DBIx::C...
|
1701 | |
1702 |
$dbi->delete_all(table => 'table1'); |
|
add experimental update_at()...
|
1703 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
- added experimental DBIx::C...
|
1704 |
$dbi->insert_at( |
1705 |
primary_key => 'key1', |
|
add experimental update_at()...
|
1706 |
table => 'table1', |
- added experimental DBIx::C...
|
1707 |
where => 1, |
1708 |
param => {key2 => 2, key3 => 3} |
|
add experimental update_at()...
|
1709 |
); |
1710 | ||
added tests
|
1711 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
1712 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
1713 |
is($dbi->select(table => 'table1')->one->{key3}, 3); |
|
- added experimental DBIx::C...
|
1714 | |
1715 |
eval { |
|
1716 |
$dbi->insert_at( |
|
1717 |
table => 'table1', |
|
1718 |
primary_key => ['key1', 'key2'], |
|
1719 |
where => {}, |
|
1720 |
param => {key1 => 1, key2 => 2, key3 => 3}, |
|
1721 |
); |
|
1722 |
}; |
|
1723 |
like($@, qr/must be/); |
|
add experimental update_at()...
|
1724 | |
- insert, insert_at, update,...
|
1725 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1726 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1727 |
$dbi->insert_at( |
|
1728 |
{key3 => 3}, |
|
1729 |
primary_key => ['key1', 'key2'], |
|
1730 |
table => 'table1', |
|
1731 |
where => [1, 2], |
|
1732 |
); |
|
added tests
|
1733 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
1734 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
1735 |
is($dbi->select(table => 'table1')->one->{key3}, 3); |
|
- insert, insert_at, update,...
|
1736 | |
add experimental update_at()...
|
1737 |
test 'update_at'; |
1738 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1739 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1740 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1741 |
$dbi->update_at( |
|
1742 |
table => 'table1', |
|
1743 |
primary_key => ['key1', 'key2'], |
|
1744 |
where => [1, 2], |
|
1745 |
param => {key3 => 4} |
|
1746 |
); |
|
added tests
|
1747 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
1748 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
1749 |
is($dbi->select(table => 'table1')->one->{key3}, 4); |
|
add experimental update_at()...
|
1750 | |
1751 |
$dbi->delete_all(table => 'table1'); |
|
1752 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1753 |
$dbi->update_at( |
|
1754 |
table => 'table1', |
|
1755 |
primary_key => 'key1', |
|
1756 |
where => 1, |
|
1757 |
param => {key3 => 4} |
|
1758 |
); |
|
added tests
|
1759 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
1760 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
1761 |
is($dbi->select(table => 'table1')->one->{key3}, 4); |
|
add experimental update_at()...
|
1762 | |
- insert, insert_at, update,...
|
1763 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1764 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1765 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1766 |
$dbi->update_at( |
|
1767 |
{key3 => 4}, |
|
1768 |
table => 'table1', |
|
1769 |
primary_key => ['key1', 'key2'], |
|
1770 |
where => [1, 2] |
|
1771 |
); |
|
added tests
|
1772 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
1773 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
1774 |
is($dbi->select(table => 'table1')->one->{key3}, 4); |
|
- insert, insert_at, update,...
|
1775 | |
add experimental update_at()...
|
1776 |
test 'select_at'; |
1777 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1778 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1779 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1780 |
$result = $dbi->select_at( |
|
1781 |
table => 'table1', |
|
1782 |
primary_key => ['key1', 'key2'], |
|
1783 |
where => [1, 2] |
|
1784 |
); |
|
added tests
|
1785 |
$row = $result->one; |
add experimental update_at()...
|
1786 |
is($row->{key1}, 1); |
1787 |
is($row->{key2}, 2); |
|
1788 |
is($row->{key3}, 3); |
|
1789 | ||
1790 |
$dbi->delete_all(table => 'table1'); |
|
1791 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1792 |
$result = $dbi->select_at( |
|
1793 |
table => 'table1', |
|
1794 |
primary_key => 'key1', |
|
1795 |
where => 1, |
|
1796 |
); |
|
added tests
|
1797 |
$row = $result->one; |
add experimental update_at()...
|
1798 |
is($row->{key1}, 1); |
1799 |
is($row->{key2}, 2); |
|
1800 |
is($row->{key3}, 3); |
|
1801 | ||
1802 |
$dbi->delete_all(table => 'table1'); |
|
1803 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1804 |
$result = $dbi->select_at( |
|
1805 |
table => 'table1', |
|
1806 |
primary_key => ['key1', 'key2'], |
|
cleanup
|
1807 |
where => [1, 2] |
add experimental update_at()...
|
1808 |
); |
added tests
|
1809 |
$row = $result->one; |
add experimental update_at()...
|
1810 |
is($row->{key1}, 1); |
1811 |
is($row->{key2}, 2); |
|
1812 |
is($row->{key3}, 3); |
|
1813 | ||
- added experimental DBIx::C...
|
1814 |
eval { |
1815 |
$result = $dbi->select_at( |
|
1816 |
table => 'table1', |
|
1817 |
primary_key => ['key1', 'key2'], |
|
1818 |
where => {}, |
|
1819 |
); |
|
1820 |
}; |
|
1821 |
like($@, qr/must be/); |
|
1822 | ||
improved error messages
|
1823 |
eval { |
1824 |
$result = $dbi->select_at( |
|
1825 |
table => 'table1', |
|
1826 |
primary_key => ['key1', 'key2'], |
|
1827 |
where => [1], |
|
1828 |
); |
|
1829 |
}; |
|
1830 |
like($@, qr/same/); |
|
1831 | ||
- added experimental DBIx::C...
|
1832 |
eval { |
1833 |
$result = $dbi->update_at( |
|
1834 |
table => 'table1', |
|
1835 |
primary_key => ['key1', 'key2'], |
|
1836 |
where => {}, |
|
1837 |
param => {key1 => 1, key2 => 2}, |
|
1838 |
); |
|
1839 |
}; |
|
1840 |
like($@, qr/must be/); |
|
1841 | ||
1842 |
eval { |
|
1843 |
$result = $dbi->delete_at( |
|
1844 |
table => 'table1', |
|
1845 |
primary_key => ['key1', 'key2'], |
|
1846 |
where => {}, |
|
1847 |
); |
|
1848 |
}; |
|
1849 |
like($@, qr/must be/); |
|
add experimental update_at()...
|
1850 | |
add experimental DBIx::Custo...
|
1851 |
test 'columns'; |
1852 |
use MyDBI1; |
|
1853 |
$dbi = MyDBI1->connect($NEW_ARGS->{0}); |
|
1854 |
$model = $dbi->model('book'); |
|
add experimental DBIx::Custo...
|
1855 | |
1856 | ||
1857 |
test 'model delete_at'; |
|
1858 |
{ |
|
1859 |
package MyDBI6; |
|
1860 |
|
|
1861 |
use base 'DBIx::Custom'; |
|
1862 |
|
|
1863 |
sub connect { |
|
1864 |
my $self = shift->SUPER::connect(@_); |
|
1865 |
|
|
1866 |
$self->include_model('MyModel5'); |
|
1867 |
|
|
1868 |
return $self; |
|
1869 |
} |
|
1870 |
} |
|
1871 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
|
1872 |
$dbi->execute($CREATE_TABLE->{1}); |
|
- added EXPERIMENTAL type() ...
|
1873 |
$dbi->execute("create table table2 (key1, key2, key3)"); |
1874 |
$dbi->execute("create table table3 (key1, key2, key3)"); |
|
add experimental DBIx::Custo...
|
1875 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
1876 |
$dbi->model('table1')->delete_at(where => [1, 2]); |
|
added EXPERIMENTAL select pr...
|
1877 |
is_deeply($dbi->select(table => 'table1')->all, []); |
- added EXPERIMENTAL type() ...
|
1878 |
$dbi->insert(table => 'table2', param => {key1 => 1, key2 => 2, key3 => 3}); |
add experimental DBIx::Custo...
|
1879 |
$dbi->model('table1_1')->delete_at(where => [1, 2]); |
added EXPERIMENTAL select pr...
|
1880 |
is_deeply($dbi->select(table => 'table1')->all, []); |
- added EXPERIMENTAL type() ...
|
1881 |
$dbi->insert(table => 'table3', param => {key1 => 1, key2 => 2, key3 => 3}); |
add experimental DBIx::Custo...
|
1882 |
$dbi->model('table1_3')->delete_at(where => [1, 2]); |
added EXPERIMENTAL select pr...
|
1883 |
is_deeply($dbi->select(table => 'table1')->all, []); |
add experimental DBIx::Custo...
|
1884 | |
- added experimental DBIx::C...
|
1885 |
test 'model insert_at'; |
1886 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
|
1887 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1888 |
$dbi->model('table1')->insert_at( |
|
1889 |
where => [1, 2], |
|
1890 |
param => {key3 => 3} |
|
1891 |
); |
|
1892 |
$result = $dbi->model('table1')->select; |
|
added tests
|
1893 |
$row = $result->one; |
- added experimental DBIx::C...
|
1894 |
is($row->{key1}, 1); |
1895 |
is($row->{key2}, 2); |
|
1896 |
is($row->{key3}, 3); |
|
add experimental DBIx::Custo...
|
1897 | |
- added experimental DBIx::C...
|
1898 |
test 'model update_at'; |
add experimental DBIx::Custo...
|
1899 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
1900 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1901 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1902 |
$dbi->model('table1')->update_at( |
|
1903 |
where => [1, 2], |
|
1904 |
param => {key3 => 4} |
|
1905 |
); |
|
1906 |
$result = $dbi->model('table1')->select; |
|
added tests
|
1907 |
$row = $result->one; |
add experimental DBIx::Custo...
|
1908 |
is($row->{key1}, 1); |
1909 |
is($row->{key2}, 2); |
|
1910 |
is($row->{key3}, 4); |
|
1911 | ||
- added experimental DBIx::C...
|
1912 |
test 'model select_at'; |
add experimental DBIx::Custo...
|
1913 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
1914 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1915 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
1916 |
$result = $dbi->model('table1')->select_at(where => [1, 2]); |
|
added tests
|
1917 |
$row = $result->one; |
add experimental DBIx::Custo...
|
1918 |
is($row->{key1}, 1); |
1919 |
is($row->{key2}, 2); |
|
1920 |
is($row->{key3}, 3); |
|
DBIx::Custom::Model select()...
|
1921 | |
1922 | ||
cleanup
|
1923 |
test 'mycolumn and column'; |
DBIx::Custom::Model select()...
|
1924 |
{ |
1925 |
package MyDBI7; |
|
1926 |
|
|
1927 |
use base 'DBIx::Custom'; |
|
1928 |
|
|
1929 |
sub connect { |
|
1930 |
my $self = shift->SUPER::connect(@_); |
|
1931 |
|
|
1932 |
$self->include_model('MyModel6'); |
|
1933 |
|
|
add experimental DBIx::Custo...
|
1934 |
|
DBIx::Custom::Model select()...
|
1935 |
return $self; |
1936 |
} |
|
1937 |
} |
|
1938 |
$dbi = MyDBI7->connect($NEW_ARGS->{0}); |
|
1939 |
$dbi->execute($CREATE_TABLE->{0}); |
|
1940 |
$dbi->execute($CREATE_TABLE->{2}); |
|
EXPERIMTANL column method th...
|
1941 |
$dbi->separator('__'); |
add experimental DBIx::Custo...
|
1942 |
$dbi->setup_model; |
1943 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
1944 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3}); |
|
1945 |
$model = $dbi->model('table1'); |
|
cleanup
|
1946 |
$result = $model->select( |
1947 |
column => [$model->mycolumn, $model->column('table2')], |
|
1948 |
where => {'table1.key1' => 1} |
|
1949 |
); |
|
added tests
|
1950 |
is_deeply($result->one, |
cleanup
|
1951 |
{key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3}); |
add experimental DBIx::Custo...
|
1952 | |
- update_param_tag is DEPREC...
|
1953 |
test 'update_param'; |
added experimental update_pa...
|
1954 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1955 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1956 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
1957 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
1958 | ||
1959 |
$param = {key2 => 11}; |
|
- update_param_tag is DEPREC...
|
1960 |
$update_param = $dbi->update_param($param); |
added experimental update_pa...
|
1961 |
$sql = <<"EOS"; |
- update_param_tag is DEPREC...
|
1962 |
update table1 $update_param |
added experimental update_pa...
|
1963 |
where key1 = 1 |
1964 |
EOS |
|
1965 |
$dbi->execute($sql, param => $param); |
|
- update_param_tag is DEPREC...
|
1966 |
$result = $dbi->execute($SELECT_SOURCES->{0}, table => 'table1'); |
added EXPERIMENTAL select pr...
|
1967 |
$rows = $result->all; |
added experimental update_pa...
|
1968 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5}, |
1969 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
1970 |
"basic"); |
|
1971 | ||
1972 | ||
added EXPERIMENTAL updat_par...
|
1973 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
1974 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1975 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
1976 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
1977 | ||
1978 |
$param = {key2 => 11, key3 => 33}; |
|
- update_param_tag is DEPREC...
|
1979 |
$update_param = $dbi->update_param($param); |
added EXPERIMENTAL updat_par...
|
1980 |
$sql = <<"EOS"; |
- update_param_tag is DEPREC...
|
1981 |
update table1 $update_param |
added EXPERIMENTAL updat_par...
|
1982 |
where key1 = 1 |
1983 |
EOS |
|
1984 |
$dbi->execute($sql, param => $param); |
|
- update_param_tag is DEPREC...
|
1985 |
$result = $dbi->execute($SELECT_SOURCES->{0}, table => 'table1'); |
added EXPERIMENTAL select pr...
|
1986 |
$rows = $result->all; |
added EXPERIMENTAL updat_par...
|
1987 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5}, |
1988 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
1989 |
"basic"); |
|
1990 | ||
1991 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
1992 |
$dbi->execute($CREATE_TABLE->{1}); |
|
1993 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
1994 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
1995 | ||
1996 |
$param = {key2 => 11, key3 => 33}; |
|
- update_param_tag is DEPREC...
|
1997 |
$update_param = $dbi->update_param($param, {no_set => 1}); |
added EXPERIMENTAL updat_par...
|
1998 |
$sql = <<"EOS"; |
- update_param_tag is DEPREC...
|
1999 |
update table1 set $update_param |
added EXPERIMENTAL updat_par...
|
2000 |
where key1 = 1 |
2001 |
EOS |
|
2002 |
$dbi->execute($sql, param => $param); |
|
- update_param_tag is DEPREC...
|
2003 |
$result = $dbi->execute($SELECT_SOURCES->{0}, table => 'table1'); |
added EXPERIMENTAL select pr...
|
2004 |
$rows = $result->all; |
added EXPERIMENTAL updat_par...
|
2005 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5}, |
2006 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
2007 |
"update param no_set"); |
|
2008 | ||
2009 |
|
|
- update_param_tag is DEPREC...
|
2010 |
eval { $dbi->update_param({";" => 1}) }; |
added experimental update_pa...
|
2011 |
like($@, qr/not safety/); |
2012 | ||
2013 | ||
- update_param_tag is DEPREC...
|
2014 |
test 'update_param'; |
added EXPERIMENTAL assign_ta...
|
2015 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
2016 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2017 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}); |
|
2018 |
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}); |
|
2019 | ||
2020 |
$param = {key2 => 11}; |
|
- update_param_tag is DEPREC...
|
2021 |
$update_param = $dbi->assign_param($param); |
added EXPERIMENTAL assign_ta...
|
2022 |
$sql = <<"EOS"; |
- update_param_tag is DEPREC...
|
2023 |
update table1 set $update_param |
added EXPERIMENTAL assign_ta...
|
2024 |
where key1 = 1 |
2025 |
EOS |
|
- update_param_tag is DEPREC...
|
2026 |
$dbi->execute($sql, param => $param, table => 'table1'); |
added EXPERIMENTAL assign_ta...
|
2027 |
$result = $dbi->execute($SELECT_SOURCES->{0}); |
added EXPERIMENTAL select pr...
|
2028 |
$rows = $result->all; |
added EXPERIMENTAL assign_ta...
|
2029 |
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5}, |
2030 |
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], |
|
2031 |
"basic"); |
|
2032 | ||
2033 | ||
added experimental update_pa...
|
2034 |
test 'insert_param'; |
2035 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2036 |
$dbi->execute($CREATE_TABLE->{1}); |
|
added EXPERIMENTAL updat_par...
|
2037 |
$param = {key1 => 1, key2 => 2}; |
- update_param_tag is DEPREC...
|
2038 |
$insert_param = $dbi->insert_param($param); |
added experimental update_pa...
|
2039 |
$sql = <<"EOS"; |
- update_param_tag is DEPREC...
|
2040 |
insert into table1 $insert_param |
added experimental update_pa...
|
2041 |
EOS |
- update_param_tag is DEPREC...
|
2042 |
$dbi->execute($sql, param => $param, table => 'table1'); |
added tests
|
2043 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
2044 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
added experimental update_pa...
|
2045 | |
added EXPERIMENTAL updat_par...
|
2046 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
reserved_word_quote is DEPRE...
|
2047 |
$dbi->quote('"'); |
added EXPERIMENTAL updat_par...
|
2048 |
$dbi->execute($CREATE_TABLE->{1}); |
2049 |
$param = {key1 => 1, key2 => 2}; |
|
- update_param_tag is DEPREC...
|
2050 |
$insert_param = $dbi->insert_param($param); |
added EXPERIMENTAL updat_par...
|
2051 |
$sql = <<"EOS"; |
- update_param_tag is DEPREC...
|
2052 |
insert into table1 $insert_param |
added EXPERIMENTAL updat_par...
|
2053 |
EOS |
- update_param_tag is DEPREC...
|
2054 |
$dbi->execute($sql, param => $param, table => 'table1'); |
added tests
|
2055 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
2056 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
add experimental DBIx::Custo...
|
2057 | |
- update_param_tag is DEPREC...
|
2058 |
eval { $dbi->insert_param({";" => 1}) }; |
added experimental update_pa...
|
2059 |
like($@, qr/not safety/); |
cleanup
|
2060 | |
2061 | ||
- added experimental DBIx::C...
|
2062 |
test 'join'; |
cleanup
|
2063 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
2064 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2065 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2066 |
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4}); |
|
2067 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2068 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5}); |
|
- added experimental DBIx::C...
|
2069 |
$dbi->execute($CREATE_TABLE->{4}); |
2070 |
$dbi->insert(table => 'table3', param => {key3 => 5, key4 => 4}); |
|
cleanup
|
2071 |
$rows = $dbi->select( |
2072 |
table => 'table1', |
|
2073 |
column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3', |
|
2074 |
where => {'table1.key2' => 2}, |
|
- added experimental DBIx::C...
|
2075 |
join => ['left outer join table2 on table1.key1 = table2.key1'] |
added EXPERIMENTAL select pr...
|
2076 |
)->all; |
cleanup
|
2077 |
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}]); |
2078 | ||
- added experimental DBIx::C...
|
2079 |
$rows = $dbi->select( |
2080 |
table => 'table1', |
|
2081 |
where => {'key1' => 1}, |
|
2082 |
join => ['left outer join table2 on table1.key1 = table2.key1'] |
|
added EXPERIMENTAL select pr...
|
2083 |
)->all; |
- added experimental DBIx::C...
|
2084 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
2085 | ||
cleanup
|
2086 |
eval { |
2087 |
$rows = $dbi->select( |
|
2088 |
table => 'table1', |
|
2089 |
column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3', |
|
2090 |
where => {'table1.key2' => 2}, |
|
- added experimental DBIx::C...
|
2091 |
join => {'table1.key1' => 'table2.key1'} |
cleanup
|
2092 |
); |
2093 |
}; |
|
2094 |
like ($@, qr/array/); |
|
- added experimental DBIx::C...
|
2095 | |
2096 |
$rows = $dbi->select( |
|
2097 |
table => 'table1', |
|
2098 |
where => {'key1' => 1}, |
|
2099 |
join => ['left outer join table2 on table1.key1 = table2.key1', |
|
2100 |
'left outer join table3 on table2.key3 = table3.key3'] |
|
added EXPERIMENTAL select pr...
|
2101 |
)->all; |
- added experimental DBIx::C...
|
2102 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
2103 | ||
2104 |
$rows = $dbi->select( |
|
2105 |
column => 'table3.key4 as table3__key4', |
|
2106 |
table => 'table1', |
|
2107 |
where => {'table1.key1' => 1}, |
|
2108 |
join => ['left outer join table2 on table1.key1 = table2.key1', |
|
2109 |
'left outer join table3 on table2.key3 = table3.key3'] |
|
added EXPERIMENTAL select pr...
|
2110 |
)->all; |
- added experimental DBIx::C...
|
2111 |
is_deeply($rows, [{table3__key4 => 4}]); |
2112 | ||
2113 |
$rows = $dbi->select( |
|
2114 |
column => 'table1.key1 as table1__key1', |
|
2115 |
table => 'table1', |
|
2116 |
where => {'table3.key4' => 4}, |
|
2117 |
join => ['left outer join table2 on table1.key1 = table2.key1', |
|
2118 |
'left outer join table3 on table2.key3 = table3.key3'] |
|
added EXPERIMENTAL select pr...
|
2119 |
)->all; |
- added experimental DBIx::C...
|
2120 |
is_deeply($rows, [{table1__key1 => 1}]); |
- added experimental DBIx::C...
|
2121 | |
added EXPERIMENTAL reserved_...
|
2122 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
reserved_word_quote is DEPRE...
|
2123 |
$dbi->quote('"'); |
added EXPERIMENTAL reserved_...
|
2124 |
$dbi->execute($CREATE_TABLE->{0}); |
2125 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2126 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2127 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5}); |
|
2128 |
$rows = $dbi->select( |
|
2129 |
table => 'table1', |
|
2130 |
column => '"table1"."key1" as "table1_key1", "table2"."key1" as "table2_key1", "key2", "key3"', |
|
2131 |
where => {'table1.key2' => 2}, |
|
2132 |
join => ['left outer join "table2" on "table1"."key1" = "table2"."key1"'], |
|
added EXPERIMENTAL select pr...
|
2133 |
)->all; |
added EXPERIMENTAL reserved_...
|
2134 |
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], |
reserved_word_quote is DEPRE...
|
2135 |
'quote'); |
- added experimental DBIx::C...
|
2136 | |
2137 |
{ |
|
2138 |
package MyDBI8; |
|
2139 |
|
|
2140 |
use base 'DBIx::Custom'; |
|
2141 |
|
|
2142 |
sub connect { |
|
2143 |
my $self = shift->SUPER::connect(@_); |
|
2144 |
|
|
2145 |
$self->include_model('MyModel7'); |
|
2146 |
|
|
2147 |
return $self; |
|
2148 |
} |
|
2149 |
} |
|
added select() all_column op...
|
2150 | |
data_source is DEPRECATED! I...
|
2151 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
2152 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2153 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2154 |
$sql = <<"EOS"; |
|
2155 |
left outer join ( |
|
2156 |
select * from table1 as t1 |
|
2157 |
where t1.key2 = ( |
|
2158 |
select max(t2.key2) from table1 as t2 |
|
2159 |
where t1.key1 = t2.key1 |
|
2160 |
) |
|
2161 |
) as latest_table1 on table1.key1 = latest_table1.key1 |
|
2162 |
EOS |
|
2163 |
$join = [$sql]; |
|
2164 |
$rows = $dbi->select( |
|
2165 |
table => 'table1', |
|
2166 |
column => 'latest_table1.key1 as latest_table1__key1', |
|
2167 |
join => $join |
|
added EXPERIMENTAL select pr...
|
2168 |
)->all; |
data_source is DEPRECATED! I...
|
2169 |
is_deeply($rows, [{latest_table1__key1 => 1}]); |
2170 | ||
- added EXPERIMENTAL DBIx::C...
|
2171 |
test 'mycolumn'; |
2172 |
$dbi = MyDBI8->connect($NEW_ARGS->{0}); |
|
- added EXPERIMENTAL DBIx::C...
|
2173 |
$dbi->execute($CREATE_TABLE->{0}); |
- added EXPERIMENTAL DBIx::C...
|
2174 |
$dbi->execute($CREATE_TABLE->{2}); |
2175 |
$dbi->setup_model; |
|
2176 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2177 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3}); |
|
2178 |
$model = $dbi->model('table1'); |
|
2179 |
$result = $model->select_at( |
|
2180 |
column => [ |
|
2181 |
$model->mycolumn, |
|
2182 |
$model->column('table2') |
|
2183 |
] |
|
- added EXPERIMENTAL DBIx::C...
|
2184 |
); |
added tests
|
2185 |
is_deeply($result->one, |
EXPERIMTANL column method th...
|
2186 |
{key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3}); |
- select() column option can...
|
2187 | |
- added EXPERIMENTAL DBIx::C...
|
2188 |
$result = $model->select_at( |
2189 |
column => [ |
|
2190 |
$model->mycolumn(['key1']), |
|
2191 |
$model->column(table2 => ['key1']) |
|
2192 |
] |
|
2193 |
); |
|
added tests
|
2194 |
is_deeply($result->one, |
EXPERIMTANL column method th...
|
2195 |
{key1 => 1, 'table2.key1' => 1}); |
- select() column option can...
|
2196 |
$result = $model->select_at( |
2197 |
column => [ |
|
2198 |
$model->mycolumn(['key1']), |
|
2199 |
{table2 => ['key1']} |
|
2200 |
] |
|
2201 |
); |
|
added tests
|
2202 |
is_deeply($result->one, |
- select() EXPERIMETNAL colu...
|
2203 |
{key1 => 1, 'table2.key1' => 1}); |
- select() column option can...
|
2204 | |
- select() column option can...
|
2205 |
$result = $model->select_at( |
2206 |
column => [ |
|
2207 |
$model->mycolumn(['key1']), |
|
2208 |
['table2.key1', as => 'table2.key1'] |
|
2209 |
] |
|
2210 |
); |
|
2211 |
is_deeply($result->one, |
|
2212 |
{key1 => 1, 'table2.key1' => 1}); |
|
2213 | ||
- select method column optio...
|
2214 |
$result = $model->select_at( |
2215 |
column => [ |
|
2216 |
$model->mycolumn(['key1']), |
|
2217 |
['table2.key1' => 'table2.key1'] |
|
2218 |
] |
|
2219 |
); |
|
2220 |
is_deeply($result->one, |
|
2221 |
{key1 => 1, 'table2.key1' => 1}); |
|
- select() column option can...
|
2222 | |
- added EXPERIMENTAL DBIx::C...
|
2223 |
test 'dbi method from model'; |
- added EXPERIMENTAL DBIx::C...
|
2224 |
{ |
2225 |
package MyDBI9; |
|
2226 |
|
|
2227 |
use base 'DBIx::Custom'; |
|
2228 |
|
|
2229 |
sub connect { |
|
2230 |
my $self = shift->SUPER::connect(@_); |
|
2231 |
|
|
2232 |
$self->include_model('MyModel8')->setup_model; |
|
2233 |
|
|
2234 |
return $self; |
|
2235 |
} |
|
2236 |
} |
|
2237 |
$dbi = MyDBI9->connect($NEW_ARGS->{0}); |
|
2238 |
$dbi->execute($CREATE_TABLE->{0}); |
|
- added EXPERIMENTAL DBIx::C...
|
2239 |
$model = $dbi->model('table1'); |
2240 |
eval{$model->execute('select * from table1')}; |
|
2241 |
ok(!$@); |
|
2242 | ||
- DBIx::Custom Model filter ...
|
2243 |
test 'column table option'; |
- added EXPERIMENTAL DBIx::C...
|
2244 |
$dbi = MyDBI9->connect($NEW_ARGS->{0}); |
2245 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2246 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2247 |
$dbi->setup_model; |
|
2248 |
$dbi->execute('insert into table1 (key1, key2) values (1, 2);'); |
|
2249 |
$dbi->execute('insert into table2 (key1, key3) values (1, 4);'); |
|
2250 |
$model = $dbi->model('table1'); |
|
2251 |
$result = $model->select( |
|
2252 |
column => [ |
|
- DBIx::Custom Model filter ...
|
2253 |
$model->column('table2', {alias => 'table2_alias'}) |
- added EXPERIMENTAL DBIx::C...
|
2254 |
], |
- DBIx::Custom Model filter ...
|
2255 |
where => {'table2_alias.key3' => 4} |
- added EXPERIMENTAL DBIx::C...
|
2256 |
); |
added tests
|
2257 |
is_deeply($result->one, |
- DBIx::Custom Model filter ...
|
2258 |
{'table2_alias.key1' => 1, 'table2_alias.key3' => 4}); |
- added EXPERIMENTAL DBIx::C...
|
2259 | |
cleanup
|
2260 |
$dbi->separator('__'); |
2261 |
$result = $model->select( |
|
2262 |
column => [ |
|
- DBIx::Custom Model filter ...
|
2263 |
$model->column('table2', {alias => 'table2_alias'}) |
cleanup
|
2264 |
], |
- DBIx::Custom Model filter ...
|
2265 |
where => {'table2_alias.key3' => 4} |
cleanup
|
2266 |
); |
2267 |
is_deeply($result->one, |
|
- DBIx::Custom Model filter ...
|
2268 |
{'table2_alias__key1' => 1, 'table2_alias__key3' => 4}); |
cleanup
|
2269 | |
2270 |
$dbi->separator('-'); |
|
2271 |
$result = $model->select( |
|
2272 |
column => [ |
|
- DBIx::Custom Model filter ...
|
2273 |
$model->column('table2', {alias => 'table2_alias'}) |
cleanup
|
2274 |
], |
- DBIx::Custom Model filter ...
|
2275 |
where => {'table2_alias.key3' => 4} |
cleanup
|
2276 |
); |
2277 |
is_deeply($result->one, |
|
- DBIx::Custom Model filter ...
|
2278 |
{'table2_alias-key1' => 1, 'table2_alias-key3' => 4}); |
cleanup
|
2279 | |
DBIx::Custom::Model type att...
|
2280 |
test 'type option'; # DEPRECATED! |
- added EXPERIMENTAL type() ...
|
2281 |
$dbi = DBIx::Custom->connect( |
2282 |
data_source => 'dbi:SQLite:dbname=:memory:', |
|
2283 |
dbi_option => { |
|
2284 |
$DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1) |
|
2285 |
} |
|
2286 |
); |
|
2287 |
my $binary = pack("I3", 1, 2, 3); |
|
2288 |
$dbi->execute('create table table1(key1, key2)'); |
|
2289 |
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, type => [key1 => DBI::SQL_BLOB]); |
|
2290 |
$result = $dbi->select(table => 'table1'); |
|
added tests
|
2291 |
$row = $result->one; |
- added EXPERIMENTAL type() ...
|
2292 |
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic"); |
2293 |
$result = $dbi->execute('select length(key1) as key1_length from table1'); |
|
added tests
|
2294 |
$row = $result->one; |
- added EXPERIMENTAL type() ...
|
2295 |
is($row->{key1_length}, length $binary); |
2296 | ||
2297 |
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, type => [['key1'] => DBI::SQL_BLOB]); |
|
2298 |
$result = $dbi->select(table => 'table1'); |
|
added tests
|
2299 |
$row = $result->one; |
- added EXPERIMENTAL type() ...
|
2300 |
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic"); |
2301 |
$result = $dbi->execute('select length(key1) as key1_length from table1'); |
|
DBIx::Custom::Model type att...
|
2302 |
$row = $result->one; |
2303 |
is($row->{key1_length}, length $binary); |
|
2304 | ||
2305 | ||
2306 |
test 'bind_type option'; |
|
2307 |
$dbi = DBIx::Custom->connect( |
|
2308 |
data_source => 'dbi:SQLite:dbname=:memory:', |
|
2309 |
dbi_option => { |
|
2310 |
$DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1) |
|
2311 |
} |
|
2312 |
); |
|
2313 |
$binary = pack("I3", 1, 2, 3); |
|
2314 |
$dbi->execute('create table table1(key1, key2)'); |
|
2315 |
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, bind_type => [key1 => DBI::SQL_BLOB]); |
|
2316 |
$result = $dbi->select(table => 'table1'); |
|
2317 |
$row = $result->one; |
|
2318 |
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic"); |
|
2319 |
$result = $dbi->execute('select length(key1) as key1_length from table1'); |
|
2320 |
$row = $result->one; |
|
2321 |
is($row->{key1_length}, length $binary); |
|
2322 | ||
2323 |
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, bind_type => [['key1'] => DBI::SQL_BLOB]); |
|
2324 |
$result = $dbi->select(table => 'table1'); |
|
2325 |
$row = $result->one; |
|
2326 |
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic"); |
|
2327 |
$result = $dbi->execute('select length(key1) as key1_length from table1'); |
|
2328 |
$row = $result->one; |
|
2329 |
is($row->{key1_length}, length $binary); |
|
2330 | ||
2331 |
test 'model type attribute'; |
|
2332 |
$dbi = DBIx::Custom->connect( |
|
2333 |
data_source => 'dbi:SQLite:dbname=:memory:', |
|
2334 |
dbi_option => { |
|
2335 |
$DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1) |
|
2336 |
} |
|
2337 |
); |
|
2338 |
$binary = pack("I3", 1, 2, 3); |
|
2339 |
$dbi->execute('create table table1(key1, key2)'); |
|
2340 |
$model = $dbi->create_model(table => 'table1', bind_type => [key1 => DBI::SQL_BLOB]); |
|
2341 |
$model->insert(param => {key1 => $binary, key2 => 'あ'}); |
|
2342 |
$result = $dbi->select(table => 'table1'); |
|
2343 |
$row = $result->one; |
|
2344 |
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic"); |
|
2345 |
$result = $dbi->execute('select length(key1) as key1_length from table1'); |
|
added tests
|
2346 |
$row = $result->one; |
- added EXPERIMENTAL type() ...
|
2347 |
is($row->{key1_length}, length $binary); |
2348 | ||
removed EXPERIMETNAL flag fr...
|
2349 |
test 'create_model'; |
2350 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2351 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2352 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2353 | ||
2354 |
$dbi->create_model( |
|
2355 |
table => 'table1', |
|
2356 |
join => [ |
|
2357 |
'left outer join table2 on table1.key1 = table2.key1' |
|
2358 |
], |
|
2359 |
primary_key => ['key1'] |
|
2360 |
); |
|
create_model() return model
|
2361 |
$model2 = $dbi->create_model( |
removed EXPERIMETNAL flag fr...
|
2362 |
table => 'table2' |
2363 |
); |
|
2364 |
$dbi->create_model( |
|
2365 |
table => 'table3', |
|
2366 |
filter => [ |
|
2367 |
key1 => {in => sub { uc $_[0] }} |
|
2368 |
] |
|
2369 |
); |
|
2370 |
$dbi->setup_model; |
|
2371 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2372 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3}); |
|
2373 |
$model = $dbi->model('table1'); |
|
2374 |
$result = $model->select( |
|
2375 |
column => [$model->mycolumn, $model->column('table2')], |
|
2376 |
where => {'table1.key1' => 1} |
|
2377 |
); |
|
added tests
|
2378 |
is_deeply($result->one, |
EXPERIMTANL column method th...
|
2379 |
{key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3}); |
added tests
|
2380 |
is_deeply($model2->select->one, {key1 => 1, key3 => 3}); |
removed EXPERIMETNAL flag fr...
|
2381 | |
adeed EXPERIMENTAL DBIx::Cus...
|
2382 |
test 'model method'; |
2383 |
test 'create_model'; |
|
2384 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2385 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2386 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3}); |
|
2387 |
$model = $dbi->create_model( |
|
2388 |
table => 'table2' |
|
2389 |
); |
|
2390 |
$model->method(foo => sub { shift->select(@_) }); |
|
added tests
|
2391 |
is_deeply($model->foo->one, {key1 => 1, key3 => 3}); |
added EXPERIMENTAL updat_par...
|
2392 | |
2393 |
test 'merge_param'; |
|
2394 |
{ |
|
2395 |
my $dbi = DBIx::Custom->new; |
|
2396 |
my $param1 = {key1 => 1, key2 => 2, key3 => 3}; |
|
2397 |
my $param2 = {key1 => 1, key2 => 2}; |
|
2398 |
my $param3 = {key1 => 1}; |
|
2399 |
my $param = $dbi->merge_param($param1, $param2, $param3); |
|
2400 |
is_deeply($param, {key1 => [1, 1, 1], key2 => [2, 2], key3 => 3}); |
|
cleanup
|
2401 |
} |
2402 | ||
fixed merge_param bug
|
2403 |
{ |
2404 |
my $dbi = DBIx::Custom->new; |
|
2405 |
my $param1 = {key1 => [1, 2], key2 => 1, key3 => [1, 2]}; |
|
2406 |
my $param2 = {key1 => [3, 4], key2 => [2, 3], key3 => 3}; |
|
2407 |
my $param = $dbi->merge_param($param1, $param2); |
|
2408 |
is_deeply($param, {key1 => [1, 2, 3, 4], key2 => [1, 2, 3], key3 => [1, 2, 3]}); |
|
2409 |
} |
|
2410 | ||
cleanup
|
2411 |
test 'select() param option'; |
2412 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2413 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2414 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2415 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
2416 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2417 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4}); |
|
2418 |
$dbi->insert(table => 'table2', param => {key1 => 2, key3 => 5}); |
|
2419 |
$rows = $dbi->select( |
|
2420 |
table => 'table1', |
|
2421 |
column => 'table1.key1 as table1_key1, key2, key3', |
|
2422 |
where => {'table1.key2' => 3}, |
|
2423 |
join => ['inner join (select * from table2 where {= table2.key3})' . |
|
2424 |
' as table2 on table1.key1 = table2.key1'], |
|
2425 |
param => {'table2.key3' => 5} |
|
added EXPERIMENTAL select pr...
|
2426 |
)->all; |
cleanup
|
2427 |
is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]); |
2428 | ||
added EXPERIMENTAL select() ...
|
2429 | |
2430 |
test 'select() wrap option'; |
|
2431 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2432 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2433 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2434 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
2435 |
$rows = $dbi->select( |
|
2436 |
table => 'table1', |
|
2437 |
column => 'key1', |
|
2438 |
wrap => ['select * from (', ') as t where key1 = 1'] |
|
added EXPERIMENTAL select pr...
|
2439 |
)->all; |
added EXPERIMENTAL select() ...
|
2440 |
is_deeply($rows, [{key1 => 1}]); |
2441 | ||
2442 |
eval { |
|
2443 |
$dbi->select( |
|
2444 |
table => 'table1', |
|
2445 |
column => 'key1', |
|
2446 |
wrap => 'select * from (' |
|
2447 |
) |
|
2448 |
}; |
|
cleanup
|
2449 |
like($@, qr/array/); |
2450 | ||
2451 |
test 'select() string where'; |
|
2452 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2453 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2454 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2455 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
2456 |
$rows = $dbi->select( |
|
2457 |
table => 'table1', |
|
updated pod
|
2458 |
where => 'key1 = :key1 and key2 = :key2', |
DEPRECATED select() param op...
|
2459 |
where_param => {key1 => 1, key2 => 2} |
added EXPERIMENTAL select pr...
|
2460 |
)->all; |
cleanup
|
2461 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
select, update, and delete w...
|
2462 | |
updated pod
|
2463 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
2464 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2465 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2466 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
2467 |
$rows = $dbi->select( |
|
2468 |
table => 'table1', |
|
2469 |
where => [ |
|
2470 |
'key1 = :key1 and key2 = :key2', |
|
2471 |
{key1 => 1, key2 => 2} |
|
2472 |
] |
|
2473 |
)->all; |
|
2474 |
is_deeply($rows, [{key1 => 1, key2 => 2}]); |
|
2475 | ||
select, update, and delete w...
|
2476 |
test 'delete() string where'; |
2477 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2478 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2479 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2480 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
2481 |
$dbi->delete( |
|
2482 |
table => 'table1', |
|
updated pod
|
2483 |
where => 'key1 = :key1 and key2 = :key2', |
DEPRECATED select() param op...
|
2484 |
where_param => {key1 => 1, key2 => 2} |
select, update, and delete w...
|
2485 |
); |
added EXPERIMENTAL select pr...
|
2486 |
$rows = $dbi->select(table => 'table1')->all; |
select, update, and delete w...
|
2487 |
is_deeply($rows, [{key1 => 2, key2 => 3}]); |
2488 | ||
updated pod
|
2489 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
2490 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2491 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2492 |
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3}); |
|
2493 |
$dbi->delete( |
|
2494 |
table => 'table1', |
|
2495 |
where => [ |
|
2496 |
'key1 = :key1 and key2 = :key2', |
|
2497 |
{key1 => 1, key2 => 2} |
|
2498 |
] |
|
2499 |
); |
|
2500 |
$rows = $dbi->select(table => 'table1')->all; |
|
2501 |
is_deeply($rows, [{key1 => 2, key2 => 3}]); |
|
2502 | ||
select, update, and delete w...
|
2503 | |
2504 |
test 'update() string where'; |
|
2505 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2506 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2507 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2508 |
$dbi->update( |
|
2509 |
table => 'table1', |
|
DEPRECATED select() param op...
|
2510 |
param => {key1 => 5}, |
updated pod
|
2511 |
where => 'key1 = :key1 and key2 = :key2', |
DEPRECATED select() param op...
|
2512 |
where_param => {key1 => 1, key2 => 2} |
select, update, and delete w...
|
2513 |
); |
added EXPERIMENTAL select pr...
|
2514 |
$rows = $dbi->select(table => 'table1')->all; |
select, update, and delete w...
|
2515 |
is_deeply($rows, [{key1 => 5, key2 => 2}]); |
- update_param_tag is DEPREC...
|
2516 | |
updated pod
|
2517 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
2518 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2519 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2520 |
$dbi->update( |
|
2521 |
table => 'table1', |
|
2522 |
param => {key1 => 5}, |
|
2523 |
where => [ |
|
2524 |
'key1 = :key1 and key2 = :key2', |
|
2525 |
{key1 => 1, key2 => 2} |
|
2526 |
] |
|
2527 |
); |
|
2528 |
$rows = $dbi->select(table => 'table1')->all; |
|
2529 |
is_deeply($rows, [{key1 => 5, key2 => 2}]); |
|
cleanup
|
2530 | |
insert_at is DEPRECATED! add...
|
2531 |
test 'insert id and primary_key option'; |
2532 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2533 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2534 |
$dbi->insert( |
|
2535 |
primary_key => ['key1', 'key2'], |
|
2536 |
table => 'table1', |
|
2537 |
id => [1, 2], |
|
2538 |
param => {key3 => 3} |
|
2539 |
); |
|
2540 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
|
2541 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
2542 |
is($dbi->select(table => 'table1')->one->{key3}, 3); |
|
2543 | ||
2544 |
$dbi->delete_all(table => 'table1'); |
|
2545 |
$dbi->insert( |
|
2546 |
primary_key => 'key1', |
|
2547 |
table => 'table1', |
|
fixed small insert, update, ...
|
2548 |
id => 0, |
insert_at is DEPRECATED! add...
|
2549 |
param => {key2 => 2, key3 => 3} |
2550 |
); |
|
2551 | ||
fixed small insert, update, ...
|
2552 |
is($dbi->select(table => 'table1')->one->{key1}, 0); |
insert_at is DEPRECATED! add...
|
2553 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
2554 |
is($dbi->select(table => 'table1')->one->{key3}, 3); |
|
2555 | ||
2556 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2557 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2558 |
$dbi->insert( |
|
2559 |
{key3 => 3}, |
|
2560 |
primary_key => ['key1', 'key2'], |
|
2561 |
table => 'table1', |
|
2562 |
id => [1, 2], |
|
2563 |
); |
|
2564 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
|
2565 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
2566 |
is($dbi->select(table => 'table1')->one->{key3}, 3); |
|
2567 | ||
cleanup
|
2568 | |
added tests
|
2569 |
test 'model insert id and primary_key option'; |
2570 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
|
2571 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2572 |
$dbi->model('table1')->insert( |
|
2573 |
id => [1, 2], |
|
2574 |
param => {key3 => 3} |
|
2575 |
); |
|
2576 |
$result = $dbi->model('table1')->select; |
|
2577 |
$row = $result->one; |
|
2578 |
is($row->{key1}, 1); |
|
2579 |
is($row->{key2}, 2); |
|
2580 |
is($row->{key3}, 3); |
|
2581 | ||
- fixed bug that model inser...
|
2582 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
2583 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2584 |
$dbi->model('table1')->insert( |
|
2585 |
{key3 => 3}, |
|
2586 |
id => [1, 2] |
|
2587 |
); |
|
2588 |
$result = $dbi->model('table1')->select; |
|
2589 |
$row = $result->one; |
|
2590 |
is($row->{key1}, 1); |
|
2591 |
is($row->{key2}, 2); |
|
2592 |
is($row->{key3}, 3); |
|
2593 | ||
update_at is DEPRECATED! use...
|
2594 |
test 'update and id option'; |
2595 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2596 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2597 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2598 |
$dbi->update( |
|
2599 |
table => 'table1', |
|
2600 |
primary_key => ['key1', 'key2'], |
|
2601 |
id => [1, 2], |
|
2602 |
param => {key3 => 4} |
|
2603 |
); |
|
2604 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
|
2605 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
2606 |
is($dbi->select(table => 'table1')->one->{key3}, 4); |
|
2607 | ||
2608 |
$dbi->delete_all(table => 'table1'); |
|
fixed small insert, update, ...
|
2609 |
$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3}); |
update_at is DEPRECATED! use...
|
2610 |
$dbi->update( |
2611 |
table => 'table1', |
|
2612 |
primary_key => 'key1', |
|
fixed small insert, update, ...
|
2613 |
id => 0, |
update_at is DEPRECATED! use...
|
2614 |
param => {key3 => 4} |
2615 |
); |
|
fixed small insert, update, ...
|
2616 |
is($dbi->select(table => 'table1')->one->{key1}, 0); |
update_at is DEPRECATED! use...
|
2617 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
2618 |
is($dbi->select(table => 'table1')->one->{key3}, 4); |
|
2619 | ||
2620 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2621 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2622 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2623 |
$dbi->update( |
|
2624 |
{key3 => 4}, |
|
2625 |
table => 'table1', |
|
2626 |
primary_key => ['key1', 'key2'], |
|
2627 |
id => [1, 2] |
|
2628 |
); |
|
2629 |
is($dbi->select(table => 'table1')->one->{key1}, 1); |
|
2630 |
is($dbi->select(table => 'table1')->one->{key2}, 2); |
|
2631 |
is($dbi->select(table => 'table1')->one->{key3}, 4); |
|
2632 | ||
2633 | ||
delete_at is DEPRECATED! use...
|
2634 |
test 'model update and id option'; |
update_at is DEPRECATED! use...
|
2635 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
2636 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2637 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2638 |
$dbi->model('table1')->update( |
|
2639 |
id => [1, 2], |
|
2640 |
param => {key3 => 4} |
|
2641 |
); |
|
2642 |
$result = $dbi->model('table1')->select; |
|
2643 |
$row = $result->one; |
|
2644 |
is($row->{key1}, 1); |
|
2645 |
is($row->{key2}, 2); |
|
2646 |
is($row->{key3}, 4); |
|
added tests
|
2647 | |
delete_at is DEPRECATED! use...
|
2648 | |
2649 |
test 'delete and id option'; |
|
2650 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2651 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2652 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2653 |
$dbi->delete( |
|
2654 |
table => 'table1', |
|
2655 |
primary_key => ['key1', 'key2'], |
|
2656 |
id => [1, 2], |
|
2657 |
); |
|
added EXPERIMENTAL select pr...
|
2658 |
is_deeply($dbi->select(table => 'table1')->all, []); |
delete_at is DEPRECATED! use...
|
2659 | |
fixed small insert, update, ...
|
2660 |
$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3}); |
delete_at is DEPRECATED! use...
|
2661 |
$dbi->delete( |
2662 |
table => 'table1', |
|
2663 |
primary_key => 'key1', |
|
fixed small insert, update, ...
|
2664 |
id => 0, |
delete_at is DEPRECATED! use...
|
2665 |
); |
added EXPERIMENTAL select pr...
|
2666 |
is_deeply($dbi->select(table => 'table1')->all, []); |
delete_at is DEPRECATED! use...
|
2667 | |
2668 | ||
2669 |
test 'model delete and id option'; |
|
2670 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
|
2671 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2672 |
$dbi->execute("create table table2 (key1, key2, key3)"); |
|
2673 |
$dbi->execute("create table table3 (key1, key2, key3)"); |
|
2674 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2675 |
$dbi->model('table1')->delete(id => [1, 2]); |
|
added EXPERIMENTAL select pr...
|
2676 |
is_deeply($dbi->select(table => 'table1')->all, []); |
delete_at is DEPRECATED! use...
|
2677 |
$dbi->insert(table => 'table2', param => {key1 => 1, key2 => 2, key3 => 3}); |
2678 |
$dbi->model('table1_1')->delete(id => [1, 2]); |
|
added EXPERIMENTAL select pr...
|
2679 |
is_deeply($dbi->select(table => 'table1')->all, []); |
delete_at is DEPRECATED! use...
|
2680 |
$dbi->insert(table => 'table3', param => {key1 => 1, key2 => 2, key3 => 3}); |
2681 |
$dbi->model('table1_3')->delete(id => [1, 2]); |
|
added EXPERIMENTAL select pr...
|
2682 |
is_deeply($dbi->select(table => 'table1')->all, []); |
delete_at is DEPRECATED! use...
|
2683 | |
select_at is DEPRECATED! use...
|
2684 | |
2685 |
test 'select and id option'; |
|
2686 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
2687 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2688 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2689 |
$result = $dbi->select( |
|
2690 |
table => 'table1', |
|
2691 |
primary_key => ['key1', 'key2'], |
|
2692 |
id => [1, 2] |
|
2693 |
); |
|
2694 |
$row = $result->one; |
|
2695 |
is($row->{key1}, 1); |
|
2696 |
is($row->{key2}, 2); |
|
2697 |
is($row->{key3}, 3); |
|
2698 | ||
2699 |
$dbi->delete_all(table => 'table1'); |
|
fixed small insert, update, ...
|
2700 |
$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3}); |
select_at is DEPRECATED! use...
|
2701 |
$result = $dbi->select( |
2702 |
table => 'table1', |
|
2703 |
primary_key => 'key1', |
|
fixed small insert, update, ...
|
2704 |
id => 0, |
select_at is DEPRECATED! use...
|
2705 |
); |
2706 |
$row = $result->one; |
|
fixed small insert, update, ...
|
2707 |
is($row->{key1}, 0); |
select_at is DEPRECATED! use...
|
2708 |
is($row->{key2}, 2); |
2709 |
is($row->{key3}, 3); |
|
2710 | ||
2711 |
$dbi->delete_all(table => 'table1'); |
|
2712 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2713 |
$result = $dbi->select( |
|
2714 |
table => 'table1', |
|
2715 |
primary_key => ['key1', 'key2'], |
|
2716 |
id => [1, 2] |
|
2717 |
); |
|
2718 |
$row = $result->one; |
|
2719 |
is($row->{key1}, 1); |
|
2720 |
is($row->{key2}, 2); |
|
2721 |
is($row->{key3}, 3); |
|
2722 | ||
2723 | ||
2724 |
test 'model select_at'; |
|
2725 |
$dbi = MyDBI6->connect($NEW_ARGS->{0}); |
|
2726 |
$dbi->execute($CREATE_TABLE->{1}); |
|
2727 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3}); |
|
2728 |
$result = $dbi->model('table1')->select(id => [1, 2]); |
|
2729 |
$row = $result->one; |
|
2730 |
is($row->{key1}, 1); |
|
2731 |
is($row->{key2}, 2); |
|
2732 |
is($row->{key3}, 3); |
|
2733 | ||
EXPERIMTANL column method th...
|
2734 |
test 'column separator is default .'; |
added EXPERIMENTAL col metho...
|
2735 |
$dbi = MyDBI7->connect($NEW_ARGS->{0}); |
2736 |
$dbi->execute($CREATE_TABLE->{0}); |
|
2737 |
$dbi->execute($CREATE_TABLE->{2}); |
|
2738 |
$dbi->setup_model; |
|
2739 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
2740 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3}); |
|
2741 |
$model = $dbi->model('table1'); |
|
2742 |
$result = $model->select( |
|
EXPERIMTANL column method th...
|
2743 |
column => [$model->column('table2')], |
added EXPERIMENTAL col metho...
|
2744 |
where => {'table1.key1' => 1} |
2745 |
); |
|
2746 |
is_deeply($result->one, |
|
2747 |
{'table2.key1' => 1, 'table2.key3' => 3}); |
|
2748 | ||
2749 |
$result = $model->select( |
|
EXPERIMTANL column method th...
|
2750 |
column => [$model->column('table2' => [qw/key1 key3/])], |
added EXPERIMENTAL col metho...
|
2751 |
where => {'table1.key1' => 1} |
2752 |
); |
|
2753 |
is_deeply($result->one, |
|
2754 |
{'table2.key1' => 1, 'table2.key3' => 3}); |
|
2755 | ||
added type_rule method and f...
|
2756 | |
2757 |
test 'type_rule from'; |
|
2758 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2759 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2760 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2761 |
date => sub { uc $_[0] } |
added type_rule method and f...
|
2762 |
} |
2763 |
); |
|
2764 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2765 |
$dbi->insert({key1 => 'a'}, table => 'table1'); |
|
2766 |
$result = $dbi->select(table => 'table1'); |
|
2767 |
is($result->fetch_first->[0], 'A'); |
|
2768 | ||
2769 |
$result = $dbi->select(table => 'table1'); |
|
2770 |
is($result->one->{key1}, 'A'); |
|
2771 | ||
added type_rule into logic
|
2772 | |
2773 |
test 'type_rule into'; |
|
2774 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2775 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2776 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2777 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2778 |
date => sub { uc $_[0] } |
added type_rule into logic
|
2779 |
} |
2780 |
); |
|
2781 |
$dbi->insert({key1 => 'a'}, table => 'table1'); |
|
2782 |
$result = $dbi->select(table => 'table1'); |
|
2783 |
is($result->one->{key1}, 'A'); |
|
2784 | ||
2785 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
added EXPERIMENTAL DBIx::Cus...
|
2786 |
$dbi->execute("create table table1 (key1 date, key2 datetime)"); |
added type_rule into logic
|
2787 |
$dbi->type_rule( |
EXPERIMENTAL type_rule argum...
|
2788 |
into1 => [ |
added EXPERIMENTAL DBIx::Cus...
|
2789 |
[qw/date datetime/] => sub { uc $_[0] } |
changed type_rule arguments ...
|
2790 |
] |
added type_rule into logic
|
2791 |
); |
2792 |
$dbi->insert({key1 => 'a', key2 => 'b'}, table => 'table1'); |
|
2793 |
$result = $dbi->select(table => 'table1'); |
|
2794 |
$row = $result->one; |
|
2795 |
is($row->{key1}, 'A'); |
|
2796 |
is($row->{key2}, 'B'); |
|
2797 | ||
2798 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2799 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2800 |
$dbi->insert({key1 => 'a', key2 => 'B'}, table => 'table1'); |
|
2801 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2802 |
into1 => [ |
added EXPERIMENTAL DBIx::Cus...
|
2803 |
[qw/date datetime/] => sub { uc $_[0] } |
changed type_rule arguments ...
|
2804 |
] |
added type_rule into logic
|
2805 |
); |
2806 |
$result = $dbi->execute( |
|
2807 |
"select * from table1 where key1 = :key1 and key2 = :table1.key2;", |
|
2808 |
param => {key1 => 'a', 'table1.key2' => 'b'} |
|
2809 |
); |
|
2810 |
$row = $result->one; |
|
2811 |
is($row->{key1}, 'a'); |
|
2812 |
is($row->{key2}, 'B'); |
|
2813 | ||
2814 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2815 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2816 |
$dbi->insert({key1 => 'A', key2 => 'B'}, table => 'table1'); |
|
2817 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2818 |
into1 => [ |
added EXPERIMENTAL DBIx::Cus...
|
2819 |
[qw/date datetime/] => sub { uc $_[0] } |
changed type_rule arguments ...
|
2820 |
] |
added type_rule into logic
|
2821 |
); |
2822 |
$result = $dbi->execute( |
|
2823 |
"select * from table1 where key1 = :key1 and key2 = :table1.key2;", |
|
2824 |
param => {key1 => 'a', 'table1.key2' => 'b'}, |
|
2825 |
table => 'table1' |
|
2826 |
); |
|
2827 |
$row = $result->one; |
|
2828 |
is($row->{key1}, 'A'); |
|
2829 |
is($row->{key2}, 'B'); |
|
2830 | ||
fixed bug that type_rule fro...
|
2831 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
added EXPERIMENTAL DBIx::Cus...
|
2832 |
$dbi->execute("create table table1 (key1 date, key2 datetime)"); |
fixed bug that type_rule fro...
|
2833 |
$dbi->register_filter(twice => sub { $_[0] * 2 }); |
2834 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2835 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2836 |
date => 'twice', |
fixed bug that type_rule fro...
|
2837 |
}, |
EXPERIMENTAL type_rule argum...
|
2838 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2839 |
date => 'twice', |
fixed bug that type_rule fro...
|
2840 |
} |
2841 |
); |
|
2842 |
$dbi->insert({key1 => 2}, table => 'table1'); |
|
2843 |
$result = $dbi->select(table => 'table1'); |
|
2844 |
is($result->fetch->[0], 8); |
|
2845 | ||
separate DBIx::Custom type_r...
|
2846 |
test 'type_rule and filter order'; |
2847 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2848 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2849 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2850 |
into1 => { |
separate DBIx::Custom type_r...
|
2851 |
date => sub { $_[0] . 'b' } |
2852 |
}, |
|
EXPERIMENTAL type_rule argum...
|
2853 |
into2 => { |
separate DBIx::Custom type_r...
|
2854 |
date => sub { $_[0] . 'c' } |
EXPERIMENTAL type_rule argum...
|
2855 |
}, |
2856 |
from1 => { |
|
2857 |
date => sub { $_[0] . 'd' } |
|
2858 |
}, |
|
2859 |
from2 => { |
|
2860 |
date => sub { $_[0] . 'e' } |
|
separate DBIx::Custom type_r...
|
2861 |
} |
2862 |
); |
|
2863 |
$dbi->insert({key1 => '1'}, table => 'table1', filter => {key1 => sub { $_[0] . 'a' }}); |
|
2864 |
$result = $dbi->select(table => 'table1'); |
|
EXPERIMENTAL type_rule argum...
|
2865 |
$result->filter(key1 => sub { $_[0] . 'f' }); |
2866 |
is($result->fetch_first->[0], '1abcdef'); |
|
2867 | ||
2868 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2869 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2870 |
$dbi->type_rule( |
|
2871 |
from1 => { |
|
2872 |
date => sub { $_[0] . 'p' } |
|
2873 |
}, |
|
2874 |
from2 => { |
|
2875 |
date => sub { $_[0] . 'q' } |
|
2876 |
}, |
|
2877 |
); |
|
2878 |
$dbi->insert({key1 => '1'}, table => 'table1'); |
|
2879 |
$result = $dbi->select(table => 'table1'); |
|
2880 |
$result->type_rule( |
|
2881 |
from1 => { |
|
2882 |
date => sub { $_[0] . 'd' } |
|
2883 |
}, |
|
2884 |
from2 => { |
|
2885 |
date => sub { $_[0] . 'e' } |
|
2886 |
} |
|
2887 |
); |
|
2888 |
$result->filter(key1 => sub { $_[0] . 'f' }); |
|
2889 |
is($result->fetch_first->[0], '1def'); |
|
added EXPERIMENTAL execute()...
|
2890 | |
2891 |
test 'type_rule_off'; |
|
2892 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2893 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2894 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2895 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2896 |
date => sub { $_[0] * 2 }, |
changed type_rule arguments ...
|
2897 |
}, |
EXPERIMENTAL type_rule argum...
|
2898 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2899 |
date => sub { $_[0] * 2 }, |
added EXPERIMENTAL execute()...
|
2900 |
} |
2901 |
); |
|
2902 |
$dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1); |
|
2903 |
$result = $dbi->select(table => 'table1', type_rule_off => 1); |
|
- changed EXPERIMENTAL DBIx:...
|
2904 |
is($result->type_rule_off->fetch->[0], 2); |
added EXPERIMENTAL execute()...
|
2905 | |
2906 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2907 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2908 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2909 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2910 |
date => sub { $_[0] * 2 }, |
changed type_rule arguments ...
|
2911 |
}, |
EXPERIMENTAL type_rule argum...
|
2912 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2913 |
date => sub { $_[0] * 3 }, |
added EXPERIMENTAL execute()...
|
2914 |
} |
2915 |
); |
|
2916 |
$dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1); |
|
2917 |
$result = $dbi->select(table => 'table1', type_rule_off => 1); |
|
added EXPERIMENTAL DBIx::Cus...
|
2918 |
is($result->one->{key1}, 4); |
2919 | ||
2920 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2921 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2922 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2923 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2924 |
date => sub { $_[0] * 2 }, |
2925 |
}, |
|
EXPERIMENTAL type_rule argum...
|
2926 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2927 |
date => sub { $_[0] * 3 }, |
2928 |
} |
|
2929 |
); |
|
2930 |
$dbi->insert({key1 => 2}, table => 'table1'); |
|
2931 |
$result = $dbi->select(table => 'table1'); |
|
2932 |
is($result->one->{key1}, 12); |
|
2933 | ||
2934 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2935 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2936 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2937 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2938 |
date => sub { $_[0] * 2 }, |
2939 |
}, |
|
EXPERIMENTAL type_rule argum...
|
2940 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2941 |
date => sub { $_[0] * 3 }, |
2942 |
} |
|
2943 |
); |
|
2944 |
$dbi->insert({key1 => 2}, table => 'table1'); |
|
2945 |
$result = $dbi->select(table => 'table1'); |
|
2946 |
is($result->fetch->[0], 12); |
|
added EXPERIMENTAL execute()...
|
2947 | |
type_rule can receive filter...
|
2948 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
2949 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2950 |
$dbi->register_filter(ppp => sub { uc $_[0] }); |
|
2951 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2952 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2953 |
date => 'ppp' |
type_rule can receive filter...
|
2954 |
} |
2955 |
); |
|
2956 |
$dbi->insert({key1 => 'a'}, table => 'table1'); |
|
2957 |
$result = $dbi->select(table => 'table1'); |
|
2958 |
is($result->one->{key1}, 'A'); |
|
2959 | ||
2960 |
eval{$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2961 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2962 |
date => 'pp' |
type_rule can receive filter...
|
2963 |
} |
2964 |
)}; |
|
2965 |
like($@, qr/not registered/); |
|
added DBIx::Custom result_fi...
|
2966 | |
added EXPERIMENTAL DBIx::Cus...
|
2967 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
2968 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2969 |
eval { |
|
2970 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2971 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2972 |
Date => sub { $_[0] * 2 }, |
2973 |
} |
|
2974 |
); |
|
2975 |
}; |
|
2976 |
like($@, qr/lower/); |
|
2977 | ||
2978 |
eval { |
|
2979 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2980 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2981 |
Date => sub { $_[0] * 2 }, |
2982 |
} |
|
2983 |
); |
|
2984 |
}; |
|
2985 |
like($@, qr/lower/); |
|
2986 | ||
2987 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
2988 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
2989 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
2990 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2991 |
date => sub { $_[0] * 2 }, |
2992 |
}, |
|
EXPERIMENTAL type_rule argum...
|
2993 |
into1 => { |
added EXPERIMENTAL DBIx::Cus...
|
2994 |
date => sub { $_[0] * 3 }, |
2995 |
} |
|
2996 |
); |
|
2997 |
$dbi->insert({key1 => 2}, table => 'table1'); |
|
2998 |
$result = $dbi->select(table => 'table1'); |
|
- changed EXPERIMENTAL DBIx:...
|
2999 |
$result->type_rule_off; |
added EXPERIMENTAL DBIx::Cus...
|
3000 |
is($result->one->{key1}, 6); |
3001 | ||
3002 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3003 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3004 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
3005 |
from1 => { |
added EXPERIMENTAL DBIx::Cus...
|
3006 |
date => sub { $_[0] * 2 }, |
3007 |
datetime => sub { $_[0] * 4 }, |
|
3008 |
}, |
|
3009 |
); |
|
3010 |
$dbi->insert({key1 => 2, key2 => 2}, table => 'table1'); |
|
3011 |
$result = $dbi->select(table => 'table1'); |
|
EXPERIMENTAL type_rule argum...
|
3012 |
$result->type_rule( |
3013 |
from1 => { |
|
3014 |
date => sub { $_[0] * 3 } |
|
3015 |
} |
|
3016 |
); |
|
added EXPERIMENTAL DBIx::Cus...
|
3017 |
$row = $result->one; |
3018 |
is($row->{key1}, 6); |
|
EXPERIMENTAL type_rule argum...
|
3019 |
is($row->{key2}, 2); |
3020 | ||
added EXPERIMENTAL DBIx::Cus...
|
3021 |
$result = $dbi->select(table => 'table1'); |
EXPERIMENTAL type_rule argum...
|
3022 |
$result->type_rule( |
3023 |
from1 => { |
|
3024 |
date => sub { $_[0] * 3 } |
|
3025 |
} |
|
3026 |
); |
|
added EXPERIMENTAL DBIx::Cus...
|
3027 |
$row = $result->one; |
3028 |
is($row->{key1}, 6); |
|
EXPERIMENTAL type_rule argum...
|
3029 |
is($row->{key2}, 2); |
3030 | ||
added EXPERIMENTAL DBIx::Cus...
|
3031 |
$result = $dbi->select(table => 'table1'); |
EXPERIMENTAL type_rule argum...
|
3032 |
$result->type_rule( |
3033 |
from1 => { |
|
3034 |
date => sub { $_[0] * 3 } |
|
3035 |
} |
|
3036 |
); |
|
cleanup
|
3037 |
$row = $result->one; |
3038 |
is($row->{key1}, 6); |
|
3039 |
is($row->{key2}, 2); |
|
3040 |
$result = $dbi->select(table => 'table1'); |
|
EXPERIMENTAL type_rule argum...
|
3041 |
$result->type_rule( |
3042 |
from1 => [date => sub { $_[0] * 3 }] |
|
3043 |
); |
|
added EXPERIMENTAL DBIx::Cus...
|
3044 |
$row = $result->one; |
3045 |
is($row->{key1}, 6); |
|
cleanup
|
3046 |
is($row->{key2}, 2); |
added EXPERIMENTAL DBIx::Cus...
|
3047 |
$dbi->register_filter(fivetimes => sub { $_[0] * 5}); |
3048 |
$result = $dbi->select(table => 'table1'); |
|
EXPERIMENTAL type_rule argum...
|
3049 |
$result->type_rule( |
3050 |
from1 => [date => 'fivetimes'] |
|
3051 |
); |
|
added EXPERIMENTAL DBIx::Cus...
|
3052 |
$row = $result->one; |
3053 |
is($row->{key1}, 10); |
|
EXPERIMENTAL type_rule argum...
|
3054 |
is($row->{key2}, 2); |
added EXPERIMENTAL DBIx::Cus...
|
3055 |
$result = $dbi->select(table => 'table1'); |
EXPERIMENTAL type_rule argum...
|
3056 |
$result->type_rule( |
3057 |
from1 => [date => undef] |
|
3058 |
); |
|
added EXPERIMENTAL DBIx::Cus...
|
3059 |
$row = $result->one; |
3060 |
is($row->{key1}, 2); |
|
EXPERIMENTAL type_rule argum...
|
3061 |
is($row->{key2}, 2); |
added EXPERIMENTAL DBIx::Cus...
|
3062 | |
DBIx::Custom::Result filter ...
|
3063 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
3064 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3065 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
3066 |
from1 => { |
DBIx::Custom::Result filter ...
|
3067 |
date => sub { $_[0] * 2 }, |
3068 |
}, |
|
3069 |
); |
|
3070 |
$dbi->insert({key1 => 2}, table => 'table1'); |
|
3071 |
$result = $dbi->select(table => 'table1'); |
|
removed EXPERIMENTAL DBIx::M...
|
3072 |
$result->filter(key1 => sub { $_[0] * 3 }); |
separate DBIx::Custom::Resul...
|
3073 |
is($result->one->{key1}, 12); |
3074 | ||
3075 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3076 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3077 |
$dbi->type_rule( |
|
EXPERIMENTAL type_rule argum...
|
3078 |
from1 => { |
separate DBIx::Custom::Resul...
|
3079 |
date => sub { $_[0] * 2 }, |
3080 |
}, |
|
3081 |
); |
|
3082 |
$dbi->insert({key1 => 2}, table => 'table1'); |
|
3083 |
$result = $dbi->select(table => 'table1'); |
|
3084 |
$result->filter(key1 => sub { $_[0] * 3 }); |
|
3085 |
is($result->fetch->[0], 12); |
|
added EXPERIMENTAL DBIx::Cus...
|
3086 | |
EXPERIMENTAL type_rule argum...
|
3087 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
3088 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3089 |
$dbi->type_rule( |
|
3090 |
into1 => { |
|
3091 |
date => sub { $_[0] . 'b' } |
|
3092 |
}, |
|
3093 |
into2 => { |
|
3094 |
date => sub { $_[0] . 'c' } |
|
3095 |
}, |
|
3096 |
from1 => { |
|
3097 |
date => sub { $_[0] . 'd' } |
|
3098 |
}, |
|
3099 |
from2 => { |
|
3100 |
date => sub { $_[0] . 'e' } |
|
3101 |
} |
|
3102 |
); |
|
3103 |
$dbi->insert({key1 => '1'}, table => 'table1', type_rule_off => 1); |
|
3104 |
$result = $dbi->select(table => 'table1'); |
|
- changed EXPERIMENTAL DBIx:...
|
3105 |
is($result->type_rule_off->fetch_first->[0], '1'); |
3106 |
$result = $dbi->select(table => 'table1'); |
|
3107 |
is($result->type_rule_on->fetch_first->[0], '1de'); |
|
EXPERIMENTAL type_rule argum...
|
3108 | |
3109 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3110 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3111 |
$dbi->type_rule( |
|
3112 |
into1 => { |
|
3113 |
date => sub { $_[0] . 'b' } |
|
3114 |
}, |
|
3115 |
into2 => { |
|
3116 |
date => sub { $_[0] . 'c' } |
|
3117 |
}, |
|
3118 |
from1 => { |
|
3119 |
date => sub { $_[0] . 'd' } |
|
3120 |
}, |
|
3121 |
from2 => { |
|
3122 |
date => sub { $_[0] . 'e' } |
|
3123 |
} |
|
3124 |
); |
|
3125 |
$dbi->insert({key1 => '1'}, table => 'table1', type_rule1_off => 1); |
|
3126 |
$result = $dbi->select(table => 'table1'); |
|
- changed EXPERIMENTAL DBIx:...
|
3127 |
is($result->type_rule1_off->fetch_first->[0], '1ce'); |
3128 |
$result = $dbi->select(table => 'table1'); |
|
3129 |
is($result->type_rule1_on->fetch_first->[0], '1cde'); |
|
EXPERIMENTAL type_rule argum...
|
3130 | |
3131 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3132 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3133 |
$dbi->type_rule( |
|
3134 |
into1 => { |
|
3135 |
date => sub { $_[0] . 'b' } |
|
3136 |
}, |
|
3137 |
into2 => { |
|
3138 |
date => sub { $_[0] . 'c' } |
|
3139 |
}, |
|
3140 |
from1 => { |
|
3141 |
date => sub { $_[0] . 'd' } |
|
3142 |
}, |
|
3143 |
from2 => { |
|
3144 |
date => sub { $_[0] . 'e' } |
|
3145 |
} |
|
3146 |
); |
|
3147 |
$dbi->insert({key1 => '1'}, table => 'table1', type_rule2_off => 1); |
|
3148 |
$result = $dbi->select(table => 'table1'); |
|
- changed EXPERIMENTAL DBIx:...
|
3149 |
is($result->type_rule2_off->fetch_first->[0], '1bd'); |
3150 |
$result = $dbi->select(table => 'table1'); |
|
3151 |
is($result->type_rule2_on->fetch_first->[0], '1bde'); |
|
EXPERIMENTAL type_rule argum...
|
3152 | |
removed EXPERIMENTAL DBIx::M...
|
3153 |
test 'separator'; |
added DBIx::Custom result_fi...
|
3154 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
3155 |
$dbi->execute($CREATE_TABLE->{0}); |
|
3156 |
$dbi->execute($CREATE_TABLE->{2}); |
|
3157 | ||
3158 |
$dbi->create_model( |
|
3159 |
table => 'table1', |
|
3160 |
join => [ |
|
3161 |
'left outer join table2 on table1.key1 = table2.key1' |
|
3162 |
], |
|
3163 |
primary_key => ['key1'], |
|
3164 |
); |
|
3165 |
$model2 = $dbi->create_model( |
|
3166 |
table => 'table2', |
|
3167 |
); |
|
3168 |
$dbi->setup_model; |
|
3169 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
3170 |
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3}); |
|
3171 |
$model = $dbi->model('table1'); |
|
3172 |
$result = $model->select( |
|
3173 |
column => [ |
|
3174 |
$model->mycolumn, |
|
3175 |
{table2 => [qw/key1 key3/]} |
|
3176 |
], |
|
3177 |
where => {'table1.key1' => 1} |
|
3178 |
); |
|
3179 |
is_deeply($result->one, |
|
removed EXPERIMENTAL DBIx::M...
|
3180 |
{key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3}); |
3181 |
is_deeply($model2->select->one, {key1 => 1, key3 => 3}); |
|
added DBIx::Custom result_fi...
|
3182 | |
EXPERIMTANL column method th...
|
3183 |
$dbi->separator('__'); |
3184 |
$model = $dbi->model('table1'); |
|
3185 |
$result = $model->select( |
|
3186 |
column => [ |
|
3187 |
$model->mycolumn, |
|
3188 |
{table2 => [qw/key1 key3/]} |
|
3189 |
], |
|
3190 |
where => {'table1.key1' => 1} |
|
3191 |
); |
|
3192 |
is_deeply($result->one, |
|
removed EXPERIMENTAL DBIx::M...
|
3193 |
{key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3}); |
3194 |
is_deeply($model2->select->one, {key1 => 1, key3 => 3}); |
|
EXPERIMTANL column method th...
|
3195 | |
cleanup
|
3196 |
$dbi->separator('-'); |
3197 |
$model = $dbi->model('table1'); |
|
3198 |
$result = $model->select( |
|
3199 |
column => [ |
|
3200 |
$model->mycolumn, |
|
3201 |
{table2 => [qw/key1 key3/]} |
|
3202 |
], |
|
3203 |
where => {'table1.key1' => 1} |
|
3204 |
); |
|
3205 |
is_deeply($result->one, |
|
removed EXPERIMENTAL DBIx::M...
|
3206 |
{key1 => 1, key2 => 2, 'table2-key1' => 1, 'table2-key3' => 3}); |
3207 |
is_deeply($model2->select->one, {key1 => 1, key3 => 3}); |
|
cleanup
|
3208 | |
EXPERIMTANL column method th...
|
3209 | |
type_rule can receive filter...
|
3210 |
test 'filter_off'; |
3211 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
3212 |
$dbi->execute($CREATE_TABLE->{0}); |
|
3213 |
$dbi->execute($CREATE_TABLE->{2}); |
|
3214 | ||
3215 |
$dbi->create_model( |
|
3216 |
table => 'table1', |
|
3217 |
join => [ |
|
3218 |
'left outer join table2 on table1.key1 = table2.key1' |
|
3219 |
], |
|
3220 |
primary_key => ['key1'], |
|
3221 |
); |
|
3222 |
$dbi->setup_model; |
|
3223 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
3224 |
$model = $dbi->model('table1'); |
|
removed EXPERIMENTAL DBIx::M...
|
3225 |
$result = $model->select(column => 'key1'); |
3226 |
$result->filter(key1 => sub { $_[0] * 2 }); |
|
3227 |
is_deeply($result->one, {key1 => 2}); |
|
fixed bug that type_rule fro...
|
3228 | |
3229 |
test 'available_date_type'; |
|
3230 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
3231 |
ok($dbi->can('available_data_type')); |
|
3232 | ||
added EXPERIMENTAL select pr...
|
3233 | |
3234 |
test 'select prefix option'; |
|
3235 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
3236 |
$dbi->execute($CREATE_TABLE->{0}); |
|
3237 |
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}); |
|
3238 |
$rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all; |
|
3239 |
is_deeply($rows, [{key1 => 1, key2 => 2}], "table"); |
|
3240 | ||
added EXPERIMETNAL separator...
|
3241 | |
3242 |
test 'separator'; |
|
3243 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
3244 |
is($dbi->separator, '.'); |
|
3245 |
$dbi->separator('-'); |
|
3246 |
is($dbi->separator, '-'); |
|
3247 |
$dbi->separator('__'); |
|
3248 |
is($dbi->separator, '__'); |
|
3249 |
eval { $dbi->separator('?') }; |
|
3250 |
like($@, qr/Separator/); |
|
3251 | ||
added EXPERIMENTAL map_param...
|
3252 | |
3253 |
test 'map_param'; |
|
3254 |
$dbi = DBIx::Custom->connect($NEW_ARGS->{0}); |
|
3255 |
$param = $dbi->map_param( |
|
3256 |
{id => 1, author => 'Ken', price => 1900}, |
|
3257 |
id => 'book.id', |
|
3258 |
author => ['book.author', sub { '%' . $_[0] . '%' }], |
|
3259 |
price => ['book.price', {if => sub { $_[0] eq 1900 }}] |
|
3260 |
); |
|
3261 |
is_deeply($param, {'book.id' => 1, 'book.author' => '%Ken%', |
|
3262 |
'book.price' => 1900}); |
|
3263 | ||
3264 |
$param = $dbi->map_param( |
|
3265 |
{id => 0, author => 0, price => 0}, |
|
3266 |
id => 'book.id', |
|
3267 |
author => ['book.author', sub { '%' . $_[0] . '%' }], |
|
3268 |
price => ['book.price', sub { '%' . $_[0] . '%' }, |
|
3269 |
{if => sub { $_[0] eq 0 }}] |
|
3270 |
); |
|
3271 |
is_deeply($param, {'book.id' => 0, 'book.author' => '%0%', 'book.price' => '%0%'}); |
|
3272 | ||
3273 |
$param = $dbi->map_param( |
|
3274 |
{id => '', author => '', price => ''}, |
|
3275 |
id => 'book.id', |
|
3276 |
author => ['book.author', sub { '%' . $_[0] . '%' }], |
|
3277 |
price => ['book.price', sub { '%' . $_[0] . '%' }, |
|
3278 |
{if => sub { $_[0] eq 1 }}] |
|
3279 |
); |
|
3280 |
is_deeply($param, {}); |
|
3281 | ||
3282 |
$param = $dbi->map_param( |
|
3283 |
{id => undef, author => undef, price => undef}, |
|
3284 |
id => 'book.id', |
|
3285 |
price => ['book.price', {if => 'exists'}] |
|
3286 |
); |
|
3287 |
is_deeply($param, {'book.price' => undef}); |
|
3288 | ||
3289 |
$param = $dbi->map_param( |
|
3290 |
{price => 'a'}, |
|
3291 |
id => ['book.id', {if => 'exists'}], |
|
3292 |
price => ['book.price', sub { '%' . $_[0] }, {if => 'exists'}] |
|
3293 |
); |
|
3294 |
is_deeply($param, {'book.price' => '%a'}); |
|
3295 | ||
added EXPERIMENTAL execute m...
|
3296 | |
3297 |
test 'table_alias'; |
|
3298 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3299 |
$dbi->execute("create table table1 (key1 Date, key2 datetime)"); |
|
3300 |
$dbi->type_rule( |
|
3301 |
into1 => { |
|
3302 |
date => sub { uc $_[0] } |
|
3303 |
} |
|
3304 |
); |
|
3305 |
$dbi->execute("insert into table1 (key1) values (:table2.key1)", {'table2.key1' => 'a'}, |
|
3306 |
table_alias => {table2 => 'table1'}); |
|
3307 |
$result = $dbi->select(table => 'table1'); |
|
3308 |
is($result->one->{key1}, 'A'); |
|
3309 | ||
- added EXPERIMENTAL order m...
|
3310 | |
3311 |
test 'order'; |
|
3312 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3313 |
{ |
|
3314 |
$dbi->execute("create table table1 (key1, key2)"); |
|
3315 |
$dbi->insert({key1 => 1, key2 => 1}, table => 'table1'); |
|
3316 |
$dbi->insert({key1 => 1, key2 => 3}, table => 'table1'); |
|
3317 |
$dbi->insert({key1 => 2, key2 => 2}, table => 'table1'); |
|
3318 |
$dbi->insert({key1 => 2, key2 => 4}, table => 'table1'); |
|
3319 |
my $order = $dbi->order; |
|
3320 |
$order->prepend('key1', 'key2 desc'); |
|
3321 |
$result = $dbi->select(table => 'table1', append => "$order"); |
|
3322 |
is_deeply($result->all, [{key1 => 1, key2 => 3}, {key1 => 1, key2 => 1}, |
|
3323 |
{key1 => 2, key2 => 4}, {key1 => 2, key2 => 2}]); |
|
3324 |
$order->prepend('key1 desc'); |
|
3325 |
$result = $dbi->select(table => 'table1', append => "$order"); |
|
3326 |
is_deeply($result->all, [{key1 => 2, key2 => 4}, {key1 => 2, key2 => 2}, |
|
3327 |
{key1 => 1, key2 => 3}, {key1 => 1, key2 => 1}]); |
|
3328 |
} |
|
3329 | ||
added tag_parse attribute
|
3330 |
test 'tag_parse'; |
3331 |
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3332 |
$dbi->tag_parse(0); |
|
3333 |
{ |
|
3334 |
$dbi->execute("create table table1 (key1, key2)"); |
|
3335 |
$dbi->insert({key1 => 1, key2 => 1}, table => 'table1'); |
|
3336 |
eval {$dbi->execute("select * from table1 where {= key1}", {key1 => 1})}; |
|
3337 |
ok($@); |
|
3338 |
} |
|
- added EXPERIMENTAL order m...
|
3339 | |
added EXPERIMENTAL last_sql ...
|
3340 |
test 'last_sql'; |
3341 |
{ |
|
3342 |
my $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3343 |
$dbi->execute("create table table1 (key1, key2)"); |
|
3344 |
$dbi->execute('select * from table1'); |
|
3345 |
is($dbi->last_sql, 'select * from table1;'); |
|
3346 |
|
|
3347 |
eval{$dbi->execute("aaa")}; |
|
3348 |
is($dbi->last_sql, 'aaa;'); |
|
3349 |
|
|
3350 |
} |
|
added EXPERIMENTAL DBIx::Cus...
|
3351 | |
3352 |
test 'DBIx::Custom header'; |
|
3353 |
{ |
|
3354 |
my $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:'); |
|
3355 |
$dbi->execute("create table table1 (key1, key2)"); |
|
3356 |
my $result = $dbi->execute('select key1 as h1, key2 as h2 from table1'); |
|
3357 |
|
|
3358 |
is_deeply($result->header, [qw/h1 h2/]); |
|
3359 |
|
|
3360 |
} |
|
3361 | ||
- update_param_tag is DEPREC...
|
3362 |
=cut |