DBIx-Custom / t / dbix-custom-core-sqlite.t /
Newer Older
3142 lines | 99.77kb
removed register_format()
yuki-kimoto authored on 2010-05-26
1
use Test::More;
2
use strict;
3
use warnings;
4

            
5
use utf8;
6
use Encode qw/encode_utf8 decode_utf8/;
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
7
use Data::Dumper;
removed register_format()
yuki-kimoto authored on 2010-05-26
8

            
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
9
$SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
removed EXPERIMETNAL select(...
Yuki Kimoto authored on 2011-04-01
10

            
removed register_format()
yuki-kimoto authored on 2010-05-26
11
BEGIN {
12
    eval { require DBD::SQLite; 1 }
13
        or plan skip_all => 'DBD::SQLite required';
14
    eval { DBD::SQLite->VERSION >= 1.25 }
15
        or plan skip_all => 'DBD::SQLite >= 1.25 required';
16

            
17
    plan 'no_plan';
18
    use_ok('DBIx::Custom');
19
}
20

            
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
21
use FindBin;
22
use lib "$FindBin::Bin/dbix-custom-core-sqlite";
23

            
removed register_format()
yuki-kimoto authored on 2010-05-26
24
# Function for test name
table object call dbi object...
Yuki Kimoto authored on 2011-01-25
25
sub test { print "# $_[0]\n" }
removed register_format()
yuki-kimoto authored on 2010-05-26
26

            
27
# Constant varialbes for test
28
my $CREATE_TABLE = {
29
    0 => 'create table table1 (key1 char(255), key2 char(255));',
30
    1 => 'create table table1 (key1 char(255), key2 char(255), key3 char(255), key4 char(255), key5 char(255));',
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
31
    2 => 'create table table2 (key1 char(255), key3 char(255));',
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
32
    3 => 'create table table1 (key1 Date, key2 datetime);',
33
    4 => 'create table table3 (key3 int, key4 int);'
removed register_format()
yuki-kimoto authored on 2010-05-26
34
};
35

            
add tests
yuki-kimoto authored on 2010-08-10
36
my $SELECT_SOURCES = {
removed register_format()
yuki-kimoto authored on 2010-05-26
37
    0 => 'select * from table1;'
38
};
39

            
40
my $DROP_TABLE = {
41
    0 => 'drop table table1'
42
};
43

            
44
my $NEW_ARGS = {
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
45
    0 => {dsn => 'dbi:SQLite:dbname=:memory:'}
removed register_format()
yuki-kimoto authored on 2010-05-26
46
};
47

            
48
# Variables
49
my $dbi;
50
my $sth;
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
51
my $source;
52
my @sources;
add tests
yuki-kimoto authored on 2010-08-10
53
my $select_SOURCE;
54
my $insert_SOURCE;
55
my $update_SOURCE;
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
56
my $param;
removed register_format()
yuki-kimoto authored on 2010-05-26
57
my $params;
58
my $sql;
59
my $result;
60
my $row;
61
my @rows;
62
my $rows;
63
my $query;
64
my @queries;
65
my $select_query;
66
my $insert_query;
67
my $update_query;
68
my $ret_val;
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
69
my $infos;
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
70
my $model;
create_model() return model
Yuki Kimoto authored on 2011-03-29
71
my $model2;
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
72
my $where;
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
73
my $update_param;
74
my $insert_param;
added EXPERIMENTAL replace()...
Yuki Kimoto authored on 2011-04-01
75
my $join;
removed register_format()
yuki-kimoto authored on 2010-05-26
76

            
77
# Prepare table
78
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
79
$dbi->execute($CREATE_TABLE->{0});
80
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
81
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
82

            
83
test 'DBIx::Custom::Result test';
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
84
$source = "select key1, key2 from table1";
85
$query = $dbi->create_query($source);
removed register_format()
yuki-kimoto authored on 2010-05-26
86
$result = $dbi->execute($query);
87

            
88
@rows = ();
89
while (my $row = $result->fetch) {
90
    push @rows, [@$row];
91
}
cleanup
Yuki Kimoto authored on 2011-01-23
92
is_deeply(\@rows, [[1, 2], [3, 4]], "fetch");
removed register_format()
yuki-kimoto authored on 2010-05-26
93

            
94
$result = $dbi->execute($query);
95
@rows = ();
96
while (my $row = $result->fetch_hash) {
97
    push @rows, {%$row};
98
}
cleanup
Yuki Kimoto authored on 2011-01-23
99
is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "fetch_hash");
removed register_format()
yuki-kimoto authored on 2010-05-26
100

            
101
$result = $dbi->execute($query);
102
$rows = $result->fetch_all;
cleanup
Yuki Kimoto authored on 2011-01-23
103
is_deeply($rows, [[1, 2], [3, 4]], "fetch_all");
removed register_format()
yuki-kimoto authored on 2010-05-26
104

            
105
$result = $dbi->execute($query);
removed reconnect method
yuki-kimoto authored on 2010-05-28
106
$rows = $result->fetch_hash_all;
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
107
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "all");
removed register_format()
yuki-kimoto authored on 2010-05-26
108

            
109
test 'Insert query return value';
110
$dbi->execute($DROP_TABLE->{0});
111
$dbi->execute($CREATE_TABLE->{0});
renamed update tag to update...
yuki-kimoto authored on 2010-08-09
112
$source = "insert into table1 {insert_param key1 key2}";
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
113
$query = $dbi->create_query($source);
removed register_format()
yuki-kimoto authored on 2010-05-26
114
$ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2});
cleanup
Yuki Kimoto authored on 2011-01-23
115
ok($ret_val);
removed register_format()
yuki-kimoto authored on 2010-05-26
116

            
117

            
118
test 'Direct query';
119
$dbi->execute($DROP_TABLE->{0});
120
$dbi->execute($CREATE_TABLE->{0});
add tests
yuki-kimoto authored on 2010-08-10
121
$insert_SOURCE = "insert into table1 {insert_param key1 key2}";
122
$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2});
123
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
124
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
125
is_deeply($rows, [{key1 => 1, key2 => 2}]);
removed register_format()
yuki-kimoto authored on 2010-05-26
126

            
127
test 'Filter basic';
128
$dbi->execute($DROP_TABLE->{0});
129
$dbi->execute($CREATE_TABLE->{0});
130
$dbi->register_filter(twice       => sub { $_[0] * 2}, 
131
                    three_times => sub { $_[0] * 3});
132

            
add tests
yuki-kimoto authored on 2010-08-10
133
$insert_SOURCE  = "insert into table1 {insert_param key1 key2};";
134
$insert_query = $dbi->create_query($insert_SOURCE);
removed register_format()
yuki-kimoto authored on 2010-05-26
135
$insert_query->filter({key1 => 'twice'});
136
$dbi->execute($insert_query, param => {key1 => 1, key2 => 2});
add tests
yuki-kimoto authored on 2010-08-10
137
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
138
$rows = $result->filter({key2 => 'three_times'})->all;
cleanup
Yuki Kimoto authored on 2011-01-23
139
is_deeply($rows, [{key1 => 2, key2 => 6}], "filter fetch_filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
140
$dbi->execute($DROP_TABLE->{0});
141

            
142
test 'Filter in';
143
$dbi->execute($CREATE_TABLE->{0});
add tests
yuki-kimoto authored on 2010-08-10
144
$insert_SOURCE  = "insert into table1 {insert_param key1 key2};";
145
$insert_query = $dbi->create_query($insert_SOURCE);
removed register_format()
yuki-kimoto authored on 2010-05-26
146
$dbi->execute($insert_query, param => {key1 => 2, key2 => 4});
add tests
yuki-kimoto authored on 2010-08-10
147
$select_SOURCE = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}";
148
$select_query = $dbi->create_query($select_SOURCE);
removed register_format()
yuki-kimoto authored on 2010-05-26
149
$select_query->filter({'table1.key1' => 'twice'});
150
$result = $dbi->execute($select_query, param => {'table1.key1' => [1,5], 'table1.key2' => [2,4]});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
151
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
152
is_deeply($rows, [{key1 => 2, key2 => 4}], "filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
153

            
154
test 'DBIx::Custom::SQLTemplate basic tag';
155
$dbi->execute($DROP_TABLE->{0});
156
$dbi->execute($CREATE_TABLE->{1});
157
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
158
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
159

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
160
$source = "select * from table1 where {= key1} and {<> key2} and {< key3} and {> key4} and {>= key5};";
161
$query = $dbi->create_query($source);
removed register_format()
yuki-kimoto authored on 2010-05-26
162
$result = $dbi->execute($query, param => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
163
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
164
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1");
removed register_format()
yuki-kimoto authored on 2010-05-26
165

            
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
166
$source = "select * from table1 where {= key1} and {<> key2} and {< key3} and {> key4} and {>= key5};";
167
$query = $dbi->create_query($source);
168
$result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
169
$rows = $result->all;
execute method can second ar...
Yuki Kimoto authored on 2011-06-09
170
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1");
171

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
172
$source = "select * from table1 where {<= key1} and {like key2};";
173
$query = $dbi->create_query($source);
removed register_format()
yuki-kimoto authored on 2010-05-26
174
$result = $dbi->execute($query, param => {key1 => 1, key2 => '%2%'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
175
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
176
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag2");
removed register_format()
yuki-kimoto authored on 2010-05-26
177

            
178
test 'DIB::Custom::SQLTemplate in tag';
179
$dbi->execute($DROP_TABLE->{0});
180
$dbi->execute($CREATE_TABLE->{1});
181
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
182
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
183

            
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
184
$source = "select * from table1 where {in key1 2};";
185
$query = $dbi->create_query($source);
removed register_format()
yuki-kimoto authored on 2010-05-26
186
$result = $dbi->execute($query, param => {key1 => [9, 1]});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
187
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
188
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
189

            
190
test 'DBIx::Custom::SQLTemplate insert tag';
191
$dbi->execute("delete from table1");
add tests
yuki-kimoto authored on 2010-08-10
192
$insert_SOURCE = 'insert into table1 {insert_param key1 key2 key3 key4 key5}';
193
$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
removed register_format()
yuki-kimoto authored on 2010-05-26
194

            
add tests
yuki-kimoto authored on 2010-08-10
195
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
196
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
197
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
198

            
199
test 'DBIx::Custom::SQLTemplate update tag';
200
$dbi->execute("delete from table1");
add tests
yuki-kimoto authored on 2010-08-10
201
$insert_SOURCE = "insert into table1 {insert_param key1 key2 key3 key4 key5}";
202
$dbi->execute($insert_SOURCE, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
203
$dbi->execute($insert_SOURCE, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
removed register_format()
yuki-kimoto authored on 2010-05-26
204

            
add tests
yuki-kimoto authored on 2010-08-10
205
$update_SOURCE = 'update table1 {update_param key1 key2 key3 key4} where {= key5}';
206
$dbi->execute($update_SOURCE, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5});
removed register_format()
yuki-kimoto authored on 2010-05-26
207

            
add tests
yuki-kimoto authored on 2010-08-10
208
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
209
$rows = $result->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
210
is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5},
cleanup
Yuki Kimoto authored on 2011-01-23
211
                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
212

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
213

            
214
test 'parameter';
215
$dbi->execute($DROP_TABLE->{0});
216
$dbi->execute($CREATE_TABLE->{1});
217
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
218
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
219

            
220
$source = "select * from table1 where key1 = :key1 and key2 = :key2";
221
$result = $dbi->execute($source, param => {key1 => 1, key2 => 2});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
222
$rows = $result->all;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
223
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
224

            
225
$source = "select * from table1 where key1 = \n:key1\n and key2 = :key2";
226
$result = $dbi->execute($source, param => {key1 => 1, key2 => 2});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
227
$rows = $result->all;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
228
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
229

            
230
$source = "select * from table1 where key1 = :key1 or key1 = :key1";
231
$result = $dbi->execute($source, param => {key1 => [1, 2]});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
232
$rows = $result->all;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
233
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
234

            
235
$source = "select * from table1 where key1 = :table1.key1 and key2 = :table1.key2";
236
$result = $dbi->execute(
237
    $source,
238
    param => {'table1.key1' => 1, 'table1.key2' => 1},
239
    filter => {'table1.key2' => sub { $_[0] * 2 }}
240
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
241
$rows = $result->all;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
242
is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
243

            
removed register_format()
yuki-kimoto authored on 2010-05-26
244
test 'Error case';
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
245
eval {DBIx::Custom->connect(dsn => 'dbi:SQLit')};
cleanup
Yuki Kimoto authored on 2011-01-23
246
ok($@, "connect error");
removed register_format()
yuki-kimoto authored on 2010-05-26
247

            
248
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
249
eval{$dbi->create_query("{p }")};
cleanup
Yuki Kimoto authored on 2011-01-23
250
ok($@, "create_query invalid SQL template");
removed register_format()
yuki-kimoto authored on 2010-05-26
251

            
252
test 'insert';
253
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
254
$dbi->execute($CREATE_TABLE->{0});
255
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
256
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
add tests
yuki-kimoto authored on 2010-08-10
257
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
258
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
259
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
260

            
261
$dbi->execute('delete from table1');
262
$dbi->register_filter(
263
    twice       => sub { $_[0] * 2 },
264
    three_times => sub { $_[0] * 3 }
265
);
renamed default_query_filter...
yuki-kimoto authored on 2010-08-03
266
$dbi->default_bind_filter('twice');
removed register_format()
yuki-kimoto authored on 2010-05-26
267
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'});
add tests
yuki-kimoto authored on 2010-08-10
268
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
269
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
270
is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
renamed default_query_filter...
yuki-kimoto authored on 2010-08-03
271
$dbi->default_bind_filter(undef);
removed register_format()
yuki-kimoto authored on 2010-05-26
272

            
273
$dbi->execute($DROP_TABLE->{0});
274
$dbi->execute($CREATE_TABLE->{0});
275
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
276
$rows = $dbi->select(table => 'table1')->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
277
is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
278

            
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
279
eval{$dbi->insert(table => 'table1', noexist => 1)};
cleanup
Yuki Kimoto authored on 2011-03-09
280
like($@, qr/noexist/, "invalid");
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
281

            
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
282
eval{$dbi->insert(table => 'table', param => {';' => 1})};
283
like($@, qr/safety/);
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
284

            
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
285
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
286
$dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
287
$dbi->execute('create table "table" ("select")');
288
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
289
$dbi->insert(table => 'table', param => {select => 1});
290
$result = $dbi->execute('select * from "table"');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
291
$rows   = $result->all;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
292
is_deeply($rows, [{select => 2}], "reserved word");
293

            
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
294
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
295
$dbi->execute($CREATE_TABLE->{0});
296
$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
297
$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
298
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
299
$rows   = $result->all;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
300
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
301

            
removed register_format()
yuki-kimoto authored on 2010-05-26
302
test 'update';
303
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
304
$dbi->execute($CREATE_TABLE->{1});
305
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
306
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
307
$dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1});
add tests
yuki-kimoto authored on 2010-08-10
308
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
309
$rows   = $result->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
310
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
311
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
cleanup
Yuki Kimoto authored on 2011-01-23
312
                  "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
313
                  
314
$dbi->execute("delete from table1");
315
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
316
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
317
$dbi->update(table => 'table1', param => {key2 => 12}, where => {key2 => 2, key3 => 3});
add tests
yuki-kimoto authored on 2010-08-10
318
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
319
$rows   = $result->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
320
is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
321
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
cleanup
Yuki Kimoto authored on 2011-01-23
322
                  "update key same as search key");
removed register_format()
yuki-kimoto authored on 2010-05-26
323

            
add tests
yuki-kimoto authored on 2010-08-10
324
$dbi->update(table => 'table1', param => {key2 => [12]}, where => {key2 => 2, key3 => 3});
325
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
326
$rows   = $result->all;
add tests
yuki-kimoto authored on 2010-08-10
327
is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
328
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
cleanup
Yuki Kimoto authored on 2011-01-23
329
                  "update key same as search key : param is array ref");
add tests
yuki-kimoto authored on 2010-08-10
330

            
removed register_format()
yuki-kimoto authored on 2010-05-26
331
$dbi->execute("delete from table1");
332
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
333
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
334
$dbi->register_filter(twice => sub { $_[0] * 2 });
335
$dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1},
many changed
Yuki Kimoto authored on 2011-01-23
336
              filter => {key2 => sub { $_[0] * 2 }});
add tests
yuki-kimoto authored on 2010-08-10
337
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
338
$rows   = $result->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
339
is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5},
340
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
cleanup
Yuki Kimoto authored on 2011-01-23
341
                  "filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
