...
|
...
|
@@ -19,14 +19,18 @@ BEGIN {
|
19
|
19
|
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
|
20
|
20
|
sub test { print "# $_[0]\n" }
|
21
|
21
|
|
|
22
|
+# Constant
|
|
23
|
+my %memory = (dsn => 'dbi:SQLite:dbname=:memory:');
|
|
24
|
+my $create_table_default = 'create table table1 (key1 char(255), key2 char(255));';
|
|
25
|
+
|
22
|
26
|
# Variables
|
23
|
27
|
my $dbi;
|
24
|
28
|
my $sth;
|
25
|
29
|
my $source;
|
26
|
30
|
my @sources;
|
27
|
|
-my $select_SOURCE;
|
28
|
|
-my $insert_SOURCE;
|
29
|
|
-my $update_SOURCE;
|
|
31
|
+my $select_source;
|
|
32
|
+my $insert_source;
|
|
33
|
+my $update_source;
|
30
|
34
|
my $param;
|
31
|
35
|
my $params;
|
32
|
36
|
my $sql;
|
...
|
...
|
@@ -49,8 +53,8 @@ my $insert_param;
|
49
|
53
|
my $join;
|
50
|
54
|
|
51
|
55
|
# Prepare table
|
52
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
53
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
56
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
57
|
+$dbi->execute($create_table_default);
|
54
|
58
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
55
|
59
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
56
|
60
|
|
...
|
...
|
@@ -82,7 +86,7 @@ is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "all");
|
82
|
86
|
|
83
|
87
|
test 'Insert query return value';
|
84
|
88
|
$dbi->execute('drop table table1');
|
85
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
89
|
+$dbi->execute($create_table_default);
|
86
|
90
|
$source = "insert into table1 {insert_param key1 key2}";
|
87
|
91
|
$query = $dbi->execute($source, {}, query => 1);
|
88
|
92
|
$ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -91,21 +95,21 @@ ok($ret_val);
|
91
|
95
|
|
92
|
96
|
test 'Direct query';
|
93
|
97
|
$dbi->execute('drop table table1');
|
94
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
95
|
|
-$insert_SOURCE = "insert into table1 {insert_param key1 key2}";
|
96
|
|
-$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2});
|
|
98
|
+$dbi->execute($create_table_default);
|
|
99
|
+$insert_source = "insert into table1 {insert_param key1 key2}";
|
|
100
|
+$dbi->execute($insert_source, param => {key1 => 1, key2 => 2});
|
97
|
101
|
$result = $dbi->execute('select * from table1;');
|
98
|
102
|
$rows = $result->all;
|
99
|
103
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
100
|
104
|
|
101
|
105
|
test 'Filter basic';
|
102
|
106
|
$dbi->execute('drop table table1');
|
103
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
107
|
+$dbi->execute($create_table_default);
|
104
|
108
|
$dbi->register_filter(twice => sub { $_[0] * 2},
|
105
|
109
|
three_times => sub { $_[0] * 3});
|
106
|
110
|
|
107
|
|
-$insert_SOURCE = "insert into table1 {insert_param key1 key2};";
|
108
|
|
-$insert_query = $dbi->execute($insert_SOURCE, {}, query => 1);
|
|
111
|
+$insert_source = "insert into table1 {insert_param key1 key2};";
|
|
112
|
+$insert_query = $dbi->execute($insert_source, {}, query => 1);
|
109
|
113
|
$insert_query->filter({key1 => 'twice'});
|
110
|
114
|
$dbi->execute($insert_query, param => {key1 => 1, key2 => 2});
|
111
|
115
|
$result = $dbi->execute('select * from table1;');
|
...
|
...
|
@@ -114,12 +118,12 @@ is_deeply($rows, [{key1 => 2, key2 => 6}], "filter fetch_filter");
|
114
|
118
|
$dbi->execute('drop table table1');
|
115
|
119
|
|
116
|
120
|
test 'Filter in';
|
117
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
118
|
|
-$insert_SOURCE = "insert into table1 {insert_param key1 key2};";
|
119
|
|
-$insert_query = $dbi->execute($insert_SOURCE, {}, query => 1);
|
|
121
|
+$dbi->execute($create_table_default);
|
|
122
|
+$insert_source = "insert into table1 {insert_param key1 key2};";
|
|
123
|
+$insert_query = $dbi->execute($insert_source, {}, query => 1);
|
120
|
124
|
$dbi->execute($insert_query, param => {key1 => 2, key2 => 4});
|
121
|
|
-$select_SOURCE = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}";
|
122
|
|
-$select_query = $dbi->execute($select_SOURCE,{}, query => 1);
|
|
125
|
+$select_source = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}";
|
|
126
|
+$select_query = $dbi->execute($select_source,{}, query => 1);
|
123
|
127
|
$select_query->filter({'table1.key1' => 'twice'});
|
124
|
128
|
$result = $dbi->execute($select_query, param => {'table1.key1' => [1,5], 'table1.key2' => [2,4]});
|
125
|
129
|
$rows = $result->all;
|
...
|
...
|
@@ -163,8 +167,8 @@ is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "bas
|
163
|
167
|
|
164
|
168
|
test 'DBIx::Custom::SQLTemplate insert tag';
|
165
|
169
|
$dbi->execute("delete from table1");
|
166
|
|
-$insert_SOURCE = 'insert into table1 {insert_param key1 key2 key3 key4 key5}';
|
167
|
|
-$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
170
|
+$insert_source = 'insert into table1 {insert_param key1 key2 key3 key4 key5}';
|
|
171
|
+$dbi->execute($insert_source, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
168
|
172
|
|
169
|
173
|
$result = $dbi->execute('select * from table1;');
|
170
|
174
|
$rows = $result->all;
|
...
|
...
|
@@ -172,12 +176,12 @@ is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "bas
|
172
|
176
|
|
173
|
177
|
test 'DBIx::Custom::SQLTemplate update tag';
|
174
|
178
|
$dbi->execute("delete from table1");
|
175
|
|
-$insert_SOURCE = "insert into table1 {insert_param key1 key2 key3 key4 key5}";
|
176
|
|
-$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
177
|
|
-$dbi->execute($insert_SOURCE, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
|
179
|
+$insert_source = "insert into table1 {insert_param key1 key2 key3 key4 key5}";
|
|
180
|
+$dbi->execute($insert_source, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
|
181
|
+$dbi->execute($insert_source, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
178
|
182
|
|
179
|
|
-$update_SOURCE = 'update table1 {update_param key1 key2 key3 key4} where {= key5}';
|
180
|
|
-$dbi->execute($update_SOURCE, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5});
|
|
183
|
+$update_source = 'update table1 {update_param key1 key2 key3 key4} where {= key5}';
|
|
184
|
+$dbi->execute($update_source, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5});
|
181
|
185
|
|
182
|
186
|
$result = $dbi->execute('select * from table1;');
|
183
|
187
|
$rows = $result->all;
|
...
|
...
|
@@ -216,7 +220,7 @@ $rows = $result->all;
|
216
|
220
|
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
|
217
|
221
|
|
218
|
222
|
$dbi->execute('drop table table1');
|
219
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
223
|
+$dbi->execute($create_table_default);
|
220
|
224
|
$dbi->insert(table => 'table1', param => {key1 => '2011-10-14 12:19:18', key2 => 2});
|
221
|
225
|
$source = "select * from table1 where key1 = '2011-10-14 12:19:18' and key2 = :key2";
|
222
|
226
|
$result = $dbi->execute(
|
...
|
...
|
@@ -227,8 +231,8 @@ $result = $dbi->execute(
|
227
|
231
|
$rows = $result->all;
|
228
|
232
|
is_deeply($rows, [{key1 => '2011-10-14 12:19:18', key2 => 2}]);
|
229
|
233
|
|
230
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
231
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
234
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
235
|
+$dbi->execute($create_table_default);
|
232
|
236
|
$dbi->insert(table => 'table1', param => {key1 => 'a:b c:d', key2 => 2});
|
233
|
237
|
$source = "select * from table1 where key1 = 'a\\:b c\\:d' and key2 = :key2";
|
234
|
238
|
$result = $dbi->execute(
|
...
|
...
|
@@ -243,13 +247,13 @@ test 'Error case';
|
243
|
247
|
eval {DBIx::Custom->connect(dsn => 'dbi:SQLit')};
|
244
|
248
|
ok($@, "connect error");
|
245
|
249
|
|
246
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
250
|
+$dbi = DBIx::Custom->connect(%memory);
|
247
|
251
|
eval{$dbi->execute("{p }", {}, query => 1)};
|
248
|
252
|
ok($@, "create_query invalid SQL template");
|
249
|
253
|
|
250
|
254
|
test 'insert';
|
251
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
252
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
255
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
256
|
+$dbi->execute($create_table_default);
|
253
|
257
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
254
|
258
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
255
|
259
|
$result = $dbi->execute('select * from table1;');
|
...
|
...
|
@@ -269,7 +273,7 @@ is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
|
269
|
273
|
$dbi->default_bind_filter(undef);
|
270
|
274
|
|
271
|
275
|
$dbi->execute('drop table table1');
|
272
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
276
|
+$dbi->execute($create_table_default);
|
273
|
277
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => ' ');
|
274
|
278
|
$rows = $dbi->select(table => 'table1')->all;
|
275
|
279
|
is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
|
...
|
...
|
@@ -280,7 +284,7 @@ like($@, qr/noexist/, "invalid");
|
280
|
284
|
eval{$dbi->insert(table => 'table', param => {';' => 1})};
|
281
|
285
|
like($@, qr/safety/);
|
282
|
286
|
|
283
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
287
|
+$dbi = DBIx::Custom->connect(%memory);
|
284
|
288
|
$dbi->quote('"');
|
285
|
289
|
$dbi->execute('create table "table" ("select")');
|
286
|
290
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -289,15 +293,15 @@ $result = $dbi->execute('select * from "table"');
|
289
|
293
|
$rows = $result->all;
|
290
|
294
|
is_deeply($rows, [{select => 2}], "reserved word");
|
291
|
295
|
|
292
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
293
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
296
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
297
|
+$dbi->execute($create_table_default);
|
294
|
298
|
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
|
295
|
299
|
$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
|
296
|
300
|
$result = $dbi->execute('select * from table1;');
|
297
|
301
|
$rows = $result->all;
|
298
|
302
|
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
|
299
|
303
|
|
300
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
304
|
+$dbi = DBIx::Custom->connect(%memory);
|
301
|
305
|
$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))");
|
302
|
306
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
303
|
307
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4}, prefix => 'or replace');
|
...
|
...
|
@@ -305,8 +309,8 @@ $result = $dbi->execute('select * from table1;');
|
305
|
309
|
$rows = $result->all;
|
306
|
310
|
is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
|
307
|
311
|
|
308
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
309
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
312
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
313
|
+$dbi->execute($create_table_default);
|
310
|
314
|
$dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
|
311
|
315
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
312
|
316
|
$result = $dbi->execute('select * from table1;');
|
...
|
...
|
@@ -314,7 +318,7 @@ $rows = $result->all;
|
314
|
318
|
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
|
315
|
319
|
|
316
|
320
|
test 'update';
|
317
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
321
|
+$dbi = DBIx::Custom->connect(%memory);
|
318
|
322
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
319
|
323
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
320
|
324
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -362,8 +366,8 @@ like($@, qr/noexist/, "invalid");
|
362
|
366
|
eval{$dbi->update(table => 'table1')};
|
363
|
367
|
like($@, qr/where/, "not contain where");
|
364
|
368
|
|
365
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
366
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
369
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
370
|
+$dbi->execute($create_table_default);
|
367
|
371
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
368
|
372
|
$where = $dbi->where;
|
369
|
373
|
$where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
|
...
|
...
|
@@ -372,8 +376,8 @@ $dbi->update(table => 'table1', param => {key1 => 3}, where => $where);
|
372
|
376
|
$result = $dbi->select(table => 'table1');
|
373
|
377
|
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
|
374
|
378
|
|
375
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
376
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
379
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
380
|
+$dbi->execute($create_table_default);
|
377
|
381
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
378
|
382
|
$dbi->update(
|
379
|
383
|
table => 'table1',
|
...
|
...
|
@@ -386,8 +390,8 @@ $dbi->update(
|
386
|
390
|
$result = $dbi->select(table => 'table1');
|
387
|
391
|
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
|
388
|
392
|
|
389
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
390
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
393
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
394
|
+$dbi->execute($create_table_default);
|
391
|
395
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
392
|
396
|
$where = $dbi->where;
|
393
|
397
|
$where->clause(['and', 'key2 = :key2']);
|
...
|
...
|
@@ -402,7 +406,7 @@ like($@, qr/safety/);
|
402
|
406
|
eval{$dbi->update(table => 'table1', param => {'key1' => 1}, where => {';' => 1})};
|
403
|
407
|
like($@, qr/safety/);
|
404
|
408
|
|
405
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
409
|
+$dbi = DBIx::Custom->connect(%memory);
|
406
|
410
|
$dbi->quote('"');
|
407
|
411
|
$dbi->execute('create table "table" ("select", "update")');
|
408
|
412
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -416,7 +420,7 @@ is_deeply($rows, [{select => 2, update => 6}], "reserved word");
|
416
|
420
|
eval {$dbi->update_all(table => 'table', param => {';' => 2}) };
|
417
|
421
|
like($@, qr/safety/);
|
418
|
422
|
|
419
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
423
|
+$dbi = DBIx::Custom->connect(%memory);
|
420
|
424
|
$dbi->reserved_word_quote('"');
|
421
|
425
|
$dbi->execute('create table "table" ("select", "update")');
|
422
|
426
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -427,7 +431,7 @@ $result = $dbi->execute('select * from "table"');
|
427
|
431
|
$rows = $result->all;
|
428
|
432
|
is_deeply($rows, [{select => 2, update => 6}], "reserved word");
|
429
|
433
|
|
430
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
434
|
+$dbi = DBIx::Custom->connect(%memory);
|
431
|
435
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
432
|
436
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
433
|
437
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -438,7 +442,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
438
|
442
|
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
439
|
443
|
"basic");
|
440
|
444
|
|
441
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
445
|
+$dbi = DBIx::Custom->connect(%memory);
|
442
|
446
|
$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))");
|
443
|
447
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
444
|
448
|
$dbi->update(table => 'table1', param => {key2 => 4},
|
...
|
...
|
@@ -447,7 +451,7 @@ $result = $dbi->execute('select * from table1;');
|
447
|
451
|
$rows = $result->all;
|
448
|
452
|
is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
|
449
|
453
|
|
450
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
454
|
+$dbi = DBIx::Custom->connect(%memory);
|
451
|
455
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
452
|
456
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
453
|
457
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -459,7 +463,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
459
|
463
|
"basic");
|
460
|
464
|
|
461
|
465
|
test 'update_all';
|
462
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
466
|
+$dbi = DBIx::Custom->connect(%memory);
|
463
|
467
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
464
|
468
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
465
|
469
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -473,8 +477,8 @@ is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
|
473
|
477
|
|
474
|
478
|
|
475
|
479
|
test 'delete';
|
476
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
477
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
480
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
481
|
+$dbi->execute($create_table_default);
|
478
|
482
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
479
|
483
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
480
|
484
|
$dbi->delete(table => 'table1', where => {key1 => 1});
|
...
|
...
|
@@ -503,8 +507,8 @@ is_deeply($rows, [{key1 => 3, key2 => 4}], "delete multi key");
|
503
|
507
|
eval{$dbi->delete(table => 'table1', where => {key1 => 1}, noexist => 1)};
|
504
|
508
|
like($@, qr/noexist/, "invalid");
|
505
|
509
|
|
506
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
507
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
510
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
511
|
+$dbi->execute($create_table_default);
|
508
|
512
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
509
|
513
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
510
|
514
|
$where = $dbi->where;
|
...
|
...
|
@@ -514,8 +518,8 @@ $dbi->delete(table => 'table1', where => $where);
|
514
|
518
|
$result = $dbi->select(table => 'table1');
|
515
|
519
|
is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
|
516
|
520
|
|
517
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
518
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
521
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
522
|
+$dbi->execute($create_table_default);
|
519
|
523
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
520
|
524
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
521
|
525
|
$dbi->delete(
|
...
|
...
|
@@ -528,7 +532,7 @@ $dbi->delete(
|
528
|
532
|
$result = $dbi->select(table => 'table1');
|
529
|
533
|
is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
|
530
|
534
|
|
531
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
535
|
+$dbi = DBIx::Custom->connect(%memory);
|
532
|
536
|
$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))");
|
533
|
537
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
534
|
538
|
$dbi->delete(table => 'table1', where => {key1 => 1}, prefix => ' ');
|
...
|
...
|
@@ -537,8 +541,8 @@ $rows = $result->all;
|
537
|
541
|
is_deeply($rows, [], "basic");
|
538
|
542
|
|
539
|
543
|
test 'delete error';
|
540
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
541
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
544
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
545
|
+$dbi->execute($create_table_default);
|
542
|
546
|
eval{$dbi->delete(table => 'table1')};
|
543
|
547
|
like($@, qr/"where" must be specified/,
|
544
|
548
|
"where key-value pairs not specified");
|
...
|
...
|
@@ -546,7 +550,7 @@ like($@, qr/"where" must be specified/,
|
546
|
550
|
eval{$dbi->delete(table => 'table1', where => {';' => 1})};
|
547
|
551
|
like($@, qr/safety/);
|
548
|
552
|
|
549
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
553
|
+$dbi = DBIx::Custom->connect(%memory);
|
550
|
554
|
$dbi->quote('"');
|
551
|
555
|
$dbi->execute('create table "table" ("select", "update")');
|
552
|
556
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -557,8 +561,8 @@ $rows = $result->all;
|
557
|
561
|
is_deeply($rows, [], "reserved word");
|
558
|
562
|
|
559
|
563
|
test 'delete_all';
|
560
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
561
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
564
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
565
|
+$dbi->execute($create_table_default);
|
562
|
566
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
563
|
567
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
564
|
568
|
$dbi->delete_all(table => 'table1');
|
...
|
...
|
@@ -568,8 +572,8 @@ is_deeply($rows, [], "basic");
|
568
|
572
|
|
569
|
573
|
|
570
|
574
|
test 'select';
|
571
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
572
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
575
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
576
|
+$dbi->execute($create_table_default);
|
573
|
577
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
574
|
578
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
575
|
579
|
$rows = $dbi->select(table => 'table1')->all;
|
...
|
...
|
@@ -613,7 +617,7 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "
|
613
|
617
|
eval{$dbi->select(table => 'table1', noexist => 1)};
|
614
|
618
|
like($@, qr/noexist/, "invalid");
|
615
|
619
|
|
616
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
620
|
+$dbi = DBIx::Custom->connect(%memory);
|
617
|
621
|
$dbi->quote('"');
|
618
|
622
|
$dbi->execute('create table "table" ("select", "update")');
|
619
|
623
|
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
|
...
|
...
|
@@ -623,13 +627,13 @@ $rows = $result->all;
|
623
|
627
|
is_deeply($rows, [{select => 2, update => 2}], "reserved word");
|
624
|
628
|
|
625
|
629
|
test 'fetch filter';
|
626
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
630
|
+$dbi = DBIx::Custom->connect(%memory);
|
627
|
631
|
$dbi->register_filter(
|
628
|
632
|
twice => sub { $_[0] * 2 },
|
629
|
633
|
three_times => sub { $_[0] * 3 }
|
630
|
634
|
);
|
631
|
635
|
$dbi->default_fetch_filter('twice');
|
632
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
636
|
+$dbi->execute($create_table_default);
|
633
|
637
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
634
|
638
|
$result = $dbi->select(table => 'table1');
|
635
|
639
|
$result->filter({key1 => 'three_times'});
|
...
|
...
|
@@ -646,8 +650,8 @@ is($dbi->filters->{encode_utf8}->('あ'),
|
646
|
650
|
encode_utf8('あ'), "encode_utf8");
|
647
|
651
|
|
648
|
652
|
test 'transaction';
|
649
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
650
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
653
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
654
|
+$dbi->execute($create_table_default);
|
651
|
655
|
$dbi->dbh->begin_work;
|
652
|
656
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
653
|
657
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
...
|
...
|
@@ -656,8 +660,8 @@ $result = $dbi->select(table => 'table1');
|
656
|
660
|
is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
|
657
|
661
|
"commit");
|
658
|
662
|
|
659
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
660
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
663
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
664
|
+$dbi->execute($create_table_default);
|
661
|
665
|
$dbi->dbh->begin_work(0);
|
662
|
666
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
663
|
667
|
$dbi->dbh->rollback;
|
...
|
...
|
@@ -666,24 +670,24 @@ $result = $dbi->select(table => 'table1');
|
666
|
670
|
ok(! $result->fetch_first, "rollback");
|
667
|
671
|
|
668
|
672
|
test 'cache';
|
669
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
673
|
+$dbi = DBIx::Custom->connect(%memory);
|
670
|
674
|
$dbi->cache(1);
|
671
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
675
|
+$dbi->execute($create_table_default);
|
672
|
676
|
$source = 'select * from table1 where key1 = :key1 and key2 = :key2;';
|
673
|
677
|
$dbi->execute($source, {}, query => 1);
|
674
|
678
|
is_deeply($dbi->{_cached}->{$source},
|
675
|
679
|
{sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2'], tables => []}, "cache");
|
676
|
680
|
|
677
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
678
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
681
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
682
|
+$dbi->execute($create_table_default);
|
679
|
683
|
$dbi->{_cached} = {};
|
680
|
684
|
$dbi->cache(0);
|
681
|
685
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
682
|
686
|
is(scalar keys %{$dbi->{_cached}}, 0, 'not cache');
|
683
|
687
|
|
684
|
688
|
test 'execute';
|
685
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
686
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
689
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
690
|
+$dbi->execute($create_table_default);
|
687
|
691
|
{
|
688
|
692
|
local $Carp::Verbose = 0;
|
689
|
693
|
eval{$dbi->execute('select * frm table1')};
|
...
|
...
|
@@ -717,8 +721,8 @@ ok($@, "execute fail");
|
717
|
721
|
|
718
|
722
|
|
719
|
723
|
test 'transaction';
|
720
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
721
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
724
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
725
|
+$dbi->execute($create_table_default);
|
722
|
726
|
|
723
|
727
|
$dbi->begin_work;
|
724
|
728
|
|
...
|
...
|
@@ -754,7 +758,7 @@ $dbi->dbh->{AutoCommit} = 1;
|
754
|
758
|
|
755
|
759
|
|
756
|
760
|
test 'method';
|
757
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
761
|
+$dbi = DBIx::Custom->connect(%memory);
|
758
|
762
|
$dbi->method(
|
759
|
763
|
one => sub { 1 }
|
760
|
764
|
);
|
...
|
...
|
@@ -776,8 +780,8 @@ eval {$dbi->XXXXXX};
|
776
|
780
|
ok($@, "not exists");
|
777
|
781
|
|
778
|
782
|
test 'out filter';
|
779
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
780
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
783
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
784
|
+$dbi->execute($create_table_default);
|
781
|
785
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
782
|
786
|
$dbi->register_filter(three_times => sub { $_[0] * 3});
|
783
|
787
|
$dbi->apply_filter(
|
...
|
...
|
@@ -791,8 +795,8 @@ $result = $dbi->select(table => 'table1');
|
791
|
795
|
$row = $result->one;
|
792
|
796
|
is_deeply($row, {key1 => 6, key2 => 12}, "insert");
|
793
|
797
|
|
794
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
795
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
798
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
799
|
+$dbi->execute($create_table_default);
|
796
|
800
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
797
|
801
|
$dbi->register_filter(three_times => sub { $_[0] * 3});
|
798
|
802
|
$dbi->apply_filter(
|
...
|
...
|
@@ -806,8 +810,8 @@ $result = $dbi->execute('select * from table1;');
|
806
|
810
|
$row = $result->one;
|
807
|
811
|
is_deeply($row, {key1 => 1, key2 => 6}, "insert");
|
808
|
812
|
|
809
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
810
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
813
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
814
|
+$dbi->execute($create_table_default);
|
811
|
815
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
812
|
816
|
$dbi->apply_filter(
|
813
|
817
|
'table1', 'key1' => {out => 'twice', in => 'twice'}
|
...
|
...
|
@@ -818,8 +822,8 @@ $result = $dbi->execute('select * from table1;');
|
818
|
822
|
$row = $result->one;
|
819
|
823
|
is_deeply($row, {key1 => 4, key2 => 2}, "update");
|
820
|
824
|
|
821
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
822
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
825
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
826
|
+$dbi->execute($create_table_default);
|
823
|
827
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
824
|
828
|
$dbi->apply_filter(
|
825
|
829
|
'table1', 'key1' => {out => 'twice', in => 'twice'}
|
...
|
...
|
@@ -830,8 +834,8 @@ $result = $dbi->execute('select * from table1;');
|
830
|
834
|
$rows = $result->all;
|
831
|
835
|
is_deeply($rows, [], "delete");
|
832
|
836
|
|
833
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
834
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
837
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
838
|
+$dbi->execute($create_table_default);
|
835
|
839
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
836
|
840
|
$dbi->apply_filter(
|
837
|
841
|
'table1', 'key1' => {out => 'twice', in => 'twice'}
|
...
|
...
|
@@ -842,8 +846,8 @@ $result->filter({'key2' => 'twice'});
|
842
|
846
|
$rows = $result->all;
|
843
|
847
|
is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
|
844
|
848
|
|
845
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
846
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
849
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
850
|
+$dbi->execute($create_table_default);
|
847
|
851
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
848
|
852
|
$dbi->apply_filter(
|
849
|
853
|
'table1', 'key1' => {out => 'twice', in => 'twice'}
|
...
|
...
|
@@ -855,8 +859,8 @@ $result = $dbi->execute("select * from table1 where key1 = :key1 and key2 = :key
|
855
|
859
|
$rows = $result->all;
|
856
|
860
|
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
|
857
|
861
|
|
858
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
859
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
862
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
863
|
+$dbi->execute($create_table_default);
|
860
|
864
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
861
|
865
|
$dbi->apply_filter(
|
862
|
866
|
'table1', 'key1' => {out => 'twice', in => 'twice'}
|
...
|
...
|
@@ -867,8 +871,8 @@ $result = $dbi->execute("select * from {table table1} where key1 = :key1 and key
|
867
|
871
|
$rows = $result->all;
|
868
|
872
|
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
|
869
|
873
|
|
870
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
871
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
874
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
875
|
+$dbi->execute($create_table_default);
|
872
|
876
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
873
|
877
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
874
|
878
|
$dbi->register_filter(three_times => sub { $_[0] * 3 });
|
...
|
...
|
@@ -899,7 +903,7 @@ $rows = $result->all;
|
899
|
903
|
is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit");
|
900
|
904
|
|
901
|
905
|
test 'each_column';
|
902
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
906
|
+$dbi = DBIx::Custom->connect(%memory);
|
903
|
907
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
904
|
908
|
$dbi->execute('create table table1 (key1 Date, key2 datetime);');
|
905
|
909
|
|
...
|
...
|
@@ -923,7 +927,7 @@ is_deeply($infos,
|
923
|
927
|
|
924
|
928
|
);
|
925
|
929
|
test 'each_table';
|
926
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
930
|
+$dbi = DBIx::Custom->connect(%memory);
|
927
|
931
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
928
|
932
|
$dbi->execute('create table table1 (key1 Date, key2 datetime);');
|
929
|
933
|
|
...
|
...
|
@@ -945,8 +949,8 @@ is_deeply($infos,
|
945
|
949
|
);
|
946
|
950
|
|
947
|
951
|
test 'limit';
|
948
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
949
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
952
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
953
|
+$dbi->execute($create_table_default);
|
950
|
954
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
951
|
955
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4});
|
952
|
956
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 6});
|
...
|
...
|
@@ -998,14 +1002,14 @@ test 'connect super';
|
998
|
1002
|
}
|
999
|
1003
|
}
|
1000
|
1004
|
|
1001
|
|
-$dbi = MyDBI->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1002
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1005
|
+$dbi = MyDBI->connect(%memory);
|
|
1006
|
+$dbi->execute($create_table_default);
|
1003
|
1007
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1004
|
1008
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
1005
|
1009
|
|
1006
|
|
-$dbi = MyDBI->new(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1010
|
+$dbi = MyDBI->new(%memory);
|
1007
|
1011
|
$dbi->connect;
|
1008
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1012
|
+$dbi->execute($create_table_default);
|
1009
|
1013
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1010
|
1014
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
1011
|
1015
|
|
...
|
...
|
@@ -1021,14 +1025,14 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
|
1021
|
1025
|
}
|
1022
|
1026
|
}
|
1023
|
1027
|
|
1024
|
|
-$dbi = MyDBI->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1025
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1028
|
+$dbi = MyDBI->connect(%memory);
|
|
1029
|
+$dbi->execute($create_table_default);
|
1026
|
1030
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1027
|
1031
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
1028
|
1032
|
|
1029
|
1033
|
test 'end_filter';
|
1030
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1031
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1034
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1035
|
+$dbi->execute($create_table_default);
|
1032
|
1036
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1033
|
1037
|
$result = $dbi->select(table => 'table1');
|
1034
|
1038
|
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
|
...
|
...
|
@@ -1036,8 +1040,8 @@ $result->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 });
|
1036
|
1040
|
$row = $result->fetch_first;
|
1037
|
1041
|
is_deeply($row, [6, 40]);
|
1038
|
1042
|
|
1039
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1040
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1043
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1044
|
+$dbi->execute($create_table_default);
|
1041
|
1045
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1042
|
1046
|
$result = $dbi->select(table => 'table1');
|
1043
|
1047
|
$result->filter([qw/key1 key2/] => sub { $_[0] * 2 });
|
...
|
...
|
@@ -1045,8 +1049,8 @@ $result->end_filter([[qw/key1 key2/] => sub { $_[0] * 3 }]);
|
1045
|
1049
|
$row = $result->fetch_first;
|
1046
|
1050
|
is_deeply($row, [6, 12]);
|
1047
|
1051
|
|
1048
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1049
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1052
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1053
|
+$dbi->execute($create_table_default);
|
1050
|
1054
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1051
|
1055
|
$result = $dbi->select(table => 'table1');
|
1052
|
1056
|
$result->filter([[qw/key1 key2/] => sub { $_[0] * 2 }]);
|
...
|
...
|
@@ -1084,8 +1088,8 @@ $row = $result->one;
|
1084
|
1088
|
is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
|
1085
|
1089
|
|
1086
|
1090
|
test 'remove_end_filter and remove_filter';
|
1087
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1088
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1091
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1092
|
+$dbi->execute($create_table_default);
|
1089
|
1093
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1090
|
1094
|
$result = $dbi->select(table => 'table1');
|
1091
|
1095
|
$row = $result
|
...
|
...
|
@@ -1097,16 +1101,16 @@ $row = $result
|
1097
|
1101
|
is_deeply($row, [1, 2]);
|
1098
|
1102
|
|
1099
|
1103
|
test 'empty where select';
|
1100
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1101
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1104
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1105
|
+$dbi->execute($create_table_default);
|
1102
|
1106
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1103
|
1107
|
$result = $dbi->select(table => 'table1', where => {});
|
1104
|
1108
|
$row = $result->one;
|
1105
|
1109
|
is_deeply($row, {key1 => 1, key2 => 2});
|
1106
|
1110
|
|
1107
|
1111
|
test 'select query option';
|
1108
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1109
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1112
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1113
|
+$dbi->execute($create_table_default);
|
1110
|
1114
|
$query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
|
1111
|
1115
|
is(ref $query, 'DBIx::Custom::Query');
|
1112
|
1116
|
$query = $dbi->update(table => 'table1', where => {key1 => 1}, param => {key2 => 2}, query => 1);
|
...
|
...
|
@@ -1117,8 +1121,8 @@ $query = $dbi->select(table => 'table1', where => {key1 => 1, key2 => 2}, query
|
1117
|
1121
|
is(ref $query, 'DBIx::Custom::Query');
|
1118
|
1122
|
|
1119
|
1123
|
test 'DBIx::Custom::Where';
|
1120
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1121
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1124
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1125
|
+$dbi->execute($create_table_default);
|
1122
|
1126
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1123
|
1127
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
1124
|
1128
|
$where = $dbi->where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
|
...
|
...
|
@@ -1409,21 +1413,21 @@ $dbi = DBIx::Custom->new;
|
1409
|
1413
|
is_deeply($dbi->dbi_option, {});
|
1410
|
1414
|
|
1411
|
1415
|
test 'register_tag_processor';
|
1412
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1416
|
+$dbi = DBIx::Custom->connect(%memory);
|
1413
|
1417
|
$dbi->register_tag_processor(
|
1414
|
1418
|
a => sub { 1 }
|
1415
|
1419
|
);
|
1416
|
1420
|
is($dbi->query_builder->tag_processors->{a}->(), 1);
|
1417
|
1421
|
|
1418
|
1422
|
test 'register_tag';
|
1419
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1423
|
+$dbi = DBIx::Custom->connect(%memory);
|
1420
|
1424
|
$dbi->register_tag(
|
1421
|
1425
|
b => sub { 2 }
|
1422
|
1426
|
);
|
1423
|
1427
|
is($dbi->query_builder->tags->{b}->(), 2);
|
1424
|
1428
|
|
1425
|
1429
|
test 'table not specify exception';
|
1426
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1430
|
+$dbi = DBIx::Custom->connect(%memory);
|
1427
|
1431
|
eval {$dbi->insert};
|
1428
|
1432
|
like($@, qr/table/);
|
1429
|
1433
|
eval {$dbi->update};
|
...
|
...
|
@@ -1435,7 +1439,7 @@ like($@, qr/table/);
|
1435
|
1439
|
|
1436
|
1440
|
|
1437
|
1441
|
test 'more tests';
|
1438
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1442
|
+$dbi = DBIx::Custom->connect(%memory);
|
1439
|
1443
|
eval{$dbi->apply_filter('table', 'column', [])};
|
1440
|
1444
|
like($@, qr/apply_filter/);
|
1441
|
1445
|
|
...
|
...
|
@@ -1445,8 +1449,8 @@ like($@, qr/apply_filter/);
|
1445
|
1449
|
$dbi->apply_filter(
|
1446
|
1450
|
|
1447
|
1451
|
);
|
1448
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1449
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1452
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1453
|
+$dbi->execute($create_table_default);
|
1450
|
1454
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1451
|
1455
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
1452
|
1456
|
$dbi->apply_filter('table1', 'key2',
|
...
|
...
|
@@ -1454,15 +1458,15 @@ $dbi->apply_filter('table1', 'key2',
|
1454
|
1458
|
$rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
|
1455
|
1459
|
is_deeply($rows, [{key1 => 1, key2 => 6}]);
|
1456
|
1460
|
|
1457
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1458
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1461
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1462
|
+$dbi->execute($create_table_default);
|
1459
|
1463
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
1460
|
1464
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
1461
|
1465
|
$dbi->apply_filter('table1', 'key2', {});
|
1462
|
1466
|
$rows = $dbi->select(table => 'table1', where => {key2 => 2})->all;
|
1463
|
1467
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
1464
|
1468
|
|
1465
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1469
|
+$dbi = DBIx::Custom->connect(%memory);
|
1466
|
1470
|
eval {$dbi->apply_filter('table1', 'key2', {out => 'no'})};
|
1467
|
1471
|
like($@, qr/not registered/);
|
1468
|
1472
|
eval {$dbi->apply_filter('table1', 'key2', {in => 'no'})};
|
...
|
...
|
@@ -1473,8 +1477,8 @@ is($dbi->one, 1);
|
1473
|
1477
|
eval{DBIx::Custom->connect()};
|
1474
|
1478
|
like($@, qr/_connect/);
|
1475
|
1479
|
|
1476
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1477
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1480
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1481
|
+$dbi->execute($create_table_default);
|
1478
|
1482
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
1479
|
1483
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
|
1480
|
1484
|
filter => {key1 => 'twice'});
|
...
|
...
|
@@ -1500,8 +1504,8 @@ ok(!defined $dbi->default_fetch_filter);
|
1500
|
1504
|
eval {$dbi->execute('select * from table1 {} {= author') };
|
1501
|
1505
|
like($@, qr/Tag not finished/);
|
1502
|
1506
|
|
1503
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1504
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1507
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
1508
|
+$dbi->execute($create_table_default);
|
1505
|
1509
|
$dbi->register_filter(one => sub { 1 });
|
1506
|
1510
|
$result = $dbi->select(table => 'table1');
|
1507
|
1511
|
eval {$result->filter(key1 => 'no')};
|
...
|
...
|
@@ -1514,10 +1518,10 @@ $result->default_filter('one');
|
1514
|
1518
|
is($result->default_filter->(), 1);
|
1515
|
1519
|
|
1516
|
1520
|
test 'dbi_option';
|
1517
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:',
|
|
1521
|
+$dbi = DBIx::Custom->connect(%memory,
|
1518
|
1522
|
dbi_option => {PrintError => 1});
|
1519
|
1523
|
ok($dbi->dbh->{PrintError});
|
1520
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:',
|
|
1524
|
+$dbi = DBIx::Custom->connect(%memory,
|
1521
|
1525
|
dbi_options => {PrintError => 1});
|
1522
|
1526
|
ok($dbi->dbh->{PrintError});
|
1523
|
1527
|
|
...
|
...
|
@@ -1528,7 +1532,7 @@ $result->stash->{foo} = 1;
|
1528
|
1532
|
is($result->stash->{foo}, 1, 'get and set');
|
1529
|
1533
|
|
1530
|
1534
|
test 'filter __ expression';
|
1531
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1535
|
+$dbi = DBIx::Custom->connect(%memory);
|
1532
|
1536
|
$dbi->execute('create table company (id, name, location_id)');
|
1533
|
1537
|
$dbi->execute('create table location (id, name)');
|
1534
|
1538
|
$dbi->apply_filter('location',
|
...
|
...
|
@@ -1558,7 +1562,7 @@ is($result->fetch_first->[0], 'B');
|
1558
|
1562
|
|
1559
|
1563
|
test 'Model class';
|
1560
|
1564
|
use MyDBI1;
|
1561
|
|
-$dbi = MyDBI1->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1565
|
+$dbi = MyDBI1->connect(%memory);
|
1562
|
1566
|
$dbi->execute("create table book (title, author)");
|
1563
|
1567
|
$model = $dbi->model('book');
|
1564
|
1568
|
$model->insert({title => 'a', author => 'b'});
|
...
|
...
|
@@ -1626,7 +1630,7 @@ is($dbi->models->{'company'}, $dbi->model('company'));
|
1626
|
1630
|
|
1627
|
1631
|
sub list { shift->select; }
|
1628
|
1632
|
}
|
1629
|
|
-$dbi = MyDBI4->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1633
|
+$dbi = MyDBI4->connect(%memory);
|
1630
|
1634
|
$dbi->execute("create table book (title, author)");
|
1631
|
1635
|
$model = $dbi->model('book');
|
1632
|
1636
|
$model->insert({title => 'a', author => 'b'});
|
...
|
...
|
@@ -1650,7 +1654,7 @@ is_deeply($model->list->all, [{name => 'a'}], 'basic');
|
1650
|
1654
|
$self->include_model('MyModel4');
|
1651
|
1655
|
}
|
1652
|
1656
|
}
|
1653
|
|
-$dbi = MyDBI5->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1657
|
+$dbi = MyDBI5->connect(%memory);
|
1654
|
1658
|
$dbi->execute("create table company (name)");
|
1655
|
1659
|
$dbi->execute("create table table1 (key1)");
|
1656
|
1660
|
$model = $dbi->model('company');
|
...
|
...
|
@@ -1662,21 +1666,21 @@ is_deeply($model->list->all, [{key1 => 1}], 'include all model');
|
1662
|
1666
|
|
1663
|
1667
|
test 'primary_key';
|
1664
|
1668
|
use MyDBI1;
|
1665
|
|
-$dbi = MyDBI1->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1669
|
+$dbi = MyDBI1->connect(%memory);
|
1666
|
1670
|
$model = $dbi->model('book');
|
1667
|
1671
|
$model->primary_key(['id', 'number']);
|
1668
|
1672
|
is_deeply($model->primary_key, ['id', 'number']);
|
1669
|
1673
|
|
1670
|
1674
|
test 'columns';
|
1671
|
1675
|
use MyDBI1;
|
1672
|
|
-$dbi = MyDBI1->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1676
|
+$dbi = MyDBI1->connect(%memory);
|
1673
|
1677
|
$model = $dbi->model('book');
|
1674
|
1678
|
$model->columns(['id', 'number']);
|
1675
|
1679
|
is_deeply($model->columns, ['id', 'number']);
|
1676
|
1680
|
|
1677
|
1681
|
test 'setup_model';
|
1678
|
1682
|
use MyDBI1;
|
1679
|
|
-$dbi = MyDBI1->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1683
|
+$dbi = MyDBI1->connect(%memory);
|
1680
|
1684
|
$dbi->execute('create table book (id)');
|
1681
|
1685
|
$dbi->execute('create table company (id, name);');
|
1682
|
1686
|
$dbi->execute('create table test (id, name, primary key (id, name));');
|
...
|
...
|
@@ -1685,7 +1689,7 @@ is_deeply($dbi->model('book')->columns, ['id']);
|
1685
|
1689
|
is_deeply($dbi->model('company')->columns, ['id', 'name']);
|
1686
|
1690
|
|
1687
|
1691
|
test 'delete_at';
|
1688
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1692
|
+$dbi = DBIx::Custom->connect(%memory);
|
1689
|
1693
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1690
|
1694
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1691
|
1695
|
$dbi->delete_at(
|
...
|
...
|
@@ -1704,7 +1708,7 @@ $dbi->delete_at(
|
1704
|
1708
|
is_deeply($dbi->select(table => 'table1')->all, []);
|
1705
|
1709
|
|
1706
|
1710
|
test 'insert_at';
|
1707
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1711
|
+$dbi = DBIx::Custom->connect(%memory);
|
1708
|
1712
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1709
|
1713
|
$dbi->insert_at(
|
1710
|
1714
|
primary_key => ['key1', 'key2'],
|
...
|
...
|
@@ -1739,7 +1743,7 @@ eval {
|
1739
|
1743
|
};
|
1740
|
1744
|
like($@, qr/must be/);
|
1741
|
1745
|
|
1742
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1746
|
+$dbi = DBIx::Custom->connect(%memory);
|
1743
|
1747
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1744
|
1748
|
$dbi->insert_at(
|
1745
|
1749
|
{key3 => 3},
|
...
|
...
|
@@ -1752,7 +1756,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
|
1752
|
1756
|
is($dbi->select(table => 'table1')->one->{key3}, 3);
|
1753
|
1757
|
|
1754
|
1758
|
test 'update_at';
|
1755
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1759
|
+$dbi = DBIx::Custom->connect(%memory);
|
1756
|
1760
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1757
|
1761
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1758
|
1762
|
$dbi->update_at(
|
...
|
...
|
@@ -1777,7 +1781,7 @@ is($dbi->select(table => 'table1')->one->{key1}, 1);
|
1777
|
1781
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
1778
|
1782
|
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
1779
|
1783
|
|
1780
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1784
|
+$dbi = DBIx::Custom->connect(%memory);
|
1781
|
1785
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1782
|
1786
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1783
|
1787
|
$dbi->update_at(
|
...
|
...
|
@@ -1791,7 +1795,7 @@ is($dbi->select(table => 'table1')->one->{key2}, 2);
|
1791
|
1795
|
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
1792
|
1796
|
|
1793
|
1797
|
test 'select_at';
|
1794
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1798
|
+$dbi = DBIx::Custom->connect(%memory);
|
1795
|
1799
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1796
|
1800
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1797
|
1801
|
$result = $dbi->select_at(
|
...
|
...
|
@@ -1867,7 +1871,7 @@ like($@, qr/must be/);
|
1867
|
1871
|
|
1868
|
1872
|
test 'columns';
|
1869
|
1873
|
use MyDBI1;
|
1870
|
|
-$dbi = MyDBI1->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1874
|
+$dbi = MyDBI1->connect(%memory);
|
1871
|
1875
|
$model = $dbi->model('book');
|
1872
|
1876
|
|
1873
|
1877
|
|
...
|
...
|
@@ -1885,7 +1889,7 @@ test 'model delete_at';
|
1885
|
1889
|
return $self;
|
1886
|
1890
|
}
|
1887
|
1891
|
}
|
1888
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1892
|
+$dbi = MyDBI6->connect(%memory);
|
1889
|
1893
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1890
|
1894
|
$dbi->execute("create table table2 (key1, key2, key3)");
|
1891
|
1895
|
$dbi->execute("create table table3 (key1, key2, key3)");
|
...
|
...
|
@@ -1900,7 +1904,7 @@ $dbi->model('table1_3')->delete_at(where => [1, 2]);
|
1900
|
1904
|
is_deeply($dbi->select(table => 'table1')->all, []);
|
1901
|
1905
|
|
1902
|
1906
|
test 'model insert_at';
|
1903
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1907
|
+$dbi = MyDBI6->connect(%memory);
|
1904
|
1908
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1905
|
1909
|
$dbi->model('table1')->insert_at(
|
1906
|
1910
|
where => [1, 2],
|
...
|
...
|
@@ -1913,7 +1917,7 @@ is($row->{key2}, 2);
|
1913
|
1917
|
is($row->{key3}, 3);
|
1914
|
1918
|
|
1915
|
1919
|
test 'model update_at';
|
1916
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1920
|
+$dbi = MyDBI6->connect(%memory);
|
1917
|
1921
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1918
|
1922
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1919
|
1923
|
$dbi->model('table1')->update_at(
|
...
|
...
|
@@ -1927,7 +1931,7 @@ is($row->{key2}, 2);
|
1927
|
1931
|
is($row->{key3}, 4);
|
1928
|
1932
|
|
1929
|
1933
|
test 'model select_at';
|
1930
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1934
|
+$dbi = MyDBI6->connect(%memory);
|
1931
|
1935
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1932
|
1936
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
1933
|
1937
|
$result = $dbi->model('table1')->select_at(where => [1, 2]);
|
...
|
...
|
@@ -1952,8 +1956,8 @@ test 'mycolumn and column';
|
1952
|
1956
|
return $self;
|
1953
|
1957
|
}
|
1954
|
1958
|
}
|
1955
|
|
-$dbi = MyDBI7->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
1956
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
1959
|
+$dbi = MyDBI7->connect(%memory);
|
|
1960
|
+$dbi->execute($create_table_default);
|
1957
|
1961
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
1958
|
1962
|
$dbi->separator('__');
|
1959
|
1963
|
$dbi->setup_model;
|
...
|
...
|
@@ -1968,7 +1972,7 @@ is_deeply($result->one,
|
1968
|
1972
|
{key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3});
|
1969
|
1973
|
|
1970
|
1974
|
test 'update_param';
|
1971
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1975
|
+$dbi = DBIx::Custom->connect(%memory);
|
1972
|
1976
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1973
|
1977
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
1974
|
1978
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -1987,7 +1991,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
1987
|
1991
|
"basic");
|
1988
|
1992
|
|
1989
|
1993
|
|
1990
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
1994
|
+$dbi = DBIx::Custom->connect(%memory);
|
1991
|
1995
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
1992
|
1996
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
1993
|
1997
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -2005,7 +2009,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
|
2005
|
2009
|
{key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}],
|
2006
|
2010
|
"basic");
|
2007
|
2011
|
|
2008
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2012
|
+$dbi = DBIx::Custom->connect(%memory);
|
2009
|
2013
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2010
|
2014
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
2011
|
2015
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -2029,7 +2033,7 @@ like($@, qr/not safety/);
|
2029
|
2033
|
|
2030
|
2034
|
|
2031
|
2035
|
test 'update_param';
|
2032
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2036
|
+$dbi = DBIx::Custom->connect(%memory);
|
2033
|
2037
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2034
|
2038
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
|
2035
|
2039
|
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
|
...
|
...
|
@@ -2049,7 +2053,7 @@ is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
|
2049
|
2053
|
|
2050
|
2054
|
|
2051
|
2055
|
test 'insert_param';
|
2052
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2056
|
+$dbi = DBIx::Custom->connect(%memory);
|
2053
|
2057
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2054
|
2058
|
$param = {key1 => 1, key2 => 2};
|
2055
|
2059
|
$insert_param = $dbi->insert_param($param);
|
...
|
...
|
@@ -2060,7 +2064,7 @@ $dbi->execute($sql, param => $param, table => 'table1');
|
2060
|
2064
|
is($dbi->select(table => 'table1')->one->{key1}, 1);
|
2061
|
2065
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
2062
|
2066
|
|
2063
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2067
|
+$dbi = DBIx::Custom->connect(%memory);
|
2064
|
2068
|
$dbi->quote('"');
|
2065
|
2069
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2066
|
2070
|
$param = {key1 => 1, key2 => 2};
|
...
|
...
|
@@ -2077,8 +2081,8 @@ like($@, qr/not safety/);
|
2077
|
2081
|
|
2078
|
2082
|
|
2079
|
2083
|
test 'join';
|
2080
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2081
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2084
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2085
|
+$dbi->execute($create_table_default);
|
2082
|
2086
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2083
|
2087
|
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
|
2084
|
2088
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
...
|
...
|
@@ -2136,9 +2140,9 @@ $rows = $dbi->select(
|
2136
|
2140
|
)->all;
|
2137
|
2141
|
is_deeply($rows, [{table1__key1 => 1}]);
|
2138
|
2142
|
|
2139
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2143
|
+$dbi = DBIx::Custom->connect(%memory);
|
2140
|
2144
|
$dbi->quote('"');
|
2141
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2145
|
+$dbi->execute($create_table_default);
|
2142
|
2146
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2143
|
2147
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2144
|
2148
|
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
|
...
|
...
|
@@ -2165,8 +2169,8 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
|
2165
|
2169
|
}
|
2166
|
2170
|
}
|
2167
|
2171
|
|
2168
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2169
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2172
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2173
|
+$dbi->execute($create_table_default);
|
2170
|
2174
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2171
|
2175
|
$sql = <<"EOS";
|
2172
|
2176
|
left outer join (
|
...
|
...
|
@@ -2185,8 +2189,8 @@ $rows = $dbi->select(
|
2185
|
2189
|
)->all;
|
2186
|
2190
|
is_deeply($rows, [{latest_table1__key1 => 1}]);
|
2187
|
2191
|
|
2188
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2189
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2192
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2193
|
+$dbi->execute($create_table_default);
|
2190
|
2194
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2191
|
2195
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2192
|
2196
|
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
|
...
|
...
|
@@ -2215,8 +2219,8 @@ $result = $dbi->select(
|
2215
|
2219
|
);
|
2216
|
2220
|
is_deeply($result->all, [{'table2.key3' => 4}]);
|
2217
|
2221
|
|
2218
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2219
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2222
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2223
|
+$dbi->execute($create_table_default);
|
2220
|
2224
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2221
|
2225
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2222
|
2226
|
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
|
...
|
...
|
@@ -2234,8 +2238,8 @@ $result = $dbi->select(
|
2234
|
2238
|
is_deeply($result->all, [{'table2.key3' => 4}]);
|
2235
|
2239
|
|
2236
|
2240
|
test 'mycolumn';
|
2237
|
|
-$dbi = MyDBI8->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2238
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2241
|
+$dbi = MyDBI8->connect(%memory);
|
|
2242
|
+$dbi->execute($create_table_default);
|
2239
|
2243
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2240
|
2244
|
$dbi->setup_model;
|
2241
|
2245
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -2299,15 +2303,15 @@ test 'dbi method from model';
|
2299
|
2303
|
return $self;
|
2300
|
2304
|
}
|
2301
|
2305
|
}
|
2302
|
|
-$dbi = MyDBI9->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2303
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2306
|
+$dbi = MyDBI9->connect(%memory);
|
|
2307
|
+$dbi->execute($create_table_default);
|
2304
|
2308
|
$model = $dbi->model('table1');
|
2305
|
2309
|
eval{$model->execute('select * from table1')};
|
2306
|
2310
|
ok(!$@);
|
2307
|
2311
|
|
2308
|
2312
|
test 'column table option';
|
2309
|
|
-$dbi = MyDBI9->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2310
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2313
|
+$dbi = MyDBI9->connect(%memory);
|
|
2314
|
+$dbi->execute($create_table_default);
|
2311
|
2315
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2312
|
2316
|
$dbi->setup_model;
|
2313
|
2317
|
$dbi->execute('insert into table1 (key1, key2) values (1, 2);');
|
...
|
...
|
@@ -2412,8 +2416,8 @@ $row = $result->one;
|
2412
|
2416
|
is($row->{key1_length}, length $binary);
|
2413
|
2417
|
|
2414
|
2418
|
test 'create_model';
|
2415
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2416
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2419
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2420
|
+$dbi->execute($create_table_default);
|
2417
|
2421
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2418
|
2422
|
|
2419
|
2423
|
$dbi->create_model(
|
...
|
...
|
@@ -2446,7 +2450,7 @@ is_deeply($model2->select->one, {key1 => 1, key3 => 3});
|
2446
|
2450
|
|
2447
|
2451
|
test 'model method';
|
2448
|
2452
|
test 'create_model';
|
2449
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2453
|
+$dbi = DBIx::Custom->connect(%memory);
|
2450
|
2454
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2451
|
2455
|
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
|
2452
|
2456
|
$model = $dbi->create_model(
|
...
|
...
|
@@ -2474,8 +2478,8 @@ test 'merge_param';
|
2474
|
2478
|
}
|
2475
|
2479
|
|
2476
|
2480
|
test 'select() param option';
|
2477
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2478
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2481
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2482
|
+$dbi->execute($create_table_default);
|
2479
|
2483
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2480
|
2484
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
2481
|
2485
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
...
|
...
|
@@ -2493,8 +2497,8 @@ is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]);
|
2493
|
2497
|
|
2494
|
2498
|
|
2495
|
2499
|
test 'select() wrap option';
|
2496
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2497
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2500
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2501
|
+$dbi->execute($create_table_default);
|
2498
|
2502
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2499
|
2503
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
2500
|
2504
|
$rows = $dbi->select(
|
...
|
...
|
@@ -2514,8 +2518,8 @@ $dbi->select(
|
2514
|
2518
|
like($@, qr/array/);
|
2515
|
2519
|
|
2516
|
2520
|
test 'select() string where';
|
2517
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2518
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2521
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2522
|
+$dbi->execute($create_table_default);
|
2519
|
2523
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2520
|
2524
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
2521
|
2525
|
$rows = $dbi->select(
|
...
|
...
|
@@ -2525,8 +2529,8 @@ $rows = $dbi->select(
|
2525
|
2529
|
)->all;
|
2526
|
2530
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
2527
|
2531
|
|
2528
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2529
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2532
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2533
|
+$dbi->execute($create_table_default);
|
2530
|
2534
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2531
|
2535
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
2532
|
2536
|
$rows = $dbi->select(
|
...
|
...
|
@@ -2539,8 +2543,8 @@ $rows = $dbi->select(
|
2539
|
2543
|
is_deeply($rows, [{key1 => 1, key2 => 2}]);
|
2540
|
2544
|
|
2541
|
2545
|
test 'delete() string where';
|
2542
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2543
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2546
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2547
|
+$dbi->execute($create_table_default);
|
2544
|
2548
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2545
|
2549
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
2546
|
2550
|
$dbi->delete(
|
...
|
...
|
@@ -2551,8 +2555,8 @@ $dbi->delete(
|
2551
|
2555
|
$rows = $dbi->select(table => 'table1')->all;
|
2552
|
2556
|
is_deeply($rows, [{key1 => 2, key2 => 3}]);
|
2553
|
2557
|
|
2554
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2555
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2558
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2559
|
+$dbi->execute($create_table_default);
|
2556
|
2560
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2557
|
2561
|
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
|
2558
|
2562
|
$dbi->delete(
|
...
|
...
|
@@ -2567,8 +2571,8 @@ is_deeply($rows, [{key1 => 2, key2 => 3}]);
|
2567
|
2571
|
|
2568
|
2572
|
|
2569
|
2573
|
test 'update() string where';
|
2570
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2571
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2574
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2575
|
+$dbi->execute($create_table_default);
|
2572
|
2576
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2573
|
2577
|
$dbi->update(
|
2574
|
2578
|
table => 'table1',
|
...
|
...
|
@@ -2579,8 +2583,8 @@ $dbi->update(
|
2579
|
2583
|
$rows = $dbi->select(table => 'table1')->all;
|
2580
|
2584
|
is_deeply($rows, [{key1 => 5, key2 => 2}]);
|
2581
|
2585
|
|
2582
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2583
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2586
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
2587
|
+$dbi->execute($create_table_default);
|
2584
|
2588
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
2585
|
2589
|
$dbi->update(
|
2586
|
2590
|
table => 'table1',
|
...
|
...
|
@@ -2594,7 +2598,7 @@ $rows = $dbi->select(table => 'table1')->all;
|
2594
|
2598
|
is_deeply($rows, [{key1 => 5, key2 => 2}]);
|
2595
|
2599
|
|
2596
|
2600
|
test 'insert id and primary_key option';
|
2597
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2601
|
+$dbi = DBIx::Custom->connect(%memory);
|
2598
|
2602
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2599
|
2603
|
$dbi->insert(
|
2600
|
2604
|
primary_key => ['key1', 'key2'],
|
...
|
...
|
@@ -2618,7 +2622,7 @@ is($dbi->select(table => 'table1')->one->{key1}, 0);
|
2618
|
2622
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
2619
|
2623
|
is($dbi->select(table => 'table1')->one->{key3}, 3);
|
2620
|
2624
|
|
2621
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2625
|
+$dbi = DBIx::Custom->connect(%memory);
|
2622
|
2626
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2623
|
2627
|
$dbi->insert(
|
2624
|
2628
|
{key3 => 3},
|
...
|
...
|
@@ -2632,7 +2636,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 3);
|
2632
|
2636
|
|
2633
|
2637
|
|
2634
|
2638
|
test 'model insert id and primary_key option';
|
2635
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2639
|
+$dbi = MyDBI6->connect(%memory);
|
2636
|
2640
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2637
|
2641
|
$dbi->model('table1')->insert(
|
2638
|
2642
|
id => [1, 2],
|
...
|
...
|
@@ -2644,7 +2648,7 @@ is($row->{key1}, 1);
|
2644
|
2648
|
is($row->{key2}, 2);
|
2645
|
2649
|
is($row->{key3}, 3);
|
2646
|
2650
|
|
2647
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2651
|
+$dbi = MyDBI6->connect(%memory);
|
2648
|
2652
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2649
|
2653
|
$dbi->model('table1')->insert(
|
2650
|
2654
|
{key3 => 3},
|
...
|
...
|
@@ -2657,7 +2661,7 @@ is($row->{key2}, 2);
|
2657
|
2661
|
is($row->{key3}, 3);
|
2658
|
2662
|
|
2659
|
2663
|
test 'update and id option';
|
2660
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2664
|
+$dbi = DBIx::Custom->connect(%memory);
|
2661
|
2665
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2662
|
2666
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2663
|
2667
|
$dbi->update(
|
...
|
...
|
@@ -2682,7 +2686,7 @@ is($dbi->select(table => 'table1')->one->{key1}, 0);
|
2682
|
2686
|
is($dbi->select(table => 'table1')->one->{key2}, 2);
|
2683
|
2687
|
is($dbi->select(table => 'table1')->one->{key3}, 4);
|
2684
|
2688
|
|
2685
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2689
|
+$dbi = DBIx::Custom->connect(%memory);
|
2686
|
2690
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2687
|
2691
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2688
|
2692
|
$dbi->update(
|
...
|
...
|
@@ -2697,7 +2701,7 @@ is($dbi->select(table => 'table1')->one->{key3}, 4);
|
2697
|
2701
|
|
2698
|
2702
|
|
2699
|
2703
|
test 'model update and id option';
|
2700
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2704
|
+$dbi = MyDBI6->connect(%memory);
|
2701
|
2705
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2702
|
2706
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2703
|
2707
|
$dbi->model('table1')->update(
|
...
|
...
|
@@ -2712,7 +2716,7 @@ is($row->{key3}, 4);
|
2712
|
2716
|
|
2713
|
2717
|
|
2714
|
2718
|
test 'delete and id option';
|
2715
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2719
|
+$dbi = DBIx::Custom->connect(%memory);
|
2716
|
2720
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2717
|
2721
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2718
|
2722
|
$dbi->delete(
|
...
|
...
|
@@ -2732,7 +2736,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
|
2732
|
2736
|
|
2733
|
2737
|
|
2734
|
2738
|
test 'model delete and id option';
|
2735
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2739
|
+$dbi = MyDBI6->connect(%memory);
|
2736
|
2740
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2737
|
2741
|
$dbi->execute("create table table2 (key1, key2, key3)");
|
2738
|
2742
|
$dbi->execute("create table table3 (key1, key2, key3)");
|
...
|
...
|
@@ -2748,7 +2752,7 @@ is_deeply($dbi->select(table => 'table1')->all, []);
|
2748
|
2752
|
|
2749
|
2753
|
|
2750
|
2754
|
test 'select and id option';
|
2751
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2755
|
+$dbi = DBIx::Custom->connect(%memory);
|
2752
|
2756
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2753
|
2757
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2754
|
2758
|
$result = $dbi->select(
|
...
|
...
|
@@ -2787,7 +2791,7 @@ is($row->{key3}, 3);
|
2787
|
2791
|
|
2788
|
2792
|
|
2789
|
2793
|
test 'model select_at';
|
2790
|
|
-$dbi = MyDBI6->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2794
|
+$dbi = MyDBI6->connect(%memory);
|
2791
|
2795
|
$dbi->execute('create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));');
|
2792
|
2796
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
|
2793
|
2797
|
$result = $dbi->model('table1')->select(id => [1, 2]);
|
...
|
...
|
@@ -2797,8 +2801,8 @@ is($row->{key2}, 2);
|
2797
|
2801
|
is($row->{key3}, 3);
|
2798
|
2802
|
|
2799
|
2803
|
test 'column separator is default .';
|
2800
|
|
-$dbi = MyDBI7->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
2801
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
2804
|
+$dbi = MyDBI7->connect(%memory);
|
|
2805
|
+$dbi->execute($create_table_default);
|
2802
|
2806
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
2803
|
2807
|
$dbi->setup_model;
|
2804
|
2808
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
...
|
...
|
@@ -2820,7 +2824,7 @@ is_deeply($result->one,
|
2820
|
2824
|
|
2821
|
2825
|
|
2822
|
2826
|
test 'type_rule from';
|
2823
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2827
|
+$dbi = DBIx::Custom->connect(%memory);
|
2824
|
2828
|
$dbi->type_rule(
|
2825
|
2829
|
from1 => {
|
2826
|
2830
|
date => sub { uc $_[0] }
|
...
|
...
|
@@ -2836,7 +2840,7 @@ is($result->one->{key1}, 'A');
|
2836
|
2840
|
|
2837
|
2841
|
|
2838
|
2842
|
test 'type_rule into';
|
2839
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2843
|
+$dbi = DBIx::Custom->connect(%memory);
|
2840
|
2844
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2841
|
2845
|
$dbi->type_rule(
|
2842
|
2846
|
into1 => {
|
...
|
...
|
@@ -2847,7 +2851,7 @@ $dbi->insert({key1 => 'a'}, table => 'table1');
|
2847
|
2851
|
$result = $dbi->select(table => 'table1');
|
2848
|
2852
|
is($result->one->{key1}, 'A');
|
2849
|
2853
|
|
2850
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2854
|
+$dbi = DBIx::Custom->connect(%memory);
|
2851
|
2855
|
$dbi->execute("create table table1 (key1 date, key2 datetime)");
|
2852
|
2856
|
$dbi->type_rule(
|
2853
|
2857
|
into1 => [
|
...
|
...
|
@@ -2860,7 +2864,7 @@ $row = $result->one;
|
2860
|
2864
|
is($row->{key1}, 'A');
|
2861
|
2865
|
is($row->{key2}, 'B');
|
2862
|
2866
|
|
2863
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2867
|
+$dbi = DBIx::Custom->connect(%memory);
|
2864
|
2868
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2865
|
2869
|
$dbi->insert({key1 => 'a', key2 => 'B'}, table => 'table1');
|
2866
|
2870
|
$dbi->type_rule(
|
...
|
...
|
@@ -2876,7 +2880,7 @@ $row = $result->one;
|
2876
|
2880
|
is($row->{key1}, 'a');
|
2877
|
2881
|
is($row->{key2}, 'B');
|
2878
|
2882
|
|
2879
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2883
|
+$dbi = DBIx::Custom->connect(%memory);
|
2880
|
2884
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2881
|
2885
|
$dbi->insert({key1 => 'A', key2 => 'B'}, table => 'table1');
|
2882
|
2886
|
$dbi->type_rule(
|
...
|
...
|
@@ -2893,7 +2897,7 @@ $row = $result->one;
|
2893
|
2897
|
is($row->{key1}, 'A');
|
2894
|
2898
|
is($row->{key2}, 'B');
|
2895
|
2899
|
|
2896
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2900
|
+$dbi = DBIx::Custom->connect(%memory);
|
2897
|
2901
|
$dbi->execute("create table table1 (key1 date, key2 datetime)");
|
2898
|
2902
|
$dbi->register_filter(twice => sub { $_[0] * 2 });
|
2899
|
2903
|
$dbi->type_rule(
|
...
|
...
|
@@ -2909,7 +2913,7 @@ $result = $dbi->select(table => 'table1');
|
2909
|
2913
|
is($result->fetch->[0], 8);
|
2910
|
2914
|
|
2911
|
2915
|
test 'type_rule and filter order';
|
2912
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2916
|
+$dbi = DBIx::Custom->connect(%memory);
|
2913
|
2917
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2914
|
2918
|
$dbi->type_rule(
|
2915
|
2919
|
into1 => {
|
...
|
...
|
@@ -2930,7 +2934,7 @@ $result = $dbi->select(table => 'table1');
|
2930
|
2934
|
$result->filter(key1 => sub { $_[0] . 'f' });
|
2931
|
2935
|
is($result->fetch_first->[0], '1abcdef');
|
2932
|
2936
|
|
2933
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2937
|
+$dbi = DBIx::Custom->connect(%memory);
|
2934
|
2938
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2935
|
2939
|
$dbi->type_rule(
|
2936
|
2940
|
from1 => {
|
...
|
...
|
@@ -2954,7 +2958,7 @@ $result->filter(key1 => sub { $_[0] . 'f' });
|
2954
|
2958
|
is($result->fetch_first->[0], '1def');
|
2955
|
2959
|
|
2956
|
2960
|
test 'type_rule_off';
|
2957
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2961
|
+$dbi = DBIx::Custom->connect(%memory);
|
2958
|
2962
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2959
|
2963
|
$dbi->type_rule(
|
2960
|
2964
|
from1 => {
|
...
|
...
|
@@ -2968,7 +2972,7 @@ $dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
|
2968
|
2972
|
$result = $dbi->select(table => 'table1', type_rule_off => 1);
|
2969
|
2973
|
is($result->type_rule_off->fetch->[0], 2);
|
2970
|
2974
|
|
2971
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2975
|
+$dbi = DBIx::Custom->connect(%memory);
|
2972
|
2976
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2973
|
2977
|
$dbi->type_rule(
|
2974
|
2978
|
from1 => {
|
...
|
...
|
@@ -2982,7 +2986,7 @@ $dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
|
2982
|
2986
|
$result = $dbi->select(table => 'table1', type_rule_off => 1);
|
2983
|
2987
|
is($result->one->{key1}, 4);
|
2984
|
2988
|
|
2985
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
2989
|
+$dbi = DBIx::Custom->connect(%memory);
|
2986
|
2990
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
2987
|
2991
|
$dbi->type_rule(
|
2988
|
2992
|
from1 => {
|
...
|
...
|
@@ -2996,7 +3000,7 @@ $dbi->insert({key1 => 2}, table => 'table1');
|
2996
|
3000
|
$result = $dbi->select(table => 'table1');
|
2997
|
3001
|
is($result->one->{key1}, 12);
|
2998
|
3002
|
|
2999
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3003
|
+$dbi = DBIx::Custom->connect(%memory);
|
3000
|
3004
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3001
|
3005
|
$dbi->type_rule(
|
3002
|
3006
|
from1 => {
|
...
|
...
|
@@ -3010,7 +3014,7 @@ $dbi->insert({key1 => 2}, table => 'table1');
|
3010
|
3014
|
$result = $dbi->select(table => 'table1');
|
3011
|
3015
|
is($result->fetch->[0], 12);
|
3012
|
3016
|
|
3013
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3017
|
+$dbi = DBIx::Custom->connect(%memory);
|
3014
|
3018
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3015
|
3019
|
$dbi->register_filter(ppp => sub { uc $_[0] });
|
3016
|
3020
|
$dbi->type_rule(
|
...
|
...
|
@@ -3029,7 +3033,7 @@ eval{$dbi->type_rule(
|
3029
|
3033
|
)};
|
3030
|
3034
|
like($@, qr/not registered/);
|
3031
|
3035
|
|
3032
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3036
|
+$dbi = DBIx::Custom->connect(%memory);
|
3033
|
3037
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3034
|
3038
|
eval {
|
3035
|
3039
|
$dbi->type_rule(
|
...
|
...
|
@@ -3049,7 +3053,7 @@ eval {
|
3049
|
3053
|
};
|
3050
|
3054
|
like($@, qr/lower/);
|
3051
|
3055
|
|
3052
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3056
|
+$dbi = DBIx::Custom->connect(%memory);
|
3053
|
3057
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3054
|
3058
|
$dbi->type_rule(
|
3055
|
3059
|
from1 => {
|
...
|
...
|
@@ -3064,7 +3068,7 @@ $result = $dbi->select(table => 'table1');
|
3064
|
3068
|
$result->type_rule_off;
|
3065
|
3069
|
is($result->one->{key1}, 6);
|
3066
|
3070
|
|
3067
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3071
|
+$dbi = DBIx::Custom->connect(%memory);
|
3068
|
3072
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3069
|
3073
|
$dbi->type_rule(
|
3070
|
3074
|
from1 => {
|
...
|
...
|
@@ -3125,7 +3129,7 @@ $row = $result->one;
|
3125
|
3129
|
is($row->{key1}, 2);
|
3126
|
3130
|
is($row->{key2}, 2);
|
3127
|
3131
|
|
3128
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3132
|
+$dbi = DBIx::Custom->connect(%memory);
|
3129
|
3133
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3130
|
3134
|
$dbi->type_rule(
|
3131
|
3135
|
from1 => {
|
...
|
...
|
@@ -3137,7 +3141,7 @@ $result = $dbi->select(table => 'table1');
|
3137
|
3141
|
$result->filter(key1 => sub { $_[0] * 3 });
|
3138
|
3142
|
is($result->one->{key1}, 12);
|
3139
|
3143
|
|
3140
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3144
|
+$dbi = DBIx::Custom->connect(%memory);
|
3141
|
3145
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3142
|
3146
|
$dbi->type_rule(
|
3143
|
3147
|
from1 => {
|
...
|
...
|
@@ -3149,7 +3153,7 @@ $result = $dbi->select(table => 'table1');
|
3149
|
3153
|
$result->filter(key1 => sub { $_[0] * 3 });
|
3150
|
3154
|
is($result->fetch->[0], 12);
|
3151
|
3155
|
|
3152
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3156
|
+$dbi = DBIx::Custom->connect(%memory);
|
3153
|
3157
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3154
|
3158
|
$dbi->type_rule(
|
3155
|
3159
|
into1 => {
|
...
|
...
|
@@ -3171,7 +3175,7 @@ is($result->type_rule_off->fetch_first->[0], '1');
|
3171
|
3175
|
$result = $dbi->select(table => 'table1');
|
3172
|
3176
|
is($result->type_rule_on->fetch_first->[0], '1de');
|
3173
|
3177
|
|
3174
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3178
|
+$dbi = DBIx::Custom->connect(%memory);
|
3175
|
3179
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3176
|
3180
|
$dbi->type_rule(
|
3177
|
3181
|
into1 => {
|
...
|
...
|
@@ -3193,7 +3197,7 @@ is($result->type_rule1_off->fetch_first->[0], '1ce');
|
3193
|
3197
|
$result = $dbi->select(table => 'table1');
|
3194
|
3198
|
is($result->type_rule1_on->fetch_first->[0], '1cde');
|
3195
|
3199
|
|
3196
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3200
|
+$dbi = DBIx::Custom->connect(%memory);
|
3197
|
3201
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3198
|
3202
|
$dbi->type_rule(
|
3199
|
3203
|
into1 => {
|
...
|
...
|
@@ -3216,8 +3220,8 @@ $result = $dbi->select(table => 'table1');
|
3216
|
3220
|
is($result->type_rule2_on->fetch_first->[0], '1bde');
|
3217
|
3221
|
|
3218
|
3222
|
test 'separator';
|
3219
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
3220
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
3223
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
3224
|
+$dbi->execute($create_table_default);
|
3221
|
3225
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
3222
|
3226
|
|
3223
|
3227
|
$dbi->create_model(
|
...
|
...
|
@@ -3273,8 +3277,8 @@ is_deeply($model2->select->one, {key1 => 1, key3 => 3});
|
3273
|
3277
|
|
3274
|
3278
|
|
3275
|
3279
|
test 'filter_off';
|
3276
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
3277
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
3280
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
3281
|
+$dbi->execute($create_table_default);
|
3278
|
3282
|
$dbi->execute('create table table2 (key1 char(255), key3 char(255));');
|
3279
|
3283
|
|
3280
|
3284
|
$dbi->create_model(
|
...
|
...
|
@@ -3292,20 +3296,20 @@ $result->filter(key1 => sub { $_[0] * 2 });
|
3292
|
3296
|
is_deeply($result->one, {key1 => 2});
|
3293
|
3297
|
|
3294
|
3298
|
test 'available_date_type';
|
3295
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3299
|
+$dbi = DBIx::Custom->connect(%memory);
|
3296
|
3300
|
ok($dbi->can('available_data_type'));
|
3297
|
3301
|
|
3298
|
3302
|
|
3299
|
3303
|
test 'select prefix option';
|
3300
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
3301
|
|
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
|
|
3304
|
+$dbi = DBIx::Custom->connect(%memory);
|
|
3305
|
+$dbi->execute($create_table_default);
|
3302
|
3306
|
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
|
3303
|
3307
|
$rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all;
|
3304
|
3308
|
is_deeply($rows, [{key1 => 1, key2 => 2}], "table");
|
3305
|
3309
|
|
3306
|
3310
|
|
3307
|
3311
|
test 'separator';
|
3308
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3312
|
+$dbi = DBIx::Custom->connect(%memory);
|
3309
|
3313
|
is($dbi->separator, '.');
|
3310
|
3314
|
$dbi->separator('-');
|
3311
|
3315
|
is($dbi->separator, '-');
|
...
|
...
|
@@ -3316,7 +3320,7 @@ like($@, qr/Separator/);
|
3316
|
3320
|
|
3317
|
3321
|
|
3318
|
3322
|
test 'map_param';
|
3319
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3323
|
+$dbi = DBIx::Custom->connect(%memory);
|
3320
|
3324
|
$param = $dbi->map_param(
|
3321
|
3325
|
{id => 1, author => 'Ken', price => 1900},
|
3322
|
3326
|
id => 'book.id',
|
...
|
...
|
@@ -3360,7 +3364,7 @@ is_deeply($param, {'book.price' => '%a'});
|
3360
|
3364
|
|
3361
|
3365
|
|
3362
|
3366
|
test 'table_alias';
|
3363
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3367
|
+$dbi = DBIx::Custom->connect(%memory);
|
3364
|
3368
|
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
|
3365
|
3369
|
$dbi->type_rule(
|
3366
|
3370
|
into1 => {
|
...
|
...
|
@@ -3374,7 +3378,7 @@ is($result->one->{key1}, 'A');
|
3374
|
3378
|
|
3375
|
3379
|
|
3376
|
3380
|
test 'order';
|
3377
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3381
|
+$dbi = DBIx::Custom->connect(%memory);
|
3378
|
3382
|
{
|
3379
|
3383
|
$dbi->execute("create table table1 (key1, key2)");
|
3380
|
3384
|
$dbi->insert({key1 => 1, key2 => 1}, table => 'table1');
|
...
|
...
|
@@ -3403,7 +3407,7 @@ $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
3403
|
3407
|
}
|
3404
|
3408
|
|
3405
|
3409
|
test 'tag_parse';
|
3406
|
|
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3410
|
+$dbi = DBIx::Custom->connect(%memory);
|
3407
|
3411
|
$dbi->tag_parse(0);
|
3408
|
3412
|
{
|
3409
|
3413
|
$dbi->execute("create table table1 (key1, key2)");
|
...
|
...
|
@@ -3414,7 +3418,7 @@ $dbi->tag_parse(0);
|
3414
|
3418
|
|
3415
|
3419
|
test 'last_sql';
|
3416
|
3420
|
{
|
3417
|
|
- my $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3421
|
+ my $dbi = DBIx::Custom->connect(%memory);
|
3418
|
3422
|
$dbi->execute("create table table1 (key1, key2)");
|
3419
|
3423
|
$dbi->execute('select * from table1');
|
3420
|
3424
|
is($dbi->last_sql, 'select * from table1;');
|
...
|
...
|
@@ -3426,7 +3430,7 @@ test 'last_sql';
|
3426
|
3430
|
|
3427
|
3431
|
test 'DBIx::Custom header';
|
3428
|
3432
|
{
|
3429
|
|
- my $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
|
|
3433
|
+ my $dbi = DBIx::Custom->connect(%memory);
|
3430
|
3434
|
$dbi->execute("create table table1 (key1, key2)");
|
3431
|
3435
|
my $result = $dbi->execute('select key1 as h1, key2 as h2 from table1');
|
3432
|
3436
|
|
...
|
...
|
@@ -3506,4 +3510,5 @@ $rows = [
|
3506
|
3510
|
]
|
3507
|
3511
|
);
|
3508
|
3512
|
}
|
|
3513
|
+
|
3509
|
3514
|
=cut
|