342

            
343
$result = $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, append => '   ');
344

            
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
345
eval{$dbi->update(table => 'table1', noexist => 1)};
cleanup
Yuki Kimoto authored on 2011-03-09
346
like($@, qr/noexist/, "invalid");
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
347

            
348
eval{$dbi->update(table => 'table1')};
cleanup
Yuki Kimoto authored on 2011-01-23
349
like($@, qr/where/, "not contain where");
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
350

            
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
351
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
352
$dbi->execute($CREATE_TABLE->{0});
353
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
354
$where = $dbi->where;
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
355
$where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
356
$where->param({key1 => 1, key2 => 2});
357
$dbi->update(table => 'table1', param => {key1 => 3}, where => $where);
358
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
359
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
360

            
361
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
362
$dbi->execute($CREATE_TABLE->{0});
363
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
364
$dbi->update(
365
    table => 'table1',
366
    param => {key1 => 3},
367
    where => [
368
        ['and', '{= key1}', '{= key2}'],
369
        {key1 => 1, key2 => 2}
370
    ]
371
);
372
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
373
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
374

            
375
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
376
$dbi->execute($CREATE_TABLE->{0});
377
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
378
$where = $dbi->where;
379
$where->clause(['and', '{= key2}']);
380
$where->param({key2 => 2});
381
$dbi->update(table => 'table1', param => {key1 => 3}, where => $where);
382
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
383
is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
384

            
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
385
eval{$dbi->update(table => 'table1', param => {';' => 1})};
386
like($@, qr/safety/);
387

            
388
eval{$dbi->update(table => 'table1', param => {'key1' => 1}, where => {';' => 1})};
389
like($@, qr/safety/);
390

            
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
391
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
392
$dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
393
$dbi->execute('create table "table" ("select", "update")');
394
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
395
$dbi->apply_filter('table', update => {out => sub { $_[0] * 3}});
396
$dbi->insert(table => 'table', param => {select => 1});
397
$dbi->update(table => 'table', where => {select => 1}, param => {update => 2});
398
$result = $dbi->execute('select * from "table"');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
399
$rows   = $result->all;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
400
is_deeply($rows, [{select => 2, update => 6}], "reserved word");
401

            
402
eval {$dbi->update_all(table => 'table', param => {';' => 2}) };
403
like($@, qr/safety/);
404

            
405
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
406
$dbi->reserved_word_quote('"');
407
$dbi->execute('create table "table" ("select", "update")');
408
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
409
$dbi->apply_filter('table', update => {out => sub { $_[0] * 3}});
410
$dbi->insert(table => 'table', param => {select => 1});
411
$dbi->update(table => 'table', where => {'table.select' => 1}, param => {update => 2});
412
$result = $dbi->execute('select * from "table"');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
413
$rows   = $result->all;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
414
is_deeply($rows, [{select => 2, update => 6}], "reserved word");
415

            
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
416
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
417
$dbi->execute($CREATE_TABLE->{1});
418
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
419
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
420
$dbi->update({key2 => 11}, table => 'table1', where => {key1 => 1});
421
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
422
$rows   = $result->all;
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
423
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
424
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
425
                  "basic");
426

            
removed register_format()
yuki-kimoto authored on 2010-05-26
427
test 'update_all';
428
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
429
$dbi->execute($CREATE_TABLE->{1});
430
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
431
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
432
$dbi->register_filter(twice => sub { $_[0] * 2 });
433
$dbi->update_all(table => 'table1', param => {key2 => 10}, filter => {key2 => 'twice'});
add tests
yuki-kimoto authored on 2010-08-10
434
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
435
$rows   = $result->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
436
is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
437
                  {key1 => 6, key2 => 20, key3 => 8, key4 => 9, key5 => 10}],
cleanup
Yuki Kimoto authored on 2011-01-23
438
                  "filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
439

            
440

            
441
test 'delete';
442
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
443
$dbi->execute($CREATE_TABLE->{0});
444
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
445
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
446
$dbi->delete(table => 'table1', where => {key1 => 1});
add tests
yuki-kimoto authored on 2010-08-10
447
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
448
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
449
is_deeply($rows, [{key1 => 3, key2 => 4}], "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
450

            
451
$dbi->execute("delete from table1;");
452
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
453
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
454
$dbi->register_filter(twice => sub { $_[0] * 2 });
455
$dbi->delete(table => 'table1', where => {key2 => 1}, filter => {key2 => 'twice'});
add tests
yuki-kimoto authored on 2010-08-10
456
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
457
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
458
is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
459

            
460
$dbi->delete(table => 'table1', where => {key1 => 1}, append => '   ');
461

            
462
$dbi->delete_all(table => 'table1');
463
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
464
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
465
$dbi->delete(table => 'table1', where => {key1 => 1, key2 => 2});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
466
$rows = $dbi->select(table => 'table1')->all;
cleanup
Yuki Kimoto authored on 2011-01-23
467
is_deeply($rows, [{key1 => 3, key2 => 4}], "delete multi key");
removed register_format()
yuki-kimoto authored on 2010-05-26
468

            
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
469
eval{$dbi->delete(table => 'table1', noexist => 1)};
cleanup
Yuki Kimoto authored on 2011-03-09
470
like($@, qr/noexist/, "invalid");
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
471

            
improved delete() and update...
Yuki Kimoto authored on 2011-01-26
472
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
473
$dbi->execute($CREATE_TABLE->{0});
474
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
475
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
476
$where = $dbi->where;
477
$where->clause(['and', '{= key1}', '{= key2}']);
478
$where->param({ke1 => 1, key2 => 2});
479
$dbi->delete(table => 'table1', where => $where);
480
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
481
is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
482

            
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
483
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
484
$dbi->execute($CREATE_TABLE->{0});
485
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
486
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
487
$dbi->delete(
488
    table => 'table1',
489
    where => [
490
        ['and', '{= key1}', '{= key2}'],
491
        {ke1 => 1, key2 => 2}
492
    ]
493
);
494
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
495
is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
496

            
removed register_format()
yuki-kimoto authored on 2010-05-26
497
test 'delete error';
498
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
499
$dbi->execute($CREATE_TABLE->{0});
500
eval{$dbi->delete(table => 'table1')};
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
501
like($@, qr/"where" must be specified/,
cleanup
Yuki Kimoto authored on 2011-01-23
502
         "where key-value pairs not specified");
removed register_format()
yuki-kimoto authored on 2010-05-26
503

            
select() where can't receive...
Yuki Kimoto authored on 2011-01-27
504
eval{$dbi->delete(table => 'table1', where => {';' => 1})};
505
like($@, qr/safety/);
506

            
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
507
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
508
$dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
509
$dbi->execute('create table "table" ("select", "update")');
510
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
511
$dbi->insert(table => 'table', param => {select => 1});
512
$dbi->delete(table => 'table', where => {select => 1});
513
$result = $dbi->execute('select * from "table"');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
514
$rows   = $result->all;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
515
is_deeply($rows, [], "reserved word");
516

            
removed register_format()
yuki-kimoto authored on 2010-05-26
517
test 'delete_all';
518
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
519
$dbi->execute($CREATE_TABLE->{0});
520
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
521
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
522
$dbi->delete_all(table => 'table1');
add tests
yuki-kimoto authored on 2010-08-10
523
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
524
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
525
is_deeply($rows, [], "basic");
removed register_format()
yuki-kimoto authored on 2010-05-26
526

            
527

            
528
test 'select';
529
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
530
$dbi->execute($CREATE_TABLE->{0});
531
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
532
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
533
$rows = $dbi->select(table => 'table1')->all;
removed register_format()
yuki-kimoto authored on 2010-05-26
534
is_deeply($rows, [{key1 => 1, key2 => 2},
cleanup
Yuki Kimoto authored on 2011-01-23
535
                  {key1 => 3, key2 => 4}], "table");
removed register_format()
yuki-kimoto authored on 2010-05-26
536

            
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
537
$rows = $dbi->select(table => 'table1', column => ['key1'])->all;
cleanup
Yuki Kimoto authored on 2011-01-23
538
is_deeply($rows, [{key1 => 1}, {key1 => 3}], "table and columns and where key");
removed register_format()
yuki-kimoto authored on 2010-05-26
539

            
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
540
$rows = $dbi->select(table => 'table1', where => {key1 => 1})->all;
cleanup
Yuki Kimoto authored on 2011-01-23
541
is_deeply($rows, [{key1 => 1, key2 => 2}], "table and columns and where key");
removed register_format()
yuki-kimoto authored on 2010-05-26
542

            
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
543
$rows = $dbi->select(table => 'table1', column => ['key1'], where => {key1 => 3})->all;
cleanup
Yuki Kimoto authored on 2011-01-23
544
is_deeply($rows, [{key1 => 3}], "table and columns and where key");
removed register_format()
yuki-kimoto authored on 2010-05-26
545

            
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
546
$rows = $dbi->select(table => 'table1', append => "order by key1 desc limit 1")->all;
cleanup
Yuki Kimoto authored on 2011-01-23
547
is_deeply($rows, [{key1 => 3, key2 => 4}], "append statement");
removed register_format()
yuki-kimoto authored on 2010-05-26
548

            
549
$dbi->register_filter(decrement => sub { $_[0] - 1 });
update document
yuki-kimoto authored on 2010-05-27
550
$rows = $dbi->select(table => 'table1', where => {key1 => 2}, filter => {key1 => 'decrement'})
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
551
            ->all;
cleanup
Yuki Kimoto authored on 2011-01-23
552
is_deeply($rows, [{key1 => 1, key2 => 2}], "filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
553

            
554
$dbi->execute($CREATE_TABLE->{2});
555
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
556
$rows = $dbi->select(
557
    table => [qw/table1 table2/],
select method column option ...
Yuki Kimoto authored on 2011-02-22
558
    column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3',
removed register_format()
yuki-kimoto authored on 2010-05-26
559
    where   => {'table1.key2' => 2},
added commit method
yuki-kimoto authored on 2010-05-27
560
    relation  => {'table1.key1' => 'table2.key1'}
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
561
)->all;
cleanup
Yuki Kimoto authored on 2011-01-23
562
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : exists where");
added commit method
yuki-kimoto authored on 2010-05-27
563

            
564
$rows = $dbi->select(
565
    table => [qw/table1 table2/],
566
    column => ['table1.key1 as table1_key1', 'table2.key1 as table2_key1', 'key2', 'key3'],
567
    relation  => {'table1.key1' => 'table2.key1'}
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
568
)->all;
cleanup
Yuki Kimoto authored on 2011-01-23
569
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : no exists where");
removed register_format()
yuki-kimoto authored on 2010-05-26
570

            
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
571
eval{$dbi->select(table => 'table1', noexist => 1)};
cleanup
Yuki Kimoto authored on 2011-03-09
572
like($@, qr/noexist/, "invalid");
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
573

            
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
574
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
575
$dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
576
$dbi->execute('create table "table" ("select", "update")');
577
$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
578
$dbi->insert(table => 'table', param => {select => 1, update => 2});
579
$result = $dbi->select(table => 'table', where => {select => 1});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
580
$rows   = $result->all;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
581
is_deeply($rows, [{select => 2, update => 2}], "reserved word");
changed argument of tag proc...
yuki-kimoto authored on 2010-08-03
582

            
removed register_format()
yuki-kimoto authored on 2010-05-26
583
test 'fetch filter';
584
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
585
$dbi->register_filter(
586
    twice       => sub { $_[0] * 2 },
587
    three_times => sub { $_[0] * 3 }
588
);
589
$dbi->default_fetch_filter('twice');
590
$dbi->execute($CREATE_TABLE->{0});
591
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
592
$result = $dbi->select(table => 'table1');
593
$result->filter({key1 => 'three_times'});
- added DBIx::Custom::Result...
Yuki Kimoto authored on 2011-06-07
594
$row = $result->one;
cleanup
Yuki Kimoto authored on 2011-01-23
595
is_deeply($row, {key1 => 3, key2 => 4}, "default_fetch_filter and filter");
removed register_format()
yuki-kimoto authored on 2010-05-26
596

            
597
test 'filters';
598
$dbi = DBIx::Custom->new;
599

            
update document
yuki-kimoto authored on 2010-05-27
600
is($dbi->filters->{decode_utf8}->(encode_utf8('あ')),
cleanup
Yuki Kimoto authored on 2011-01-23
601
   'あ', "decode_utf8");
removed register_format()
yuki-kimoto authored on 2010-05-26
602

            
603
is($dbi->filters->{encode_utf8}->('あ'),
cleanup
Yuki Kimoto authored on 2011-01-23
604
   encode_utf8('あ'), "encode_utf8");
removed register_format()
yuki-kimoto authored on 2010-05-26
605

            
added commit method
yuki-kimoto authored on 2010-05-27
606
test 'transaction';
607
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
608
$dbi->execute($CREATE_TABLE->{0});
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
609
$dbi->dbh->begin_work;
added commit method
yuki-kimoto authored on 2010-05-27
610
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
611
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
612
$dbi->dbh->commit;
added commit method
yuki-kimoto authored on 2010-05-27
613
$result = $dbi->select(table => 'table1');
- added DBIx::Custom::Result...
Yuki Kimoto authored on 2011-06-07
614
is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
cleanup
Yuki Kimoto authored on 2011-01-23
615
          "commit");
added commit method
yuki-kimoto authored on 2010-05-27
616

            
617
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
618
$dbi->execute($CREATE_TABLE->{0});
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
619
$dbi->dbh->begin_work(0);
added commit method
yuki-kimoto authored on 2010-05-27
620
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
removed DBIx::Custom commit ...
yuki-kimoto authored on 2010-07-14
621
$dbi->dbh->rollback;
added commit method
yuki-kimoto authored on 2010-05-27
622

            
623
$result = $dbi->select(table => 'table1');
cleanup
Yuki Kimoto authored on 2011-01-23
624
ok(! $result->fetch_first, "rollback");
add cache attribute
yuki-kimoto authored on 2010-06-14
625

            
626
test 'cache';
627
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
removed from cache() and cac...
Yuki Kimoto authored on 2011-03-29
628
$dbi->cache(1);
add cache attribute
yuki-kimoto authored on 2010-06-14
629
$dbi->execute($CREATE_TABLE->{0});
renamed build_query to creat...
yuki-kimoto authored on 2010-08-06
630
$source = 'select * from table1 where {= key1} and {= key2};';
631
$dbi->create_query($source);
632
is_deeply($dbi->{_cached}->{$source}, 
add table tag
Yuki Kimoto authored on 2011-02-09
633
          {sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2'], tables => []}, "cache");
add cache attribute
yuki-kimoto authored on 2010-06-14
634

            
635
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
636
$dbi->execute($CREATE_TABLE->{0});
637
$dbi->{_cached} = {};
638
$dbi->cache(0);
639
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
640
is(scalar keys %{$dbi->{_cached}}, 0, 'not cache');
641

            
add tests
yuki-kimoto authored on 2010-08-10
642
test 'execute';
643
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
644
$dbi->execute($CREATE_TABLE->{0});
removed experimental registe...
yuki-kimoto authored on 2010-08-24
645
{
646
    local $Carp::Verbose = 0;
647
    eval{$dbi->execute('select * frm table1')};
cleanup
Yuki Kimoto authored on 2011-01-23
648
    like($@, qr/\Qselect * frm table1;/, "fail prepare");
649
    like($@, qr/\.t /, "fail : not verbose");
removed experimental registe...
yuki-kimoto authored on 2010-08-24
650
}
651
{
652
    local $Carp::Verbose = 1;
653
    eval{$dbi->execute('select * frm table1')};
cleanup
Yuki Kimoto authored on 2011-01-23
654
    like($@, qr/Custom.*\.t /s, "fail : verbose");
removed experimental registe...
yuki-kimoto authored on 2010-08-24
655
}
add tests
yuki-kimoto authored on 2010-08-10
656

            
657
eval{$dbi->execute('select * from table1', no_exists => 1)};
improved error messages
Yuki Kimoto authored on 2011-04-18
658
like($@, qr/wrong/, "invald SQL");
add tests
yuki-kimoto authored on 2010-08-10
659

            
660
$query = $dbi->create_query('select * from table1 where {= key1}');
661
$dbi->dbh->disconnect;
662
eval{$dbi->execute($query, param => {key1 => {a => 1}})};
cleanup
Yuki Kimoto authored on 2011-01-23
663
ok($@, "execute fail");
add tests
yuki-kimoto authored on 2010-08-10
664

            
removed experimental registe...
yuki-kimoto authored on 2010-08-24
665
{
666
    local $Carp::Verbose = 0;
667
    eval{$dbi->create_query('select * from table1 where {0 key1}')};
cleanup
Yuki Kimoto authored on 2011-01-23
668
    like($@, qr/\Q.t /, "caller spec : not vebose");
removed experimental registe...
yuki-kimoto authored on 2010-08-24
669
}
670
{
671
    local $Carp::Verbose = 1;
672
    eval{$dbi->create_query('select * from table1 where {0 key1}')};
cleanup
Yuki Kimoto authored on 2011-01-23
673
    like($@, qr/QueryBuilder.*\.t /s, "caller spec : not vebose");
removed experimental registe...
yuki-kimoto authored on 2010-08-24
674
}
cleanup
yuki-kimoto authored on 2010-10-17
675

            
676

            
677
test 'transaction';
678
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
679
$dbi->execute($CREATE_TABLE->{0});
680

            
681
$dbi->begin_work;
682

            
683
eval {
684
    $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
685
    die "Error";
686
    $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
687
};
688

            
689
$dbi->rollback if $@;
690

            
691
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
692
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
693
is_deeply($rows, [], "rollback");
cleanup
yuki-kimoto authored on 2010-10-17
694

            
695
$dbi->begin_work;
696

            
697
eval {
698
    $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
699
    $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
700
};
701

            
702
$dbi->commit unless $@;
703

            
704
$result = $dbi->select(table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
705
$rows = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
706
is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "commit");
cleanup
yuki-kimoto authored on 2010-10-17
707

            
708
$dbi->dbh->{AutoCommit} = 0;
709
eval{ $dbi->begin_work };
cleanup
Yuki Kimoto authored on 2011-01-23
710
ok($@, "exception");
cleanup
yuki-kimoto authored on 2010-10-17
711
$dbi->dbh->{AutoCommit} = 1;
712

            
added helper method
yuki-kimoto authored on 2010-10-17
713

            
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
714
test 'method';
added helper method
yuki-kimoto authored on 2010-10-17
715
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
716
$dbi->method(
added helper method
yuki-kimoto authored on 2010-10-17
717
    one => sub { 1 }
718
);
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
719
$dbi->method(
added helper method
yuki-kimoto authored on 2010-10-17
720
    two => sub { 2 }
721
);
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
722
$dbi->method({
added helper method
yuki-kimoto authored on 2010-10-17
723
    twice => sub {
724
        my $self = shift;
725
        return $_[0] * 2;
726
    }
727
});
728

            
cleanup
Yuki Kimoto authored on 2011-01-23
729
is($dbi->one, 1, "first");
730
is($dbi->two, 2, "second");
731
is($dbi->twice(5), 10 , "second");
added helper method
yuki-kimoto authored on 2010-10-17
732

            
733
eval {$dbi->XXXXXX};
autoload DBI method
Yuki Kimoto authored on 2011-01-26
734
ok($@, "not exists");
added helper method
yuki-kimoto authored on 2010-10-17
735

            
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
736
test 'out filter';
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
737
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
738
$dbi->execute($CREATE_TABLE->{0});
739
$dbi->register_filter(twice => sub { $_[0] * 2 });
740
$dbi->register_filter(three_times => sub { $_[0] * 3});
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
741
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
742
    'table1', 'key1' => {out => 'twice', in => 'three_times'}, 
743
              'key2' => {out => 'three_times', in => 'twice'});
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
744
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
745
$result = $dbi->execute($SELECT_SOURCES->{0});
746
$row   = $result->fetch_hash_first;
cleanup
Yuki Kimoto authored on 2011-01-23
747
is_deeply($row, {key1 => 2, key2 => 6}, "insert");
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
748
$result = $dbi->select(table => 'table1');
added tests
Yuki Kimoto authored on 2011-06-08
749
$row   = $result->one;
cleanup
Yuki Kimoto authored on 2011-01-23
750
is_deeply($row, {key1 => 6, key2 => 12}, "insert");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
751

            
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
752
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
753
$dbi->execute($CREATE_TABLE->{0});
754
$dbi->register_filter(twice => sub { $_[0] * 2 });
755
$dbi->register_filter(three_times => sub { $_[0] * 3});
756
$dbi->apply_filter(
757
    'table1', 'key1' => {out => 'twice', in => 'three_times'}, 
758
              'key2' => {out => 'three_times', in => 'twice'});
759
$dbi->apply_filter(
760
    'table1', 'key1' => {out => undef}
761
); 
762
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
763
$result = $dbi->execute($SELECT_SOURCES->{0});
added tests
Yuki Kimoto authored on 2011-06-08
764
$row   = $result->one;
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
765
is_deeply($row, {key1 => 1, key2 => 6}, "insert");
766

            
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
767
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
768
$dbi->execute($CREATE_TABLE->{0});
769
$dbi->register_filter(twice => sub { $_[0] * 2 });
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
770
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
771
    'table1', 'key1' => {out => 'twice', in => 'twice'}
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
772
);
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
773
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => undef});
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
774
$dbi->update(table => 'table1', param => {key1 => 2}, where => {key2 => 2});
775
$result = $dbi->execute($SELECT_SOURCES->{0});
added tests
Yuki Kimoto authored on 2011-06-08
776
$row   = $result->one;
cleanup
Yuki Kimoto authored on 2011-01-23
777
is_deeply($row, {key1 => 4, key2 => 2}, "update");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
778

            
779
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
780
$dbi->execute($CREATE_TABLE->{0});
781
$dbi->register_filter(twice => sub { $_[0] * 2 });
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
782
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
783
    'table1', 'key1' => {out => 'twice', in => 'twice'}
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
784
);
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
785
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1=> undef});
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
786
$dbi->delete(table => 'table1', where => {key1 => 1});
787
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
788
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
789
is_deeply($rows, [], "delete");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
790

            
791
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
792
$dbi->execute($CREATE_TABLE->{0});
793
$dbi->register_filter(twice => sub { $_[0] * 2 });
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
794
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
795
    'table1', 'key1' => {out => 'twice', in => 'twice'}
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
796
);
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
797
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef});
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
798
$result = $dbi->select(table => 'table1', where => {key1 => 1});
799
$result->filter({'key2' => 'twice'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
800
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
801
is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
802

            
803
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
804
$dbi->execute($CREATE_TABLE->{0});
805
$dbi->register_filter(twice => sub { $_[0] * 2 });
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
806
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
807
    'table1', 'key1' => {out => 'twice', in => 'twice'}
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
808
);
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
809
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef});
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
810
$result = $dbi->execute("select * from table1 where {= key1} and {= key2};",
811
                        param => {key1 => 1, key2 => 2},
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
812
                        table => ['table1']);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
813
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
814
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
815

            
add table tag
Yuki Kimoto authored on 2011-02-09
816
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
817
$dbi->execute($CREATE_TABLE->{0});
818
$dbi->register_filter(twice => sub { $_[0] * 2 });
819
$dbi->apply_filter(
820
    'table1', 'key1' => {out => 'twice', in => 'twice'}
821
);
822
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef});
823
$result = $dbi->execute("select * from {table table1} where {= key1} and {= key2};",
824
                        param => {key1 => 1, key2 => 2});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
825
$rows   = $result->all;
add table tag
Yuki Kimoto authored on 2011-02-09
826
is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
827

            
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
828
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
829
$dbi->execute($CREATE_TABLE->{0});
830
$dbi->execute($CREATE_TABLE->{2});
831
$dbi->register_filter(twice => sub { $_[0] * 2 });
832
$dbi->register_filter(three_times => sub { $_[0] * 3 });
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
833
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
834
    'table1', 'key2' => {out => 'twice', in => 'twice'}
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
835
);
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
836
$dbi->apply_filter(
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
837
    'table2', 'key3' => {out => 'three_times', in => 'three_times'}
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
838
);
renamed auto_filter to apply...
Yuki Kimoto authored on 2011-01-12
839
$dbi->insert(table => 'table1', param => {key1 => 5, key2 => 2}, filter => {key2 => undef});
840
$dbi->insert(table => 'table2', param => {key1 => 5, key3 => 6}, filter => {key3 => undef});
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
841
$result = $dbi->select(
842
     table => ['table1', 'table2'],
843
     column => ['key2', 'key3'],
844
     where => {'table1.key2' => 1, 'table2.key3' => 2}, relation => {'table1.key1' => 'table2.key1'});
845

            
846
$result->filter({'key2' => 'twice'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
847
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
848
is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
849

            
850
$result = $dbi->select(
851
     table => ['table1', 'table2'],
852
     column => ['key2', 'key3'],
853
     where => {'key2' => 1, 'key3' => 2}, relation => {'table1.key1' => 'table2.key1'});
854

            
855
$result->filter({'key2' => 'twice'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
856
$rows   = $result->all;
cleanup
Yuki Kimoto authored on 2011-01-23
857
is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit");
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
858

            
pod fix
Yuki Kimoto authored on 2011-01-21
859
test 'each_column';
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
860
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
861
$dbi->execute($CREATE_TABLE->{2});
862
$dbi->execute($CREATE_TABLE->{3});
863

            
864
$infos = [];
pod fix
Yuki Kimoto authored on 2011-01-21
865
$dbi->each_column(sub {
removed experimental txn_sco...
Yuki Kimoto authored on 2011-01-24
866
    my ($self, $table, $column, $cinfo) = @_;
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
867
    
868
    if ($table =~ /^table/) {
869
         my $info = [$table, $column, $cinfo->{COLUMN_NAME}];
870
         push @$infos, $info;
871
    }
872
});
873
$infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos];
874
is_deeply($infos, 
875
    [
876
        ['table1', 'key1', 'key1'],
877
        ['table1', 'key2', 'key2'],
878
        ['table2', 'key1', 'key1'],
879
        ['table2', 'key3', 'key3']
880
    ]
cleanup
Yuki Kimoto authored on 2011-01-23
881
    
added experimental iterate_a...
Yuki Kimoto authored on 2010-12-22
882
);
added auto_filter method
kimoto.yuki@gmail.com authored on 2010-12-21
883

            
add examples
Yuki Kimoto authored on 2011-01-07
884
test 'limit';
885
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
886
$dbi->execute($CREATE_TABLE->{0});
887
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
888
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4});
889
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 6});
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
890
$dbi->register_tag(
add examples
Yuki Kimoto authored on 2011-01-07
891
    limit => sub {
892
        my ($count, $offset) = @_;
893
        
894
        my $s = '';
895
        $s .= "limit $count";
896
        $s .= " offset $offset" if defined $offset;
897
        
898
        return [$s, []];
899
    }
900
);
901
$rows = $dbi->select(
902
  table => 'table1',
903
  where => {key1 => 1},
904
  append => "order by key2 {limit 1 0}"
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
905
)->all;
cleanup
Yuki Kimoto authored on 2011-01-23
906
is_deeply($rows, [{key1 => 1, key2 => 2}]);
add examples
Yuki Kimoto authored on 2011-01-07
907
$rows = $dbi->select(
908
  table => 'table1',
909
  where => {key1 => 1},
910
  append => "order by key2 {limit 2 1}"
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
911
)->all;
cleanup
Yuki Kimoto authored on 2011-01-23
912
is_deeply($rows, [{key1 => 1, key2 => 4},{key1 => 1, key2 => 6}]);
add examples
Yuki Kimoto authored on 2011-01-07
913
$rows = $dbi->select(
914
  table => 'table1',
915
  where => {key1 => 1},
916
  append => "order by key2 {limit 1}"
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
917
)->all;
cleanup
Yuki Kimoto authored on 2011-01-23
918
is_deeply($rows, [{key1 => 1, key2 => 2}]);
added insert, update, update...
Yuki Kimoto authored on 2011-01-04
919

            
remove DBIx::Custom::Model
Yuki Kimoto authored on 2011-01-12
920
test 'connect super';
921
{
922
    package MyDBI;
923
    
924
    use base 'DBIx::Custom';
925
    sub connect {
926
        my $self = shift->SUPER::connect(@_);
927
        
928
        return $self;
929
    }
930
    
931
    sub new {
cleanup
Yuki Kimoto authored on 2011-01-25
932
        my $self = shift->SUPER::new(@_);
remove DBIx::Custom::Model
Yuki Kimoto authored on 2011-01-12
933
        
934
        return $self;
935
    }
936
}
937

            
938
$dbi = MyDBI->connect($NEW_ARGS->{0});
939
$dbi->execute($CREATE_TABLE->{0});
940
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
added tests
Yuki Kimoto authored on 2011-06-08
941
is($dbi->select(table => 'table1')->one->{key1}, 1);
remove DBIx::Custom::Model
Yuki Kimoto authored on 2011-01-12
942

            
943
$dbi = MyDBI->new($NEW_ARGS->{0});
cleanup
Yuki Kimoto authored on 2011-01-25
944
$dbi->connect;
remove DBIx::Custom::Model
Yuki Kimoto authored on 2011-01-12
945
$dbi->execute($CREATE_TABLE->{0});
946
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
added tests
Yuki Kimoto authored on 2011-06-08
947
is($dbi->select(table => 'table1')->one->{key1}, 1);
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
948

            
cleanup
Yuki Kimoto authored on 2011-01-25
949
{
950
    package MyDBI2;
951
    
952
    use base 'DBIx::Custom';
953
    sub connect {
954
        my $self = shift->SUPER::new(@_);
955
        $self->connect;
956
        
957
        return $self;
958
    }
959
}
960

            
961
$dbi = MyDBI->connect($NEW_ARGS->{0});
962
$dbi->execute($CREATE_TABLE->{0});
963
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
added tests
Yuki Kimoto authored on 2011-06-08
964
is($dbi->select(table => 'table1')->one->{key1}, 1);
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
965

            
966
test 'end_filter';
967
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
968
$dbi->execute($CREATE_TABLE->{0});
969
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
970
$result = $dbi->select(table => 'table1');
971
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
972
$result->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 });
973
$row = $result->fetch_first;
974
is_deeply($row, [6, 40]);
975

            
all filter can receive array...
Yuki Kimoto authored on 2011-02-25
976
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
977
$dbi->execute($CREATE_TABLE->{0});
978
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
979
$result = $dbi->select(table => 'table1');
980
$result->filter([qw/key1 key2/] => sub { $_[0] * 2 });
981
$result->end_filter([[qw/key1 key2/] => sub { $_[0] * 3 }]);
982
$row = $result->fetch_first;
983
is_deeply($row, [6, 12]);
984

            
985
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
986
$dbi->execute($CREATE_TABLE->{0});
987
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
988
$result = $dbi->select(table => 'table1');
989
$result->filter([[qw/key1 key2/] => sub { $_[0] * 2 }]);
990
$result->end_filter([qw/key1 key2/] => sub { $_[0] * 3 });
991
$row = $result->fetch_first;
992
is_deeply($row, [6, 12]);
993

            
many changed
Yuki Kimoto authored on 2011-01-23
994
$dbi->register_filter(five_times => sub { $_[0] * 5 });
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
995
$result = $dbi->select(table => 'table1');
996
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
many changed
Yuki Kimoto authored on 2011-01-23
997
$result->end_filter({key1 => sub { $_[0] * 3 }, key2 => 'five_times' });
added tests
Yuki Kimoto authored on 2011-06-08
998
$row = $result->one;
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-17
999
is_deeply($row, {key1 => 6, key2 => 40});
fix select method empty wher...
Yuki Kimoto authored on 2011-01-17
1000

            
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
1001
$dbi->register_filter(five_times => sub { $_[0] * 5 });
1002
$dbi->apply_filter('table1',
1003
    key1 => {end => sub { $_[0] * 3 } },
1004
    key2 => {end => 'five_times'}
1005
);
1006
$result = $dbi->select(table => 'table1');
1007
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
added tests
Yuki Kimoto authored on 2011-06-08
1008
$row = $result->one;
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
1009
is_deeply($row, {key1 => 6, key2 => 40}, 'apply_filter');
1010

            
1011
$dbi->register_filter(five_times => sub { $_[0] * 5 });
1012
$dbi->apply_filter('table1',
1013
    key1 => {end => sub { $_[0] * 3 } },
1014
    key2 => {end => 'five_times'}
1015
);
1016
$result = $dbi->select(table => 'table1');
1017
$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
1018
$result->filter(key1 => undef);
1019
$result->end_filter(key1 => undef);
added tests
Yuki Kimoto authored on 2011-06-08
1020
$row = $result->one;
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
1021
is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
fix select method empty wher...
Yuki Kimoto authored on 2011-01-17
1022

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
1023
test 'remove_end_filter and remove_filter';
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
1024
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1025
$dbi->execute($CREATE_TABLE->{0});
1026
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1027
$result = $dbi->select(table => 'table1');
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
1028
$row = $result
1029
       ->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 })
1030
       ->remove_filter
1031
       ->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 })
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
1032
       ->remove_end_filter
1033
       ->fetch_first;
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
1034
is_deeply($row, [1, 2]);
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-02-28
1035

            
fix select method empty wher...
Yuki Kimoto authored on 2011-01-17
1036
test 'empty where select';
1037
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1038
$dbi->execute($CREATE_TABLE->{0});
1039
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1040
$result = $dbi->select(table => 'table1', where => {});
added tests
Yuki Kimoto authored on 2011-06-08
1041
$row = $result->one;
fix select method empty wher...
Yuki Kimoto authored on 2011-01-17
1042
is_deeply($row, {key1 => 1, key2 => 2});
1043

            
added experimental sugar met...
Yuki Kimoto authored on 2011-01-17
1044
test 'select query option';
1045
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1046
$dbi->execute($CREATE_TABLE->{0});
1047
$query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
1048
is(ref $query, 'DBIx::Custom::Query');
1049
$query = $dbi->update(table => 'table1', where => {key1 => 1}, param => {key2 => 2}, query => 1);
1050
is(ref $query, 'DBIx::Custom::Query');
1051
$query = $dbi->delete(table => 'table1', where => {key1 => 1}, query => 1);
1052
is(ref $query, 'DBIx::Custom::Query');
1053
$query = $dbi->select(table => 'table1', where => {key1 => 1, key2 => 2}, query => 1);
1054
is(ref $query, 'DBIx::Custom::Query');
1055

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1056
test 'DBIx::Custom::Where';
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1057
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1058
$dbi->execute($CREATE_TABLE->{0});
1059
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1060
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1061
$where = $dbi->where->clause(['and', '{= key1}', '{= key2}']);
1062
is("$where", "where ( {= key1} and {= key2} )", 'no param');
1063

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1064
$where = $dbi->where
added test
Yuki Kimoto authored on 2011-01-19
1065
             ->clause(['and', '{= key1}', '{= key2}'])
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1066
             ->param({key1 => 1});
added test
Yuki Kimoto authored on 2011-01-19
1067

            
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1068
$result = $dbi->select(
1069
    table => 'table1',
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1070
    where => $where
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1071
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1072
$row = $result->all;
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1073
is_deeply($row, [{key1 => 1, key2 => 2}]);
1074

            
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1075
$result = $dbi->select(
1076
    table => 'table1',
1077
    where => [
1078
        ['and', '{= key1}', '{= key2}'],
1079
        {key1 => 1}
1080
    ]
1081
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1082
$row = $result->all;
where can recieve array refr...
Yuki Kimoto authored on 2011-03-24
1083
is_deeply($row, [{key1 => 1, key2 => 2}]);
1084

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1085
$where = $dbi->where
added test
Yuki Kimoto authored on 2011-01-19
1086
             ->clause(['and', '{= key1}', '{= key2}'])
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1087
             ->param({key1 => 1, key2 => 2});
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1088
$result = $dbi->select(
1089
    table => 'table1',
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1090
    where => $where
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1091
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1092
$row = $result->all;
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1093
is_deeply($row, [{key1 => 1, key2 => 2}]);
1094

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1095
$where = $dbi->where
added test
Yuki Kimoto authored on 2011-01-19
1096
             ->clause(['and', '{= key1}', '{= key2}'])
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1097
             ->param({});
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1098
$result = $dbi->select(
1099
    table => 'table1',
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1100
    where => $where,
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1101
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1102
$row = $result->all;
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1103
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1104

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1105
$where = $dbi->where
updated pod
Yuki Kimoto authored on 2011-06-07
1106
             ->clause(['and', ['or', 'key1 > :key1', 'key1 < :key1'], 'key2 = :key2'])
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1107
             ->param({key1 => [0, 3], key2 => 2});
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1108
$result = $dbi->select(
1109
    table => 'table1',
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1110
    where => $where,
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1111
); 
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1112
$row = $result->all;
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1113
is_deeply($row, [{key1 => 1, key2 => 2}]);
1114

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1115
$where = $dbi->where;
1116
$result = $dbi->select(
1117
    table => 'table1',
1118
    where => $where
1119
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1120
$row = $result->all;
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1121
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1122

            
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1123
eval {
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1124
$where = $dbi->where
added test
Yuki Kimoto authored on 2011-01-19
1125
             ->clause(['uuu']);
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1126
$result = $dbi->select(
1127
    table => 'table1',
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1128
    where => $where
experimental extended select...
Yuki Kimoto authored on 2011-01-17
1129
);
1130
};
1131
ok($@);
1132

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1133
$where = $dbi->where;
1134
is("$where", '');
1135

            
added test
Yuki Kimoto authored on 2011-01-19
1136
$where = $dbi->where
1137
             ->clause(['or', ('{= key1}') x 2])
1138
             ->param({key1 => [1, 3]});
1139
$result = $dbi->select(
1140
    table => 'table1',
1141
    where => $where,
1142
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1143
$row = $result->all;
added test
Yuki Kimoto authored on 2011-01-19
1144
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1145

            
1146
$where = $dbi->where
1147
             ->clause(['or', ('{= key1}') x 2])
1148
             ->param({key1 => [1]});
1149
$result = $dbi->select(
1150
    table => 'table1',
1151
    where => $where,
1152
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1153
$row = $result->all;
added test
Yuki Kimoto authored on 2011-01-19
1154
is_deeply($row, [{key1 => 1, key2 => 2}]);
1155

            
1156
$where = $dbi->where
1157
             ->clause(['or', ('{= key1}') x 2])
1158
             ->param({key1 => 1});
1159
$result = $dbi->select(
1160
    table => 'table1',
1161
    where => $where,
1162
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1163
$row = $result->all;
added test
Yuki Kimoto authored on 2011-01-19
1164
is_deeply($row, [{key1 => 1, key2 => 2}]);
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1165

            
many changed
Yuki Kimoto authored on 2011-01-23
1166
$where = $dbi->where
1167
             ->clause('{= key1}')
1168
             ->param({key1 => 1});
1169
$result = $dbi->select(
1170
    table => 'table1',
1171
    where => $where,
1172
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1173
$row = $result->all;
many changed
Yuki Kimoto authored on 2011-01-23
1174
is_deeply($row, [{key1 => 1, key2 => 2}]);
1175

            
1176
$where = $dbi->where
1177
             ->clause('{= key1} {= key2}')
1178
             ->param({key1 => 1});
1179
eval{$where->to_string};
1180
like($@, qr/one column/);
1181

            
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1182
$where = $dbi->where
1183
             ->clause('{= key1}')
1184
             ->param([]);
1185
eval{$where->to_string};
1186
like($@, qr/Parameter/);
1187

            
1188
$where = $dbi->where
1189
             ->clause(['or', ('{= key1}') x 3])
1190
             ->param({key1 => [$dbi->not_exists, 1, 3]});
1191
$result = $dbi->select(
1192
    table => 'table1',
1193
    where => $where,
1194
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1195
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1196
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1197

            
1198
$where = $dbi->where
1199
             ->clause(['or', ('{= key1}') x 3])
1200
             ->param({key1 => [1, $dbi->not_exists, 3]});
1201
$result = $dbi->select(
1202
    table => 'table1',
1203
    where => $where,
1204
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1205
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1206
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1207

            
1208
$where = $dbi->where
1209
             ->clause(['or', ('{= key1}') x 3])
1210
             ->param({key1 => [1, 3, $dbi->not_exists]});
1211
$result = $dbi->select(
1212
    table => 'table1',
1213
    where => $where,
1214
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1215
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1216
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1217

            
1218
$where = $dbi->where
1219
             ->clause(['or', ('{= key1}') x 3])
1220
             ->param({key1 => [1, $dbi->not_exists, $dbi->not_exists]});
1221
$result = $dbi->select(
1222
    table => 'table1',
1223
    where => $where,
1224
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1225
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1226
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1227

            
1228
$where = $dbi->where
1229
             ->clause(['or', ('{= key1}') x 3])
1230
             ->param({key1 => [$dbi->not_exists, 1, $dbi->not_exists]});
1231
$result = $dbi->select(
1232
    table => 'table1',
1233
    where => $where,
1234
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1235
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1236
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1237

            
1238
$where = $dbi->where
1239
             ->clause(['or', ('{= key1}') x 3])
1240
             ->param({key1 => [$dbi->not_exists, $dbi->not_exists, 1]});
1241
$result = $dbi->select(
1242
    table => 'table1',
1243
    where => $where,
1244
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1245
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1246
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1247

            
1248
$where = $dbi->where
1249
             ->clause(['or', ('{= key1}') x 3])
1250
             ->param({key1 => [$dbi->not_exists, $dbi->not_exists, $dbi->not_exists]});
1251
$result = $dbi->select(
1252
    table => 'table1',
1253
    where => $where,
1254
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1255
$row = $result->all;
added experimental not_exist...
Yuki Kimoto authored on 2011-01-26
1256
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1257

            
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
1258
$where = $dbi->where
1259
             ->clause(['or', ('{= key1}') x 3])
1260
             ->param({key1 => []});
1261
$result = $dbi->select(
1262
    table => 'table1',
1263
    where => $where,
1264
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1265
$row = $result->all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
1266
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1267

            
1268
$where = $dbi->where
1269
             ->clause(['and', '{> key1}', '{< key1}' ])
1270
             ->param({key1 => [2, $dbi->not_exists]});
1271
$result = $dbi->select(
1272
    table => 'table1',
1273
    where => $where,
1274
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1275
$row = $result->all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
1276
is_deeply($row, [{key1 => 3, key2 => 4}], 'not_exists');
1277

            
1278
$where = $dbi->where
1279
             ->clause(['and', '{> key1}', '{< key1}' ])
1280
             ->param({key1 => [$dbi->not_exists, 2]});
1281
$result = $dbi->select(
1282
    table => 'table1',
1283
    where => $where,
1284
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1285
$row = $result->all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
1286
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1287

            
1288
$where = $dbi->where
1289
             ->clause(['and', '{> key1}', '{< key1}' ])
1290
             ->param({key1 => [$dbi->not_exists, $dbi->not_exists]});
1291
$result = $dbi->select(
1292
    table => 'table1',
1293
    where => $where,
1294
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1295
$row = $result->all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
1296
is_deeply($row, [{key1 => 1, key2 => 2},{key1 => 3, key2 => 4}], 'not_exists');
1297

            
1298
$where = $dbi->where
1299
             ->clause(['and', '{> key1}', '{< key1}' ])
1300
             ->param({key1 => [0, 2]});
1301
$result = $dbi->select(
1302
    table => 'table1',
1303
    where => $where,
1304
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1305
$row = $result->all;
make delete() using where ob...
Yuki Kimoto authored on 2011-01-26
1306
is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1307

            
DBIx::Custom::Where clause a...
Yuki Kimoto authored on 2011-04-18
1308
$where = $dbi->where
1309
             ->clause(['and', 'key1 is not null', 'key2 is not null' ]);
1310
$result = $dbi->select(
1311
    table => 'table1',
1312
    where => $where,
1313
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1314
$row = $result->all;
DBIx::Custom::Where clause a...
Yuki Kimoto authored on 2011-04-18
1315
is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1316

            
improved error messages
Yuki Kimoto authored on 2011-04-18
1317
eval {$dbi->where(ppp => 1) };
1318
like($@, qr/invalid/);
1319

            
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1320
test 'dbi_option default';
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1321
$dbi = DBIx::Custom->new;
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1322
is_deeply($dbi->dbi_option, {});
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1323

            
added register_tag_processor
Yuki Kimoto authored on 2011-01-20
1324
test 'register_tag_processor';
1325
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1326
$dbi->register_tag_processor(
1327
    a => sub { 1 }
1328
);
1329
is($dbi->query_builder->tag_processors->{a}->(), 1);
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-18
1330

            
renamed DBIx::Custom::TagPro...
Yuki Kimoto authored on 2011-01-24
1331
test 'register_tag';
1332
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1333
$dbi->register_tag(
1334
    b => sub { 2 }
1335
);
1336
is($dbi->query_builder->tags->{b}->(), 2);
1337

            
added table not specified ex...
Yuki Kimoto authored on 2011-01-21
1338
test 'table not specify exception';
1339
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1340
eval {$dbi->insert};
1341
like($@, qr/table/);
1342
eval {$dbi->update};
1343
like($@, qr/table/);
1344
eval {$dbi->delete};
1345
like($@, qr/table/);
1346
eval {$dbi->select};
1347
like($@, qr/table/);
many changed
Yuki Kimoto authored on 2011-01-23
1348

            
1349

            
1350
test 'more tests';
1351
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1352
eval{$dbi->apply_filter('table', 'column', [])};
1353
like($@, qr/apply_filter/);
1354

            
1355
eval{$dbi->apply_filter('table', 'column', {outer => 2})};
1356
like($@, qr/apply_filter/);
1357

            
1358
$dbi->apply_filter(
1359

            
1360
);
1361
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1362
$dbi->execute($CREATE_TABLE->{0});
1363
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1364
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1365
$dbi->apply_filter('table1', 'key2', 
1366
                   {in => sub { $_[0] * 3 }, out => sub { $_[0] * 2 }});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1367
$rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
many changed
Yuki Kimoto authored on 2011-01-23
1368
is_deeply($rows, [{key1 => 1, key2 => 6}]);
1369

            
1370
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1371
$dbi->execute($CREATE_TABLE->{0});
1372
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1373
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1374
$dbi->apply_filter('table1', 'key2', {});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1375
$rows = $dbi->select(table => 'table1', where => {key2 => 2})->all;
many changed
Yuki Kimoto authored on 2011-01-23
1376
is_deeply($rows, [{key1 => 1, key2 => 2}]);
1377

            
1378
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1379
eval {$dbi->apply_filter('table1', 'key2', {out => 'no'})};
1380
like($@, qr/not registered/);
1381
eval {$dbi->apply_filter('table1', 'key2', {in => 'no'})};
1382
like($@, qr/not registered/);
renamed helper to method.
Yuki Kimoto authored on 2011-01-25
1383
$dbi->method({one => sub { 1 }});
many changed
Yuki Kimoto authored on 2011-01-23
1384
is($dbi->one, 1);
1385

            
1386
eval{DBIx::Custom->connect()};
cleanup
Yuki Kimoto authored on 2011-04-25
1387
like($@, qr/_connect/);
many changed
Yuki Kimoto authored on 2011-01-23
1388

            
1389
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1390
$dbi->execute($CREATE_TABLE->{0});
1391
$dbi->register_filter(twice => sub { $_[0] * 2 });
1392
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
1393
             filter => {key1 => 'twice'});
added tests
Yuki Kimoto authored on 2011-06-08
1394
$row = $dbi->select(table => 'table1')->one;
many changed
Yuki Kimoto authored on 2011-01-23
1395
is_deeply($row, {key1 => 2, key2 => 2});
1396
eval {$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
1397
             filter => {key1 => 'no'}) };
1398
like($@, qr//);
1399

            
1400
$dbi->register_filter(one => sub { });
1401
$dbi->default_fetch_filter('one');
1402
ok($dbi->default_fetch_filter);
1403
$dbi->default_bind_filter('one');
1404
ok($dbi->default_bind_filter);
1405
eval{$dbi->default_fetch_filter('no')};
1406
like($@, qr/not registered/);
1407
eval{$dbi->default_bind_filter('no')};
1408
like($@, qr/not registered/);
1409
$dbi->default_bind_filter(undef);
1410
ok(!defined $dbi->default_bind_filter);
1411
$dbi->default_fetch_filter(undef);
1412
ok(!defined $dbi->default_fetch_filter);
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1413
eval {$dbi->execute('select * from table1 {} {= author') };
many changed
Yuki Kimoto authored on 2011-01-23
1414
like($@, qr/Tag not finished/);
1415

            
1416
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1417
$dbi->execute($CREATE_TABLE->{0});
1418
$dbi->register_filter(one => sub { 1 });
1419
$result = $dbi->select(table => 'table1');
1420
eval {$result->filter(key1 => 'no')};
1421
like($@, qr/not registered/);
1422
eval {$result->end_filter(key1 => 'no')};
1423
like($@, qr/not registered/);
1424
$result->default_filter(undef);
1425
ok(!defined $result->default_filter);
1426
$result->default_filter('one');
1427
is($result->default_filter->(), 1);
1428

            
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1429
test 'dbi_option';
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1430
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:',
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1431
                             dbi_option => {PrintError => 1});
1432
ok($dbi->dbh->{PrintError});
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
1433
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:',
renamed dbi_options to dbi_o...
Yuki Kimoto authored on 2011-01-23
1434
                             dbi_options => {PrintError => 1});
1435
ok($dbi->dbh->{PrintError});
1436

            
added experimental DBIx::Cus...
Yuki Kimoto authored on 2011-01-25
1437
test 'DBIx::Custom::Result stash()';
1438
$result = DBIx::Custom::Result->new;
1439
is_deeply($result->stash, {}, 'default');
1440
$result->stash->{foo} = 1;
1441
is($result->stash->{foo}, 1, 'get and set');
table object call dbi object...
Yuki Kimoto authored on 2011-01-25
1442

            
fix bug : filter can't over...
Yuki Kimoto authored on 2011-02-09
1443
test 'filter __ expression';
1444
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1445
$dbi->execute('create table company (id, name, location_id)');
1446
$dbi->execute('create table location (id, name)');
1447
$dbi->apply_filter('location',
1448
  name => {in => sub { uc $_[0] } }
1449
);
1450

            
1451
$dbi->insert(table => 'company', param => {id => 1, name => 'a', location_id => 2});
1452
$dbi->insert(table => 'location', param => {id => 2, name => 'b'});
1453

            
1454
$result = $dbi->select(
1455
    table => ['company', 'location'], relation => {'company.location_id' => 'location.id'},
1456
    column => ['location.name as location__name']
1457
);
1458
is($result->fetch_first->[0], 'B');
1459

            
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1460
$result = $dbi->select(
1461
    table => 'company', relation => {'company.location_id' => 'location.id'},
1462
    column => ['location.name as location__name']
1463
);
1464
is($result->fetch_first->[0], 'B');
1465

            
added EXPERIMENTAL col metho...
Yuki Kimoto authored on 2011-06-08
1466
$result = $dbi->select(
1467
    table => 'company', relation => {'company.location_id' => 'location.id'},
1468
    column => ['location.name as "location.name"']
1469
);
1470
is($result->fetch_first->[0], 'B');
1471

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1472
test 'Model class';
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1473
use MyDBI1;
1474
$dbi = MyDBI1->connect($NEW_ARGS->{0});
1475
$dbi->execute("create table book (title, author)");
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1476
$model = $dbi->model('book');
1477
$model->insert({title => 'a', author => 'b'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1478
is_deeply($model->list->all, [{title => 'a', author => 'b'}], 'basic');
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1479
$dbi->execute("create table company (name)");
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1480
$model = $dbi->model('company');
1481
$model->insert({name => 'a'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1482
is_deeply($model->list->all, [{name => 'a'}], 'basic');
add models() attribute
Yuki Kimoto authored on 2011-02-21
1483
is($dbi->models->{'book'}, $dbi->model('book'));
1484
is($dbi->models->{'company'}, $dbi->model('company'));
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1485

            
1486
{
1487
    package MyDBI4;
1488

            
1489
    use strict;
1490
    use warnings;
1491

            
1492
    use base 'DBIx::Custom';
1493

            
1494
    sub connect {
1495
        my $self = shift->SUPER::connect(@_);
1496
        
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1497
        $self->include_model(
1498
            MyModel2 => [
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1499
                'book',
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-24
1500
                {class => 'Company', name => 'company'}
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1501
            ]
1502
        );
1503
    }
1504

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1505
    package MyModel2::Base1;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1506

            
1507
    use strict;
1508
    use warnings;
1509

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1510
    use base 'DBIx::Custom::Model';
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1511

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1512
    package MyModel2::book;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1513

            
1514
    use strict;
1515
    use warnings;
1516

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1517
    use base 'MyModel2::Base1';
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1518

            
1519
    sub insert {
1520
        my ($self, $param) = @_;
1521
        
1522
        return $self->SUPER::insert(param => $param);
1523
    }
1524

            
1525
    sub list { shift->select; }
1526

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1527
    package MyModel2::Company;
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1528

            
1529
    use strict;
1530
    use warnings;
1531

            
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1532
    use base 'MyModel2::Base1';
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1533

            
1534
    sub insert {
1535
        my ($self, $param) = @_;
1536
        
1537
        return $self->SUPER::insert(param => $param);
1538
    }
1539

            
1540
    sub list { shift->select; }
1541
}
1542
$dbi = MyDBI4->connect($NEW_ARGS->{0});
1543
$dbi->execute("create table book (title, author)");
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1544
$model = $dbi->model('book');
1545
$model->insert({title => 'a', author => 'b'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1546
is_deeply($model->list->all, [{title => 'a', author => 'b'}], 'basic');
removed experimental base_ta...
Yuki Kimoto authored on 2011-02-15
1547
$dbi->execute("create table company (name)");
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1548
$model = $dbi->model('company');
1549
$model->insert({name => 'a'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1550
is_deeply($model->list->all, [{name => 'a'}], 'basic');
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1551

            
1552
{
1553
     package MyDBI5;
1554

            
1555
    use strict;
1556
    use warnings;
1557

            
1558
    use base 'DBIx::Custom';
1559

            
1560
    sub connect {
1561
        my $self = shift->SUPER::connect(@_);
1562
        
1563
        $self->include_model('MyModel4');
1564
    }
1565
}
1566
$dbi = MyDBI5->connect($NEW_ARGS->{0});
1567
$dbi->execute("create table company (name)");
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1568
$dbi->execute("create table table1 (key1)");
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1569
$model = $dbi->model('company');
1570
$model->insert({name => 'a'});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1571
is_deeply($model->list->all, [{name => 'a'}], 'include all model');
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1572
$dbi->insert(table => 'table1', param => {key1 => 1});
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1573
$model = $dbi->model('book');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1574
is_deeply($model->list->all, [{key1 => 1}], 'include all model');
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1575

            
add DBIx::Custom::Model fore...
Yuki Kimoto authored on 2011-02-21
1576
test 'primary_key';
1577
use MyDBI1;
1578
$dbi = MyDBI1->connect($NEW_ARGS->{0});
1579
$model = $dbi->model('book');
1580
$model->primary_key(['id', 'number']);
1581
is_deeply($model->primary_key, ['id', 'number']);
1582

            
add DBIx::Custom::Model colu...
Yuki Kimoto authored on 2011-02-21
1583
test 'columns';
1584
use MyDBI1;
1585
$dbi = MyDBI1->connect($NEW_ARGS->{0});
1586
$model = $dbi->model('book');
1587
$model->columns(['id', 'number']);
1588
is_deeply($model->columns, ['id', 'number']);
add feture. all model class ...
Yuki Kimoto authored on 2011-02-18
1589

            
add experimental setup_model...
Yuki Kimoto authored on 2011-02-21
1590
test 'setup_model';
1591
use MyDBI1;
1592
$dbi = MyDBI1->connect($NEW_ARGS->{0});
1593
$dbi->execute('create table book (id)');
1594
$dbi->execute('create table company (id, name);');
1595
$dbi->execute('create table test (id, name, primary key (id, name));');
1596
$dbi->setup_model;
1597
is_deeply($dbi->model('book')->columns, ['id']);
1598
is_deeply($dbi->model('company')->columns, ['id', 'name']);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1599

            
1600
test 'delete_at';
1601
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1602
$dbi->execute($CREATE_TABLE->{1});
1603
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1604
$dbi->delete_at(
1605
    table => 'table1',
1606
    primary_key => ['key1', 'key2'],
1607
    where => [1, 2],
1608
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1609
is_deeply($dbi->select(table => 'table1')->all, []);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1610

            
1611
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1612
$dbi->delete_at(
1613
    table => 'table1',
1614
    primary_key => 'key1',
1615
    where => 1,
1616
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1617
is_deeply($dbi->select(table => 'table1')->all, []);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1618

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1619
test 'insert_at';
1620
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1621
$dbi->execute($CREATE_TABLE->{1});
1622
$dbi->insert_at(
1623
    primary_key => ['key1', 'key2'], 
1624
    table => 'table1',
1625
    where => [1, 2],
1626
    param => {key3 => 3}
1627
);
added tests
Yuki Kimoto authored on 2011-06-08
1628
is($dbi->select(table => 'table1')->one->{key1}, 1);
1629
is($dbi->select(table => 'table1')->one->{key2}, 2);
1630
is($dbi->select(table => 'table1')->one->{key3}, 3);
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1631

            
1632
$dbi->delete_all(table => 'table1');
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1633
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1634
$dbi->insert_at(
1635
    primary_key => 'key1', 
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1636
    table => 'table1',
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1637
    where => 1,
1638
    param => {key2 => 2, key3 => 3}
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1639
);
1640

            
added tests
Yuki Kimoto authored on 2011-06-08
1641
is($dbi->select(table => 'table1')->one->{key1}, 1);
1642
is($dbi->select(table => 'table1')->one->{key2}, 2);
1643
is($dbi->select(table => 'table1')->one->{key3}, 3);
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1644

            
1645
eval {
1646
    $dbi->insert_at(
1647
        table => 'table1',
1648
        primary_key => ['key1', 'key2'],
1649
        where => {},
1650
        param => {key1 => 1, key2 => 2, key3 => 3},
1651
    );
1652
};
1653
like($@, qr/must be/);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1654

            
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1655
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1656
$dbi->execute($CREATE_TABLE->{1});
1657
$dbi->insert_at(
1658
    {key3 => 3},
1659
    primary_key => ['key1', 'key2'], 
1660
    table => 'table1',
1661
    where => [1, 2],
1662
);
added tests
Yuki Kimoto authored on 2011-06-08
1663
is($dbi->select(table => 'table1')->one->{key1}, 1);
1664
is($dbi->select(table => 'table1')->one->{key2}, 2);
1665
is($dbi->select(table => 'table1')->one->{key3}, 3);
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1666

            
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1667
test 'update_at';
1668
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1669
$dbi->execute($CREATE_TABLE->{1});
1670
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1671
$dbi->update_at(
1672
    table => 'table1',
1673
    primary_key => ['key1', 'key2'],
1674
    where => [1, 2],
1675
    param => {key3 => 4}
1676
);
added tests
Yuki Kimoto authored on 2011-06-08
1677
is($dbi->select(table => 'table1')->one->{key1}, 1);
1678
is($dbi->select(table => 'table1')->one->{key2}, 2);
1679
is($dbi->select(table => 'table1')->one->{key3}, 4);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1680

            
1681
$dbi->delete_all(table => 'table1');
1682
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1683
$dbi->update_at(
1684
    table => 'table1',
1685
    primary_key => 'key1',
1686
    where => 1,
1687
    param => {key3 => 4}
1688
);
added tests
Yuki Kimoto authored on 2011-06-08
1689
is($dbi->select(table => 'table1')->one->{key1}, 1);
1690
is($dbi->select(table => 'table1')->one->{key2}, 2);
1691
is($dbi->select(table => 'table1')->one->{key3}, 4);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1692

            
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1693
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1694
$dbi->execute($CREATE_TABLE->{1});
1695
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1696
$dbi->update_at(
1697
    {key3 => 4},
1698
    table => 'table1',
1699
    primary_key => ['key1', 'key2'],
1700
    where => [1, 2]
1701
);
added tests
Yuki Kimoto authored on 2011-06-08
1702
is($dbi->select(table => 'table1')->one->{key1}, 1);
1703
is($dbi->select(table => 'table1')->one->{key2}, 2);
1704
is($dbi->select(table => 'table1')->one->{key3}, 4);
- insert, insert_at, update,...
Yuki Kimoto authored on 2011-06-08
1705

            
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1706
test 'select_at';
1707
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1708
$dbi->execute($CREATE_TABLE->{1});
1709
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1710
$result = $dbi->select_at(
1711
    table => 'table1',
1712
    primary_key => ['key1', 'key2'],
1713
    where => [1, 2]
1714
);
added tests
Yuki Kimoto authored on 2011-06-08
1715
$row = $result->one;
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1716
is($row->{key1}, 1);
1717
is($row->{key2}, 2);
1718
is($row->{key3}, 3);
1719

            
1720
$dbi->delete_all(table => 'table1');
1721
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1722
$result = $dbi->select_at(
1723
    table => 'table1',
1724
    primary_key => 'key1',
1725
    where => 1,
1726
);
added tests
Yuki Kimoto authored on 2011-06-08
1727
$row = $result->one;
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1728
is($row->{key1}, 1);
1729
is($row->{key2}, 2);
1730
is($row->{key3}, 3);
1731

            
1732
$dbi->delete_all(table => 'table1');
1733
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1734
$result = $dbi->select_at(
1735
    table => 'table1',
1736
    primary_key => ['key1', 'key2'],
cleanup
Yuki Kimoto authored on 2011-03-21
1737
    where => [1, 2]
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1738
);
added tests
Yuki Kimoto authored on 2011-06-08
1739
$row = $result->one;
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1740
is($row->{key1}, 1);
1741
is($row->{key2}, 2);
1742
is($row->{key3}, 3);
1743

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1744
eval {
1745
    $result = $dbi->select_at(
1746
        table => 'table1',
1747
        primary_key => ['key1', 'key2'],
1748
        where => {},
1749
    );
1750
};
1751
like($@, qr/must be/);
1752

            
improved error messages
Yuki Kimoto authored on 2011-04-18
1753
eval {
1754
    $result = $dbi->select_at(
1755
        table => 'table1',
1756
        primary_key => ['key1', 'key2'],
1757
        where => [1],
1758
    );
1759
};
1760
like($@, qr/same/);
1761

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1762
eval {
1763
    $result = $dbi->update_at(
1764
        table => 'table1',
1765
        primary_key => ['key1', 'key2'],
1766
        where => {},
1767
        param => {key1 => 1, key2 => 2},
1768
    );
1769
};
1770
like($@, qr/must be/);
1771

            
1772
eval {
1773
    $result = $dbi->delete_at(
1774
        table => 'table1',
1775
        primary_key => ['key1', 'key2'],
1776
        where => {},
1777
    );
1778
};
1779
like($@, qr/must be/);
add experimental update_at()...
Yuki Kimoto authored on 2011-02-21
1780

            
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1781
test 'columns';
1782
use MyDBI1;
1783
$dbi = MyDBI1->connect($NEW_ARGS->{0});
1784
$model = $dbi->model('book');
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1785

            
1786

            
1787
test 'model delete_at';
1788
{
1789
    package MyDBI6;
1790
    
1791
    use base 'DBIx::Custom';
1792
    
1793
    sub connect {
1794
        my $self = shift->SUPER::connect(@_);
1795
        
1796
        $self->include_model('MyModel5');
1797
        
1798
        return $self;
1799
    }
1800
}
1801
$dbi = MyDBI6->connect($NEW_ARGS->{0});
1802
$dbi->execute($CREATE_TABLE->{1});
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1803
$dbi->execute("create table table2 (key1, key2, key3)");
1804
$dbi->execute("create table table3 (key1, key2, key3)");
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1805
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1806
$dbi->model('table1')->delete_at(where => [1, 2]);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1807
is_deeply($dbi->select(table => 'table1')->all, []);
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1808
$dbi->insert(table => 'table2', param => {key1 => 1, key2 => 2, key3 => 3});
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-24
1809
$dbi->model('table1_1')->delete_at(where => [1, 2]);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1810
is_deeply($dbi->select(table => 'table1')->all, []);
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
1811
$dbi->insert(table => 'table3', param => {key1 => 1, key2 => 2, key3 => 3});
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-24
1812
$dbi->model('table1_3')->delete_at(where => [1, 2]);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1813
is_deeply($dbi->select(table => 'table1')->all, []);
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1814

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1815
test 'model insert_at';
1816
$dbi = MyDBI6->connect($NEW_ARGS->{0});
1817
$dbi->execute($CREATE_TABLE->{1});
1818
$dbi->model('table1')->insert_at(
1819
    where => [1, 2],
1820
    param => {key3 => 3}
1821
);
1822
$result = $dbi->model('table1')->select;
added tests
Yuki Kimoto authored on 2011-06-08
1823
$row = $result->one;
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1824
is($row->{key1}, 1);
1825
is($row->{key2}, 2);
1826
is($row->{key3}, 3);
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1827

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1828
test 'model update_at';
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1829
$dbi = MyDBI6->connect($NEW_ARGS->{0});
1830
$dbi->execute($CREATE_TABLE->{1});
1831
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1832
$dbi->model('table1')->update_at(
1833
    where => [1, 2],
1834
    param => {key3 => 4}
1835
);
1836
$result = $dbi->model('table1')->select;
added tests
Yuki Kimoto authored on 2011-06-08
1837
$row = $result->one;
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1838
is($row->{key1}, 1);
1839
is($row->{key2}, 2);
1840
is($row->{key3}, 4);
1841

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-02-28
1842
test 'model select_at';
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1843
$dbi = MyDBI6->connect($NEW_ARGS->{0});
1844
$dbi->execute($CREATE_TABLE->{1});
1845
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
1846
$result = $dbi->model('table1')->select_at(where => [1, 2]);
added tests
Yuki Kimoto authored on 2011-06-08
1847
$row = $result->one;
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-21
1848
is($row->{key1}, 1);
1849
is($row->{key2}, 2);
1850
is($row->{key3}, 3);
DBIx::Custom::Model select()...
Yuki Kimoto authored on 2011-02-22
1851

            
1852

            
cleanup
Yuki Kimoto authored on 2011-03-21
1853
test 'mycolumn and column';
DBIx::Custom::Model select()...
Yuki Kimoto authored on 2011-02-22
1854
{
1855
    package MyDBI7;
1856
    
1857
    use base 'DBIx::Custom';
1858
    
1859
    sub connect {
1860
        my $self = shift->SUPER::connect(@_);
1861
        
1862
        $self->include_model('MyModel6');
1863
        
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
1864
        
DBIx::Custom::Model select()...
Yuki Kimoto authored on 2011-02-22
1865
        return $self;
1866
    }
1867
}
1868
$dbi = MyDBI7->connect($NEW_ARGS->{0});
1869
$dbi->execute($CREATE_TABLE->{0});
1870
$dbi->execute($CREATE_TABLE->{2});
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
1871
$dbi->separator('__');
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
1872
$dbi->setup_model;
1873
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1874
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
1875
$model = $dbi->model('table1');
cleanup
Yuki Kimoto authored on 2011-03-21
1876
$result = $model->select(
1877
    column => [$model->mycolumn, $model->column('table2')],
1878
    where => {'table1.key1' => 1}
1879
);
added tests
Yuki Kimoto authored on 2011-06-08
1880
is_deeply($result->one,
cleanup
Yuki Kimoto authored on 2011-03-21
1881
          {key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3});
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
1882

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1883
test 'update_param';
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1884
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1885
$dbi->execute($CREATE_TABLE->{1});
1886
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1887
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1888

            
1889
$param = {key2 => 11};
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1890
$update_param = $dbi->update_param($param);
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1891
$sql = <<"EOS";
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1892
update table1 $update_param
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1893
where key1 = 1
1894
EOS
1895
$dbi->execute($sql, param => $param);
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1896
$result = $dbi->execute($SELECT_SOURCES->{0}, table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1897
$rows   = $result->all;
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1898
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
1899
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
1900
                  "basic");
1901

            
1902

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1903
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1904
$dbi->execute($CREATE_TABLE->{1});
1905
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1906
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1907

            
1908
$param = {key2 => 11, key3 => 33};
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1909
$update_param = $dbi->update_param($param);
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1910
$sql = <<"EOS";
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1911
update table1 $update_param
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1912
where key1 = 1
1913
EOS
1914
$dbi->execute($sql, param => $param);
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1915
$result = $dbi->execute($SELECT_SOURCES->{0}, table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1916
$rows   = $result->all;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1917
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
1918
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
1919
                  "basic");
1920

            
1921
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1922
$dbi->execute($CREATE_TABLE->{1});
1923
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1924
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1925

            
1926
$param = {key2 => 11, key3 => 33};
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1927
$update_param = $dbi->update_param($param, {no_set => 1});
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1928
$sql = <<"EOS";
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1929
update table1 set $update_param
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1930
where key1 = 1
1931
EOS
1932
$dbi->execute($sql, param => $param);
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1933
$result = $dbi->execute($SELECT_SOURCES->{0}, table => 'table1');
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1934
$rows   = $result->all;
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1935
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
1936
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
1937
                  "update param no_set");
1938

            
1939
            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1940
eval { $dbi->update_param({";" => 1}) };
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1941
like($@, qr/not safety/);
1942

            
1943

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1944
test 'update_param';
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1945
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1946
$dbi->execute($CREATE_TABLE->{1});
1947
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1948
$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1949

            
1950
$param = {key2 => 11};
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1951
$update_param = $dbi->assign_param($param);
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1952
$sql = <<"EOS";
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1953
update table1 set $update_param
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1954
where key1 = 1
1955
EOS
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1956
$dbi->execute($sql, param => $param, table => 'table1');
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1957
$result = $dbi->execute($SELECT_SOURCES->{0});
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
1958
$rows   = $result->all;
added EXPERIMENTAL assign_ta...
Yuki Kimoto authored on 2011-04-26
1959
is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
1960
                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
1961
                  "basic");
1962

            
1963

            
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1964
test 'insert_param';
1965
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1966
$dbi->execute($CREATE_TABLE->{1});
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1967
$param = {key1 => 1, key2 => 2};
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1968
$insert_param = $dbi->insert_param($param);
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1969
$sql = <<"EOS";
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1970
insert into table1 $insert_param
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1971
EOS
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1972
$dbi->execute($sql, param => $param, table => 'table1');
added tests
Yuki Kimoto authored on 2011-06-08
1973
is($dbi->select(table => 'table1')->one->{key1}, 1);
1974
is($dbi->select(table => 'table1')->one->{key2}, 2);
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1975

            
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1976
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
1977
$dbi->quote('"');
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1978
$dbi->execute($CREATE_TABLE->{1});
1979
$param = {key1 => 1, key2 => 2};
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1980
$insert_param = $dbi->insert_param($param);
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1981
$sql = <<"EOS";
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1982
insert into table1 $insert_param
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
1983
EOS
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1984
$dbi->execute($sql, param => $param, table => 'table1');
added tests
Yuki Kimoto authored on 2011-06-08
1985
is($dbi->select(table => 'table1')->one->{key1}, 1);
1986
is($dbi->select(table => 'table1')->one->{key2}, 2);
add experimental DBIx::Custo...
Yuki Kimoto authored on 2011-02-22
1987

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
1988
eval { $dbi->insert_param({";" => 1}) };
added experimental update_pa...
Yuki Kimoto authored on 2011-03-08
1989
like($@, qr/not safety/);
cleanup
Yuki Kimoto authored on 2011-03-08
1990

            
1991

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
1992
test 'join';
cleanup
Yuki Kimoto authored on 2011-03-08
1993
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
1994
$dbi->execute($CREATE_TABLE->{0});
1995
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1996
$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1997
$dbi->execute($CREATE_TABLE->{2});
1998
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
1999
$dbi->execute($CREATE_TABLE->{4});
2000
$dbi->insert(table => 'table3', param => {key3 => 5, key4 => 4});
cleanup
Yuki Kimoto authored on 2011-03-08
2001
$rows = $dbi->select(
2002
    table => 'table1',
2003
    column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3',
2004
    where   => {'table1.key2' => 2},
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2005
    join  => ['left outer join table2 on table1.key1 = table2.key1']
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2006
)->all;
cleanup
Yuki Kimoto authored on 2011-03-08
2007
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}]);
2008

            
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2009
$rows = $dbi->select(
2010
    table => 'table1',
2011
    where   => {'key1' => 1},
2012
    join  => ['left outer join table2 on table1.key1 = table2.key1']
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2013
)->all;
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2014
is_deeply($rows, [{key1 => 1, key2 => 2}]);
2015

            
cleanup
Yuki Kimoto authored on 2011-03-08
2016
eval {
2017
    $rows = $dbi->select(
2018
        table => 'table1',
2019
        column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3',
2020
        where   => {'table1.key2' => 2},
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2021
        join  => {'table1.key1' => 'table2.key1'}
cleanup
Yuki Kimoto authored on 2011-03-08
2022
    );
2023
};
2024
like ($@, qr/array/);
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2025

            
2026
$rows = $dbi->select(
2027
    table => 'table1',
2028
    where   => {'key1' => 1},
2029
    join  => ['left outer join table2 on table1.key1 = table2.key1',
2030
              'left outer join table3 on table2.key3 = table3.key3']
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2031
)->all;
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2032
is_deeply($rows, [{key1 => 1, key2 => 2}]);
2033

            
2034
$rows = $dbi->select(
2035
    column => 'table3.key4 as table3__key4',
2036
    table => 'table1',
2037
    where   => {'table1.key1' => 1},
2038
    join  => ['left outer join table2 on table1.key1 = table2.key1',
2039
              'left outer join table3 on table2.key3 = table3.key3']
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2040
)->all;
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2041
is_deeply($rows, [{table3__key4 => 4}]);
2042

            
2043
$rows = $dbi->select(
2044
    column => 'table1.key1 as table1__key1',
2045
    table => 'table1',
2046
    where   => {'table3.key4' => 4},
2047
    join  => ['left outer join table2 on table1.key1 = table2.key1',
2048
              'left outer join table3 on table2.key3 = table3.key3']
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2049
)->all;
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-08
2050
is_deeply($rows, [{table1__key1 => 1}]);
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-11
2051

            
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2052
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2053
$dbi->quote('"');
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2054
$dbi->execute($CREATE_TABLE->{0});
2055
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2056
$dbi->execute($CREATE_TABLE->{2});
2057
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
2058
$rows = $dbi->select(
2059
    table => 'table1',
2060
    column => '"table1"."key1" as "table1_key1", "table2"."key1" as "table2_key1", "key2", "key3"',
2061
    where   => {'table1.key2' => 2},
2062
    join  => ['left outer join "table2" on "table1"."key1" = "table2"."key1"'],
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2063
)->all;
added EXPERIMENTAL reserved_...
Yuki Kimoto authored on 2011-03-30
2064
is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
reserved_word_quote is DEPRE...
Yuki Kimoto authored on 2011-06-17
2065
          'quote');
- added experimental DBIx::C...
Yuki Kimoto authored on 2011-03-11
2066

            
2067
{
2068
    package MyDBI8;
2069
    
2070
    use base 'DBIx::Custom';
2071
    
2072
    sub connect {
2073
        my $self = shift->SUPER::connect(@_);
2074
        
2075
        $self->include_model('MyModel7');
2076
        
2077
        return $self;
2078
    }
2079
}
added select() all_column op...
Yuki Kimoto authored on 2011-03-12
2080

            
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2081
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2082
$dbi->execute($CREATE_TABLE->{0});
2083
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2084
$sql = <<"EOS";
2085
left outer join (
2086
  select * from table1 as t1
2087
  where t1.key2 = (
2088
    select max(t2.key2) from table1 as t2
2089
    where t1.key1 = t2.key1
2090
  )
2091
) as latest_table1 on table1.key1 = latest_table1.key1
2092
EOS
2093
$join = [$sql];
2094
$rows = $dbi->select(
2095
    table => 'table1',
2096
    column => 'latest_table1.key1 as latest_table1__key1',
2097
    join  => $join
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2098
)->all;
data_source is DEPRECATED! I...
Yuki Kimoto authored on 2011-06-06
2099
is_deeply($rows, [{latest_table1__key1 => 1}]);
2100

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2101
test 'mycolumn';
2102
$dbi = MyDBI8->connect($NEW_ARGS->{0});
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
2103
$dbi->execute($CREATE_TABLE->{0});
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2104
$dbi->execute($CREATE_TABLE->{2});
2105
$dbi->setup_model;
2106
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2107
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2108
$model = $dbi->model('table1');
2109
$result = $model->select_at(
2110
    column => [
2111
        $model->mycolumn,
2112
        $model->column('table2')
2113
    ]
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
2114
);
added tests
Yuki Kimoto authored on 2011-06-08
2115
is_deeply($result->one,
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
2116
          {key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3});
- select() column option can...
Yuki Kimoto authored on 2011-06-07
2117

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2118
$result = $model->select_at(
2119
    column => [
2120
        $model->mycolumn(['key1']),
2121
        $model->column(table2 => ['key1'])
2122
    ]
2123
);
added tests
Yuki Kimoto authored on 2011-06-08
2124
is_deeply($result->one,
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
2125
          {key1 => 1, 'table2.key1' => 1});
- select() column option can...
Yuki Kimoto authored on 2011-06-07
2126
$result = $model->select_at(
2127
    column => [
2128
        $model->mycolumn(['key1']),
2129
        {table2 => ['key1']}
2130
    ]
2131
);
added tests
Yuki Kimoto authored on 2011-06-08
2132
is_deeply($result->one,
- select() EXPERIMETNAL colu...
Yuki Kimoto authored on 2011-06-08
2133
          {key1 => 1, 'table2.key1' => 1});
- select() column option can...
Yuki Kimoto authored on 2011-06-07
2134

            
- select() column option can...
Yuki Kimoto authored on 2011-06-08
2135
$result = $model->select_at(
2136
    column => [
2137
        $model->mycolumn(['key1']),
2138
        ['table2.key1', as => 'table2.key1']
2139
    ]
2140
);
2141
is_deeply($result->one,
2142
          {key1 => 1, 'table2.key1' => 1});
2143

            
2144
eval{
2145
    $result = $model->select_at(
2146
        column => [
2147
            ['table2.key1', asaaaa => 'table2.key1']
2148
        ]
2149
    );
2150
};
2151
like($@, qr/COLUMN/);
2152

            
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2153
test 'dbi method from model';
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-14
2154
{
2155
    package MyDBI9;
2156
    
2157
    use base 'DBIx::Custom';
2158
    
2159
    sub connect {
2160
        my $self = shift->SUPER::connect(@_);
2161
        
2162
        $self->include_model('MyModel8')->setup_model;
2163
        
2164
        return $self;
2165
    }
2166
}
2167
$dbi = MyDBI9->connect($NEW_ARGS->{0});
2168
$dbi->execute($CREATE_TABLE->{0});
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2169
$model = $dbi->model('table1');
2170
eval{$model->execute('select * from table1')};
2171
ok(!$@);
2172

            
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2173
test 'column table option';
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2174
$dbi = MyDBI9->connect($NEW_ARGS->{0});
2175
$dbi->execute($CREATE_TABLE->{0});
2176
$dbi->execute($CREATE_TABLE->{2});
2177
$dbi->setup_model;
2178
$dbi->execute('insert into table1 (key1, key2) values (1, 2);');
2179
$dbi->execute('insert into table2 (key1, key3) values (1, 4);');
2180
$model = $dbi->model('table1');
2181
$result = $model->select(
2182
    column => [
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2183
        $model->column('table2', {alias => 'table2_alias'})
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2184
    ],
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2185
    where => {'table2_alias.key3' => 4}
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2186
);
added tests
Yuki Kimoto authored on 2011-06-08
2187
is_deeply($result->one, 
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2188
          {'table2_alias.key1' => 1, 'table2_alias.key3' => 4});
- added EXPERIMENTAL DBIx::C...
Yuki Kimoto authored on 2011-03-15
2189

            
cleanup
Yuki Kimoto authored on 2011-06-13
2190
$dbi->separator('__');
2191
$result = $model->select(
2192
    column => [
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2193
        $model->column('table2', {alias => 'table2_alias'})
cleanup
Yuki Kimoto authored on 2011-06-13
2194
    ],
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2195
    where => {'table2_alias.key3' => 4}
cleanup
Yuki Kimoto authored on 2011-06-13
2196
);
2197
is_deeply($result->one, 
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2198
          {'table2_alias__key1' => 1, 'table2_alias__key3' => 4});
cleanup
Yuki Kimoto authored on 2011-06-13
2199

            
2200
$dbi->separator('-');
2201
$result = $model->select(
2202
    column => [
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2203
        $model->column('table2', {alias => 'table2_alias'})
cleanup
Yuki Kimoto authored on 2011-06-13
2204
    ],
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2205
    where => {'table2_alias.key3' => 4}
cleanup
Yuki Kimoto authored on 2011-06-13
2206
);
2207
is_deeply($result->one, 
- DBIx::Custom Model filter ...
Yuki Kimoto authored on 2011-06-15
2208
          {'table2_alias-key1' => 1, 'table2_alias-key3' => 4});
cleanup
Yuki Kimoto authored on 2011-06-13
2209

            
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
2210
test 'type option'; # DEPRECATED!
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
2211
$dbi = DBIx::Custom->connect(
2212
    data_source => 'dbi:SQLite:dbname=:memory:',
2213
    dbi_option => {
2214
        $DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1)
2215
    }
2216
);
2217
my $binary = pack("I3", 1, 2, 3);
2218
$dbi->execute('create table table1(key1, key2)');
2219
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, type => [key1 => DBI::SQL_BLOB]);
2220
$result = $dbi->select(table => 'table1');
added tests
Yuki Kimoto authored on 2011-06-08
2221
$row   = $result->one;
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
2222
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic");
2223
$result = $dbi->execute('select length(key1) as key1_length from table1');
added tests
Yuki Kimoto authored on 2011-06-08
2224
$row = $result->one;
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
2225
is($row->{key1_length}, length $binary);
2226

            
2227
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, type => [['key1'] => DBI::SQL_BLOB]);
2228
$result = $dbi->select(table => 'table1');
added tests
Yuki Kimoto authored on 2011-06-08
2229
$row   = $result->one;
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
2230
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic");
2231
$result = $dbi->execute('select length(key1) as key1_length from table1');
DBIx::Custom::Model type att...
Yuki Kimoto authored on 2011-06-17
2232
$row = $result->one;
2233
is($row->{key1_length}, length $binary);
2234

            
2235

            
2236
test 'bind_type option';
2237
$dbi = DBIx::Custom->connect(
2238
    data_source => 'dbi:SQLite:dbname=:memory:',
2239
    dbi_option => {
2240
        $DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1)
2241
    }
2242
);
2243
$binary = pack("I3", 1, 2, 3);
2244
$dbi->execute('create table table1(key1, key2)');
2245
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, bind_type => [key1 => DBI::SQL_BLOB]);
2246
$result = $dbi->select(table => 'table1');
2247
$row   = $result->one;
2248
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic");
2249
$result = $dbi->execute('select length(key1) as key1_length from table1');
2250
$row = $result->one;
2251
is($row->{key1_length}, length $binary);
2252

            
2253
$dbi->insert(table => 'table1', param => {key1 => $binary, key2 => 'あ'}, bind_type => [['key1'] => DBI::SQL_BLOB]);
2254
$result = $dbi->select(table => 'table1');
2255
$row   = $result->one;
2256
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic");
2257
$result = $dbi->execute('select length(key1) as key1_length from table1');
2258
$row = $result->one;
2259
is($row->{key1_length}, length $binary);
2260

            
2261
test 'model type attribute';
2262
$dbi = DBIx::Custom->connect(
2263
    data_source => 'dbi:SQLite:dbname=:memory:',
2264
    dbi_option => {
2265
        $DBD::SQLite::VERSION > 1.26 ? (sqlite_unicode => 1) : (unicode => 1)
2266
    }
2267
);
2268
$binary = pack("I3", 1, 2, 3);
2269
$dbi->execute('create table table1(key1, key2)');
2270
$model = $dbi->create_model(table => 'table1', bind_type => [key1 => DBI::SQL_BLOB]);
2271
$model->insert(param => {key1 => $binary, key2 => 'あ'});
2272
$result = $dbi->select(table => 'table1');
2273
$row   = $result->one;
2274
is_deeply($row, {key1 => $binary, key2 => 'あ'}, "basic");
2275
$result = $dbi->execute('select length(key1) as key1_length from table1');
added tests
Yuki Kimoto authored on 2011-06-08
2276
$row = $result->one;
- added EXPERIMENTAL type() ...
Yuki Kimoto authored on 2011-03-21
2277
is($row->{key1_length}, length $binary);
2278

            
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2279
test 'create_model';
2280
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2281
$dbi->execute($CREATE_TABLE->{0});
2282
$dbi->execute($CREATE_TABLE->{2});
2283

            
2284
$dbi->create_model(
2285
    table => 'table1',
2286
    join => [
2287
       'left outer join table2 on table1.key1 = table2.key1'
2288
    ],
2289
    primary_key => ['key1']
2290
);
create_model() return model
Yuki Kimoto authored on 2011-03-29
2291
$model2 = $dbi->create_model(
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2292
    table => 'table2'
2293
);
2294
$dbi->create_model(
2295
    table => 'table3',
2296
    filter => [
2297
        key1 => {in => sub { uc $_[0] }}
2298
    ]
2299
);
2300
$dbi->setup_model;
2301
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2302
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2303
$model = $dbi->model('table1');
2304
$result = $model->select(
2305
    column => [$model->mycolumn, $model->column('table2')],
2306
    where => {'table1.key1' => 1}
2307
);
added tests
Yuki Kimoto authored on 2011-06-08
2308
is_deeply($result->one,
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
2309
          {key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3});
added tests
Yuki Kimoto authored on 2011-06-08
2310
is_deeply($model2->select->one, {key1 => 1, key3 => 3});
removed EXPERIMETNAL flag fr...
Yuki Kimoto authored on 2011-03-25
2311

            
adeed EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-03-29
2312
test 'model method';
2313
test 'create_model';
2314
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2315
$dbi->execute($CREATE_TABLE->{2});
2316
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2317
$model = $dbi->create_model(
2318
    table => 'table2'
2319
);
2320
$model->method(foo => sub { shift->select(@_) });
added tests
Yuki Kimoto authored on 2011-06-08
2321
is_deeply($model->foo->one, {key1 => 1, key3 => 3});
added EXPERIMENTAL updat_par...
Yuki Kimoto authored on 2011-03-30
2322

            
2323
test 'merge_param';
2324
{
2325
    my $dbi = DBIx::Custom->new;
2326
    my $param1 = {key1 => 1, key2 => 2, key3 => 3};
2327
    my $param2 = {key1 => 1, key2 => 2};
2328
    my $param3 = {key1 => 1};
2329
    my $param = $dbi->merge_param($param1, $param2, $param3);
2330
    is_deeply($param, {key1 => [1, 1, 1], key2 => [2, 2], key3 => 3});
cleanup
Yuki Kimoto authored on 2011-04-01
2331
}
2332

            
fixed merge_param bug
Yuki Kimoto authored on 2011-05-23
2333
{
2334
    my $dbi = DBIx::Custom->new;
2335
    my $param1 = {key1 => [1, 2], key2 => 1, key3 => [1, 2]};
2336
    my $param2 = {key1 => [3, 4], key2 => [2, 3], key3 => 3};
2337
    my $param = $dbi->merge_param($param1, $param2);
2338
    is_deeply($param, {key1 => [1, 2, 3, 4], key2 => [1, 2, 3], key3 => [1, 2, 3]});
2339
}
2340

            
cleanup
Yuki Kimoto authored on 2011-04-01
2341
test 'select() param option';
2342
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2343
$dbi->execute($CREATE_TABLE->{0});
2344
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2345
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2346
$dbi->execute($CREATE_TABLE->{2});
2347
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
2348
$dbi->insert(table => 'table2', param => {key1 => 2, key3 => 5});
2349
$rows = $dbi->select(
2350
    table => 'table1',
2351
    column => 'table1.key1 as table1_key1, key2, key3',
2352
    where   => {'table1.key2' => 3},
2353
    join  => ['inner join (select * from table2 where {= table2.key3})' . 
2354
              ' as table2 on table1.key1 = table2.key1'],
2355
    param => {'table2.key3' => 5}
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2356
)->all;
cleanup
Yuki Kimoto authored on 2011-04-01
2357
is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]);
2358

            
added EXPERIMENTAL select() ...
Yuki Kimoto authored on 2011-04-19
2359

            
2360
test 'select() wrap option';
2361
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2362
$dbi->execute($CREATE_TABLE->{0});
2363
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2364
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2365
$rows = $dbi->select(
2366
    table => 'table1',
2367
    column => 'key1',
2368
    wrap => ['select * from (', ') as t where key1 = 1']
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2369
)->all;
added EXPERIMENTAL select() ...
Yuki Kimoto authored on 2011-04-19
2370
is_deeply($rows, [{key1 => 1}]);
2371

            
2372
eval {
2373
$dbi->select(
2374
    table => 'table1',
2375
    column => 'key1',
2376
    wrap => 'select * from ('
2377
)
2378
};
cleanup
Yuki Kimoto authored on 2011-04-25
2379
like($@, qr/array/);
2380

            
2381
test 'select() string where';
2382
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2383
$dbi->execute($CREATE_TABLE->{0});
2384
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2385
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2386
$rows = $dbi->select(
2387
    table => 'table1',
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
2388
    where => '{= key1} and {= key2}',
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2389
    where_param => {key1 => 1, key2 => 2}
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2390
)->all;
cleanup
Yuki Kimoto authored on 2011-04-25
2391
is_deeply($rows, [{key1 => 1, key2 => 2}]);
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
2392

            
2393
test 'delete() string where';
2394
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2395
$dbi->execute($CREATE_TABLE->{0});
2396
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2397
$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2398
$dbi->delete(
2399
    table => 'table1',
2400
    where => '{= key1} and {= key2}',
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2401
    where_param => {key1 => 1, key2 => 2}
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
2402
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2403
$rows = $dbi->select(table => 'table1')->all;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
2404
is_deeply($rows, [{key1 => 2, key2 => 3}]);
2405

            
2406

            
2407
test 'update() string where';
2408
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2409
$dbi->execute($CREATE_TABLE->{0});
2410
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2411
$dbi->update(
2412
    table => 'table1',
DEPRECATED select() param op...
Yuki Kimoto authored on 2011-04-25
2413
    param => {key1 => 5},
2414
    where => '{= key1} and {= key2}',
2415
    where_param => {key1 => 1, key2 => 2}
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
2416
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2417
$rows = $dbi->select(table => 'table1')->all;
select, update, and delete w...
Yuki Kimoto authored on 2011-04-25
2418
is_deeply($rows, [{key1 => 5, key2 => 2}]);
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
2419

            
cleanup
Yuki Kimoto authored on 2011-06-08
2420

            
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
2421
test 'insert id and primary_key option';
2422
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2423
$dbi->execute($CREATE_TABLE->{1});
2424
$dbi->insert(
2425
    primary_key => ['key1', 'key2'], 
2426
    table => 'table1',
2427
    id => [1, 2],
2428
    param => {key3 => 3}
2429
);
2430
is($dbi->select(table => 'table1')->one->{key1}, 1);
2431
is($dbi->select(table => 'table1')->one->{key2}, 2);
2432
is($dbi->select(table => 'table1')->one->{key3}, 3);
2433

            
2434
$dbi->delete_all(table => 'table1');
2435
$dbi->insert(
2436
    primary_key => 'key1', 
2437
    table => 'table1',
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2438
    id => 0,
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
2439
    param => {key2 => 2, key3 => 3}
2440
);
2441

            
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2442
is($dbi->select(table => 'table1')->one->{key1}, 0);
insert_at is DEPRECATED! add...
Yuki Kimoto authored on 2011-06-08
2443
is($dbi->select(table => 'table1')->one->{key2}, 2);
2444
is($dbi->select(table => 'table1')->one->{key3}, 3);
2445

            
2446
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2447
$dbi->execute($CREATE_TABLE->{1});
2448
$dbi->insert(
2449
    {key3 => 3},
2450
    primary_key => ['key1', 'key2'], 
2451
    table => 'table1',
2452
    id => [1, 2],
2453
);
2454
is($dbi->select(table => 'table1')->one->{key1}, 1);
2455
is($dbi->select(table => 'table1')->one->{key2}, 2);
2456
is($dbi->select(table => 'table1')->one->{key3}, 3);
2457

            
cleanup
Yuki Kimoto authored on 2011-06-08
2458

            
added tests
Yuki Kimoto authored on 2011-06-08
2459
test 'model insert id and primary_key option';
2460
$dbi = MyDBI6->connect($NEW_ARGS->{0});
2461
$dbi->execute($CREATE_TABLE->{1});
2462
$dbi->model('table1')->insert(
2463
    id => [1, 2],
2464
    param => {key3 => 3}
2465
);
2466
$result = $dbi->model('table1')->select;
2467
$row = $result->one;
2468
is($row->{key1}, 1);
2469
is($row->{key2}, 2);
2470
is($row->{key3}, 3);
2471

            
- fixed bug that model inser...
Yuki Kimoto authored on 2011-06-10
2472
$dbi = MyDBI6->connect($NEW_ARGS->{0});
2473
$dbi->execute($CREATE_TABLE->{1});
2474
$dbi->model('table1')->insert(
2475
    {key3 => 3},
2476
    id => [1, 2]
2477
);
2478
$result = $dbi->model('table1')->select;
2479
$row = $result->one;
2480
is($row->{key1}, 1);
2481
is($row->{key2}, 2);
2482
is($row->{key3}, 3);
2483

            
update_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2484
test 'update and id option';
2485
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2486
$dbi->execute($CREATE_TABLE->{1});
2487
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2488
$dbi->update(
2489
    table => 'table1',
2490
    primary_key => ['key1', 'key2'],
2491
    id => [1, 2],
2492
    param => {key3 => 4}
2493
);
2494
is($dbi->select(table => 'table1')->one->{key1}, 1);
2495
is($dbi->select(table => 'table1')->one->{key2}, 2);
2496
is($dbi->select(table => 'table1')->one->{key3}, 4);
2497

            
2498
$dbi->delete_all(table => 'table1');
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2499
$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
update_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2500
$dbi->update(
2501
    table => 'table1',
2502
    primary_key => 'key1',
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2503
    id => 0,
update_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2504
    param => {key3 => 4}
2505
);
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2506
is($dbi->select(table => 'table1')->one->{key1}, 0);
update_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2507
is($dbi->select(table => 'table1')->one->{key2}, 2);
2508
is($dbi->select(table => 'table1')->one->{key3}, 4);
2509

            
2510
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2511
$dbi->execute($CREATE_TABLE->{1});
2512
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2513
$dbi->update(
2514
    {key3 => 4},
2515
    table => 'table1',
2516
    primary_key => ['key1', 'key2'],
2517
    id => [1, 2]
2518
);
2519
is($dbi->select(table => 'table1')->one->{key1}, 1);
2520
is($dbi->select(table => 'table1')->one->{key2}, 2);
2521
is($dbi->select(table => 'table1')->one->{key3}, 4);
2522

            
2523

            
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2524
test 'model update and id option';
update_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2525
$dbi = MyDBI6->connect($NEW_ARGS->{0});
2526
$dbi->execute($CREATE_TABLE->{1});
2527
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2528
$dbi->model('table1')->update(
2529
    id => [1, 2],
2530
    param => {key3 => 4}
2531
);
2532
$result = $dbi->model('table1')->select;
2533
$row = $result->one;
2534
is($row->{key1}, 1);
2535
is($row->{key2}, 2);
2536
is($row->{key3}, 4);
added tests
Yuki Kimoto authored on 2011-06-08
2537

            
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2538

            
2539
test 'delete and id option';
2540
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2541
$dbi->execute($CREATE_TABLE->{1});
2542
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2543
$dbi->delete(
2544
    table => 'table1',
2545
    primary_key => ['key1', 'key2'],
2546
    id => [1, 2],
2547
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2548
is_deeply($dbi->select(table => 'table1')->all, []);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2549

            
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2550
$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2551
$dbi->delete(
2552
    table => 'table1',
2553
    primary_key => 'key1',
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2554
    id => 0,
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2555
);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2556
is_deeply($dbi->select(table => 'table1')->all, []);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2557

            
2558

            
2559
test 'model delete and id option';
2560
$dbi = MyDBI6->connect($NEW_ARGS->{0});
2561
$dbi->execute($CREATE_TABLE->{1});
2562
$dbi->execute("create table table2 (key1, key2, key3)");
2563
$dbi->execute("create table table3 (key1, key2, key3)");
2564
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2565
$dbi->model('table1')->delete(id => [1, 2]);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2566
is_deeply($dbi->select(table => 'table1')->all, []);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2567
$dbi->insert(table => 'table2', param => {key1 => 1, key2 => 2, key3 => 3});
2568
$dbi->model('table1_1')->delete(id => [1, 2]);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2569
is_deeply($dbi->select(table => 'table1')->all, []);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2570
$dbi->insert(table => 'table3', param => {key1 => 1, key2 => 2, key3 => 3});
2571
$dbi->model('table1_3')->delete(id => [1, 2]);
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
2572
is_deeply($dbi->select(table => 'table1')->all, []);
delete_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2573

            
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2574

            
2575
test 'select and id option';
2576
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
2577
$dbi->execute($CREATE_TABLE->{1});
2578
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2579
$result = $dbi->select(
2580
    table => 'table1',
2581
    primary_key => ['key1', 'key2'],
2582
    id => [1, 2]
2583
);
2584
$row = $result->one;
2585
is($row->{key1}, 1);
2586
is($row->{key2}, 2);
2587
is($row->{key3}, 3);
2588

            
2589
$dbi->delete_all(table => 'table1');
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2590
$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2591
$result = $dbi->select(
2592
    table => 'table1',
2593
    primary_key => 'key1',
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2594
    id => 0,
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2595
);
2596
$row = $result->one;
fixed small insert, update, ...
Yuki Kimoto authored on 2011-06-21
2597
is($row->{key1}, 0);
select_at is DEPRECATED! use...
Yuki Kimoto authored on 2011-06-08
2598
is($row->{key2}, 2);
2599
is($row->{key3}, 3);
2600

            
2601
$dbi->delete_all(table => 'table1');
2602
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2603
$result = $dbi->select(
2604
    table => 'table1',
2605
    primary_key => ['key1', 'key2'],
2606
    id => [1, 2]
2607
);
2608
$row = $result->one;
2609
is($row->{key1}, 1);
2610
is($row->{key2}, 2);
2611
is($row->{key3}, 3);
2612

            
2613

            
2614
test 'model select_at';
2615
$dbi = MyDBI6->connect($NEW_ARGS->{0});
2616
$dbi->execute($CREATE_TABLE->{1});
2617
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2618
$result = $dbi->model('table1')->select(id => [1, 2]);
2619
$row = $result->one;
2620
is($row->{key1}, 1);
2621
is($row->{key2}, 2);
2622
is($row->{key3}, 3);
2623

            
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
2624
test 'column separator is default .';
added EXPERIMENTAL col metho...
Yuki Kimoto authored on 2011-06-08
2625
$dbi = MyDBI7->connect($NEW_ARGS->{0});
2626
$dbi->execute($CREATE_TABLE->{0});
2627
$dbi->execute($CREATE_TABLE->{2});
2628
$dbi->setup_model;
2629
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2630
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2631
$model = $dbi->model('table1');
2632
$result = $model->select(
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
2633
    column => [$model->column('table2')],
added EXPERIMENTAL col metho...
Yuki Kimoto authored on 2011-06-08
2634
    where => {'table1.key1' => 1}
2635
);
2636
is_deeply($result->one,
2637
          {'table2.key1' => 1, 'table2.key3' => 3});
2638

            
2639
$result = $model->select(
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
2640
    column => [$model->column('table2' => [qw/key1 key3/])],
added EXPERIMENTAL col metho...
Yuki Kimoto authored on 2011-06-08
2641
    where => {'table1.key1' => 1}
2642
);
2643
is_deeply($result->one,
2644
          {'table2.key1' => 1, 'table2.key3' => 3});
2645

            
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
2646

            
2647
test 'type_rule from';
2648
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2649
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2650
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2651
        date => sub { uc $_[0] }
added type_rule method and f...
Yuki Kimoto authored on 2011-06-09
2652
    }
2653
);
2654
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2655
$dbi->insert({key1 => 'a'}, table => 'table1');
2656
$result = $dbi->select(table => 'table1');
2657
is($result->fetch_first->[0], 'A');
2658

            
2659
$result = $dbi->select(table => 'table1');
2660
is($result->one->{key1}, 'A');
2661

            
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2662

            
2663
test 'type_rule into';
2664
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2665
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2666
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2667
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2668
        date => sub { uc $_[0] }
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2669
    }
2670
);
2671
$dbi->insert({key1 => 'a'}, table => 'table1');
2672
$result = $dbi->select(table => 'table1');
2673
is($result->one->{key1}, 'A');
2674

            
2675
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2676
$dbi->execute("create table table1 (key1 date, key2 datetime)");
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2677
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2678
    into1 => [
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2679
         [qw/date datetime/] => sub { uc $_[0] }
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2680
    ]
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2681
);
2682
$dbi->insert({key1 => 'a', key2 => 'b'}, table => 'table1');
2683
$result = $dbi->select(table => 'table1');
2684
$row = $result->one;
2685
is($row->{key1}, 'A');
2686
is($row->{key2}, 'B');
2687

            
2688
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2689
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2690
$dbi->insert({key1 => 'a', key2 => 'B'}, table => 'table1');
2691
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2692
    into1 => [
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2693
        [qw/date datetime/] => sub { uc $_[0] }
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2694
    ]
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2695
);
2696
$result = $dbi->execute(
2697
    "select * from table1 where key1 = :key1 and key2 = :table1.key2;",
2698
    param => {key1 => 'a', 'table1.key2' => 'b'}
2699
);
2700
$row = $result->one;
2701
is($row->{key1}, 'a');
2702
is($row->{key2}, 'B');
2703

            
2704
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2705
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2706
$dbi->insert({key1 => 'A', key2 => 'B'}, table => 'table1');
2707
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2708
    into1 => [
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2709
        [qw/date datetime/] => sub { uc $_[0] }
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2710
    ]
added type_rule into logic
Yuki Kimoto authored on 2011-06-09
2711
);
2712
$result = $dbi->execute(
2713
    "select * from table1 where key1 = :key1 and key2 = :table1.key2;",
2714
    param => {key1 => 'a', 'table1.key2' => 'b'},
2715
    table => 'table1'
2716
);
2717
$row = $result->one;
2718
is($row->{key1}, 'A');
2719
is($row->{key2}, 'B');
2720

            
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
2721
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2722
$dbi->execute("create table table1 (key1 date, key2 datetime)");
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
2723
$dbi->register_filter(twice => sub { $_[0] * 2 });
2724
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2725
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2726
        date => 'twice',
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
2727
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2728
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2729
        date => 'twice',
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
2730
    }
2731
);
2732
$dbi->insert({key1 => 2}, table => 'table1');
2733
$result = $dbi->select(table => 'table1');
2734
is($result->fetch->[0], 8);
2735

            
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2736
test 'type_rule and filter order';
2737
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2738
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2739
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2740
    into1 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2741
        date => sub { $_[0] . 'b' }
2742
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2743
    into2 => {
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2744
        date => sub { $_[0] . 'c' }
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2745
    },
2746
    from1 => {
2747
        date => sub { $_[0] . 'd' }
2748
    },
2749
    from2 => {
2750
        date => sub { $_[0] . 'e' }
separate DBIx::Custom type_r...
Yuki Kimoto authored on 2011-06-15
2751
    }
2752
);
2753
$dbi->insert({key1 => '1'}, table => 'table1', filter => {key1 => sub { $_[0] . 'a' }});
2754
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2755
$result->filter(key1 => sub { $_[0] . 'f' });
2756
is($result->fetch_first->[0], '1abcdef');
2757

            
2758
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2759
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2760
$dbi->type_rule(
2761
    from1 => {
2762
        date => sub { $_[0] . 'p' }
2763
    },
2764
    from2 => {
2765
        date => sub { $_[0] . 'q' }
2766
    },
2767
);
2768
$dbi->insert({key1 => '1'}, table => 'table1');
2769
$result = $dbi->select(table => 'table1');
2770
$result->type_rule(
2771
    from1 => {
2772
        date => sub { $_[0] . 'd' }
2773
    },
2774
    from2 => {
2775
        date => sub { $_[0] . 'e' }
2776
    }
2777
);
2778
$result->filter(key1 => sub { $_[0] . 'f' });
2779
is($result->fetch_first->[0], '1def');
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2780

            
2781
test 'type_rule_off';
2782
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2783
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2784
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2785
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2786
        date => sub { $_[0] * 2 },
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2787
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2788
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2789
        date => sub { $_[0] * 2 },
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2790
    }
2791
);
2792
$dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
2793
$result = $dbi->select(table => 'table1', type_rule_off => 1);
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
2794
is($result->type_rule_off->fetch->[0], 2);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2795

            
2796
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2797
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2798
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2799
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2800
        date => sub { $_[0] * 2 },
changed type_rule arguments ...
Yuki Kimoto authored on 2011-06-12
2801
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2802
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2803
        date => sub { $_[0] * 3 },
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2804
    }
2805
);
2806
$dbi->insert({key1 => 2}, table => 'table1', type_rule_off => 1);
2807
$result = $dbi->select(table => 'table1', type_rule_off => 1);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2808
is($result->one->{key1}, 4);
2809

            
2810
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2811
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2812
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2813
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2814
        date => sub { $_[0] * 2 },
2815
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2816
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2817
        date => sub { $_[0] * 3 },
2818
    }
2819
);
2820
$dbi->insert({key1 => 2}, table => 'table1');
2821
$result = $dbi->select(table => 'table1');
2822
is($result->one->{key1}, 12);
2823

            
2824
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2825
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2826
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2827
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2828
        date => sub { $_[0] * 2 },
2829
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2830
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2831
        date => sub { $_[0] * 3 },
2832
    }
2833
);
2834
$dbi->insert({key1 => 2}, table => 'table1');
2835
$result = $dbi->select(table => 'table1');
2836
is($result->fetch->[0], 12);
added EXPERIMENTAL execute()...
Yuki Kimoto authored on 2011-06-09
2837

            
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
2838
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2839
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2840
$dbi->register_filter(ppp => sub { uc $_[0] });
2841
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2842
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2843
        date => 'ppp'
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
2844
    }
2845
);
2846
$dbi->insert({key1 => 'a'}, table => 'table1');
2847
$result = $dbi->select(table => 'table1');
2848
is($result->one->{key1}, 'A');
2849

            
2850
eval{$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2851
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2852
        date => 'pp'
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
2853
    }
2854
)};
2855
like($@, qr/not registered/);
added DBIx::Custom result_fi...
Yuki Kimoto authored on 2011-06-12
2856

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2857
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2858
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2859
eval {
2860
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2861
        from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2862
            Date => sub { $_[0] * 2 },
2863
        }
2864
    );
2865
};
2866
like($@, qr/lower/);
2867

            
2868
eval {
2869
    $dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2870
        into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2871
            Date => sub { $_[0] * 2 },
2872
        }
2873
    );
2874
};
2875
like($@, qr/lower/);
2876

            
2877
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2878
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2879
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2880
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2881
        date => sub { $_[0] * 2 },
2882
    },
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2883
    into1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2884
        date => sub { $_[0] * 3 },
2885
    }
2886
);
2887
$dbi->insert({key1 => 2}, table => 'table1');
2888
$result = $dbi->select(table => 'table1');
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
2889
$result->type_rule_off;
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2890
is($result->one->{key1}, 6);
2891

            
2892
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2893
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2894
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2895
    from1 => {
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2896
        date => sub { $_[0] * 2 },
2897
        datetime => sub { $_[0] * 4 },
2898
    },
2899
);
2900
$dbi->insert({key1 => 2, key2 => 2}, table => 'table1');
2901
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2902
$result->type_rule(
2903
    from1 => {
2904
        date => sub { $_[0] * 3 }
2905
    }
2906
);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2907
$row = $result->one;
2908
is($row->{key1}, 6);
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2909
is($row->{key2}, 2);
2910

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2911
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2912
$result->type_rule(
2913
    from1 => {
2914
        date => sub { $_[0] * 3 }
2915
    }
2916
);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2917
$row = $result->one;
2918
is($row->{key1}, 6);
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2919
is($row->{key2}, 2);
2920

            
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2921
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2922
$result->type_rule(
2923
    from1 => {
2924
        date => sub { $_[0] * 3 }
2925
    }
2926
);
cleanup
Yuki Kimoto authored on 2011-06-15
2927
$row = $result->one;
2928
is($row->{key1}, 6);
2929
is($row->{key2}, 2);
2930
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2931
$result->type_rule(
2932
    from1 => [date => sub { $_[0] * 3 }]
2933
);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2934
$row = $result->one;
2935
is($row->{key1}, 6);
cleanup
Yuki Kimoto authored on 2011-06-15
2936
is($row->{key2}, 2);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2937
$dbi->register_filter(fivetimes => sub { $_[0] * 5});
2938
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2939
$result->type_rule(
2940
    from1 => [date => 'fivetimes']
2941
);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2942
$row = $result->one;
2943
is($row->{key1}, 10);
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2944
is($row->{key2}, 2);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2945
$result = $dbi->select(table => 'table1');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2946
$result->type_rule(
2947
    from1 => [date => undef]
2948
);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2949
$row = $result->one;
2950
is($row->{key1}, 2);
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2951
is($row->{key2}, 2);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2952

            
DBIx::Custom::Result filter ...
Yuki Kimoto authored on 2011-06-14
2953
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2954
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2955
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2956
    from1 => {
DBIx::Custom::Result filter ...
Yuki Kimoto authored on 2011-06-14
2957
        date => sub { $_[0] * 2 },
2958
    },
2959
);
2960
$dbi->insert({key1 => 2}, table => 'table1');
2961
$result = $dbi->select(table => 'table1');
removed EXPERIMENTAL DBIx::M...
Yuki Kimoto authored on 2011-06-14
2962
$result->filter(key1 => sub { $_[0] * 3 });
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
2963
is($result->one->{key1}, 12);
2964

            
2965
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2966
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2967
$dbi->type_rule(
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2968
    from1 => {
separate DBIx::Custom::Resul...
Yuki Kimoto authored on 2011-06-15
2969
        date => sub { $_[0] * 2 },
2970
    },
2971
);
2972
$dbi->insert({key1 => 2}, table => 'table1');
2973
$result = $dbi->select(table => 'table1');
2974
$result->filter(key1 => sub { $_[0] * 3 });
2975
is($result->fetch->[0], 12);
added EXPERIMENTAL DBIx::Cus...
Yuki Kimoto authored on 2011-06-14
2976

            
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2977
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2978
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
2979
$dbi->type_rule(
2980
    into1 => {
2981
        date => sub { $_[0] . 'b' }
2982
    },
2983
    into2 => {
2984
        date => sub { $_[0] . 'c' }
2985
    },
2986
    from1 => {
2987
        date => sub { $_[0] . 'd' }
2988
    },
2989
    from2 => {
2990
        date => sub { $_[0] . 'e' }
2991
    }
2992
);
2993
$dbi->insert({key1 => '1'}, table => 'table1', type_rule_off => 1);
2994
$result = $dbi->select(table => 'table1');
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
2995
is($result->type_rule_off->fetch_first->[0], '1');
2996
$result = $dbi->select(table => 'table1');
2997
is($result->type_rule_on->fetch_first->[0], '1de');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
2998

            
2999
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
3000
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
3001
$dbi->type_rule(
3002
    into1 => {
3003
        date => sub { $_[0] . 'b' }
3004
    },
3005
    into2 => {
3006
        date => sub { $_[0] . 'c' }
3007
    },
3008
    from1 => {
3009
        date => sub { $_[0] . 'd' }
3010
    },
3011
    from2 => {
3012
        date => sub { $_[0] . 'e' }
3013
    }
3014
);
3015
$dbi->insert({key1 => '1'}, table => 'table1', type_rule1_off => 1);
3016
$result = $dbi->select(table => 'table1');
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
3017
is($result->type_rule1_off->fetch_first->[0], '1ce');
3018
$result = $dbi->select(table => 'table1');
3019
is($result->type_rule1_on->fetch_first->[0], '1cde');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3020

            
3021
$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
3022
$dbi->execute("create table table1 (key1 Date, key2 datetime)");
3023
$dbi->type_rule(
3024
    into1 => {
3025
        date => sub { $_[0] . 'b' }
3026
    },
3027
    into2 => {
3028
        date => sub { $_[0] . 'c' }
3029
    },
3030
    from1 => {
3031
        date => sub { $_[0] . 'd' }
3032
    },
3033
    from2 => {
3034
        date => sub { $_[0] . 'e' }
3035
    }
3036
);
3037
$dbi->insert({key1 => '1'}, table => 'table1', type_rule2_off => 1);
3038
$result = $dbi->select(table => 'table1');
- changed EXPERIMENTAL DBIx:...
Yuki Kimoto authored on 2011-06-20
3039
is($result->type_rule2_off->fetch_first->[0], '1bd');
3040
$result = $dbi->select(table => 'table1');
3041
is($result->type_rule2_on->fetch_first->[0], '1bde');
EXPERIMENTAL type_rule argum...
Yuki Kimoto authored on 2011-06-17
3042

            
removed EXPERIMENTAL DBIx::M...
Yuki Kimoto authored on 2011-06-14
3043
test 'separator';
added DBIx::Custom result_fi...
Yuki Kimoto authored on 2011-06-12
3044
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
3045
$dbi->execute($CREATE_TABLE->{0});
3046
$dbi->execute($CREATE_TABLE->{2});
3047

            
3048
$dbi->create_model(
3049
    table => 'table1',
3050
    join => [
3051
       'left outer join table2 on table1.key1 = table2.key1'
3052
    ],
3053
    primary_key => ['key1'],
3054
);
3055
$model2 = $dbi->create_model(
3056
    table => 'table2',
3057
);
3058
$dbi->setup_model;
3059
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3060
$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
3061
$model = $dbi->model('table1');
3062
$result = $model->select(
3063
    column => [
3064
        $model->mycolumn,
3065
        {table2 => [qw/key1 key3/]}
3066
    ],
3067
    where => {'table1.key1' => 1}
3068
);
3069
is_deeply($result->one,
removed EXPERIMENTAL DBIx::M...
Yuki Kimoto authored on 2011-06-14
3070
          {key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3});
3071
is_deeply($model2->select->one, {key1 => 1, key3 => 3});
added DBIx::Custom result_fi...
Yuki Kimoto authored on 2011-06-12
3072

            
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
3073
$dbi->separator('__');
3074
$model = $dbi->model('table1');
3075
$result = $model->select(
3076
    column => [
3077
        $model->mycolumn,
3078
        {table2 => [qw/key1 key3/]}
3079
    ],
3080
    where => {'table1.key1' => 1}
3081
);
3082
is_deeply($result->one,
removed EXPERIMENTAL DBIx::M...
Yuki Kimoto authored on 2011-06-14
3083
          {key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3});
3084
is_deeply($model2->select->one, {key1 => 1, key3 => 3});
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
3085

            
cleanup
Yuki Kimoto authored on 2011-06-13
3086
$dbi->separator('-');
3087
$model = $dbi->model('table1');
3088
$result = $model->select(
3089
    column => [
3090
        $model->mycolumn,
3091
        {table2 => [qw/key1 key3/]}
3092
    ],
3093
    where => {'table1.key1' => 1}
3094
);
3095
is_deeply($result->one,
removed EXPERIMENTAL DBIx::M...
Yuki Kimoto authored on 2011-06-14
3096
          {key1 => 1, key2 => 2, 'table2-key1' => 1, 'table2-key3' => 3});
3097
is_deeply($model2->select->one, {key1 => 1, key3 => 3});
cleanup
Yuki Kimoto authored on 2011-06-13
3098

            
EXPERIMTANL column method th...
Yuki Kimoto authored on 2011-06-13
3099

            
type_rule can receive filter...
Yuki Kimoto authored on 2011-06-12
3100
test 'filter_off';
3101
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
3102
$dbi->execute($CREATE_TABLE->{0});
3103
$dbi->execute($CREATE_TABLE->{2});
3104

            
3105
$dbi->create_model(
3106
    table => 'table1',
3107
    join => [
3108
       'left outer join table2 on table1.key1 = table2.key1'
3109
    ],
3110
    primary_key => ['key1'],
3111
);
3112
$dbi->setup_model;
3113
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3114
$model = $dbi->model('table1');
removed EXPERIMENTAL DBIx::M...
Yuki Kimoto authored on 2011-06-14
3115
$result = $model->select(column => 'key1');
3116
$result->filter(key1 => sub { $_[0] * 2 });
3117
is_deeply($result->one, {key1 => 2});
fixed bug that type_rule fro...
Yuki Kimoto authored on 2011-06-13
3118

            
3119
test 'available_date_type';
3120
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
3121
ok($dbi->can('available_data_type'));
3122

            
added EXPERIMENTAL select pr...
Yuki Kimoto authored on 2011-06-13
3123

            
3124
test 'select prefix option';
3125
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
3126
$dbi->execute($CREATE_TABLE->{0});
3127
$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3128
$rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all;
3129
is_deeply($rows, [{key1 => 1, key2 => 2}], "table");
3130

            
added EXPERIMETNAL separator...
Yuki Kimoto authored on 2011-06-13
3131

            
3132
test 'separator';
3133
$dbi = DBIx::Custom->connect($NEW_ARGS->{0});
3134
is($dbi->separator, '.');
3135
$dbi->separator('-');
3136
is($dbi->separator, '-');
3137
$dbi->separator('__');
3138
is($dbi->separator, '__');
3139
eval { $dbi->separator('?') };
3140
like($@, qr/Separator/);
3141

            
- update_param_tag is DEPREC...
Yuki Kimoto authored on 2011-06-07
3142
=cut