Showing 2 changed files with 12 additions and 73 deletions
+12 -7
t/common.t
... ...
@@ -17,7 +17,8 @@ sub test { print "# $_[0]\n" }
17 17
 # Constant
18 18
 my $create_table1 = $dbi->create_table1;
19 19
 my $create_table1_2 = $dbi->create_table1_2;
20
-
20
+my $q = substr($dbi->quote, 0, 1);
21
+my $p = substr($dbi->quote, 1, 1) || $q;
21 22
 
22 23
 # Variable
23 24
 # Variables
... ...
@@ -247,7 +248,8 @@ eval{$dbi->execute("{p }", {}, query => 1)};
247 248
 ok($@, "create_query invalid SQL template");
248 249
 
249 250
 test 'insert';
250
-$dbi->delete_all(table => 'table1');
251
+eval { $dbi->execute('drop table table1') };
252
+$dbi->execute($create_table1);
251 253
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
252 254
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
253 255
 $result = $dbi->execute('select * from table1;');
... ...
@@ -266,7 +268,8 @@ $rows   = $result->all;
266 268
 is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
267 269
 $dbi->default_bind_filter(undef);
268 270
 
269
-$dbi->delete_all(table => 'table1');
271
+$dbi->execute('drop table table1');
272
+$dbi->execute($create_table1);
270 273
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
271 274
 $rows = $dbi->select(table => 'table1')->all;
272 275
 is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
... ...
@@ -277,16 +280,16 @@ like($@, qr/noexist/, "invalid");
277 280
 eval{$dbi->insert(table => 'table', param => {';' => 1})};
278 281
 like($@, qr/safety/);
279 282
 
280
-__END__
281
-
282 283
 $dbi->quote('"');
283
-$dbi->execute('create table "table" ("select")');
284
+eval { $dbi->execute("drop table ${q}table$p") };
285
+$dbi->execute("create table ${q}table$p (${q}select$p)");
284 286
 $dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
285 287
 $dbi->insert(table => 'table', param => {select => 1});
286
-$result = $dbi->execute('select * from "table"');
288
+$result = $dbi->execute("select * from ${q}table$p");
287 289
 $rows   = $result->all;
288 290
 is_deeply($rows, [{select => 2}], "reserved word");
289 291
 
292
+eval { $dbi->execute('drop table table1') };
290 293
 $dbi->execute($create_table1);
291 294
 $dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
292 295
 $dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
... ...
@@ -294,6 +297,7 @@ $result = $dbi->execute('select * from table1;');
294 297
 $rows   = $result->all;
295 298
 is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
296 299
 
300
+eval { $dbi->execute('drop table table1') };
297 301
 $dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))");
298 302
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
299 303
 $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4}, prefix => 'or replace');
... ...
@@ -301,6 +305,7 @@ $result = $dbi->execute('select * from table1;');
301 305
 $rows   = $result->all;
302 306
 is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
303 307
 
308
+eval { $dbi->execute('drop table table1') };
304 309
 $dbi->execute($create_table1);
305 310
 $dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
306 311
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
-66
t/sqlite.t
... ...
@@ -65,72 +65,6 @@ my $binary;
65 65
 # Prepare table
66 66
 $dbi = DBIx::Custom->connect;
67 67
 
68
-test 'insert';
69
-eval { $dbi->execute('drop table table1') };
70
-$dbi->execute($create_table1);
71
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
72
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
73
-$result = $dbi->execute('select * from table1;');
74
-$rows   = $result->all;
75
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
76
-
77
-$dbi->execute('delete from table1');
78
-$dbi->register_filter(
79
-    twice       => sub { $_[0] * 2 },
80
-    three_times => sub { $_[0] * 3 }
81
-);
82
-$dbi->default_bind_filter('twice');
83
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'});
84
-$result = $dbi->execute('select * from table1;');
85
-$rows   = $result->all;
86
-is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
87
-$dbi->default_bind_filter(undef);
88
-
89
-$dbi->execute('drop table table1');
90
-$dbi->execute($create_table1);
91
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
92
-$rows = $dbi->select(table => 'table1')->all;
93
-is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
94
-
95
-eval{$dbi->insert(table => 'table1', noexist => 1)};
96
-like($@, qr/noexist/, "invalid");
97
-
98
-eval{$dbi->insert(table => 'table', param => {';' => 1})};
99
-like($@, qr/safety/);
100
-
101
-$dbi->quote('"');
102
-eval { $dbi->execute("drop table ${q}table$p") };
103
-$dbi->execute("create table ${q}table$p (${q}select$p)");
104
-$dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
105
-$dbi->insert(table => 'table', param => {select => 1});
106
-$result = $dbi->execute("select * from ${q}table$p");
107
-$rows   = $result->all;
108
-is_deeply($rows, [{select => 2}], "reserved word");
109
-
110
-eval { $dbi->execute('drop table table1') };
111
-$dbi->execute($create_table1);
112
-$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
113
-$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
114
-$result = $dbi->execute('select * from table1;');
115
-$rows   = $result->all;
116
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
117
-
118
-eval { $dbi->execute('drop table table1') };
119
-$dbi->execute("create table table1 (key1 char(255), key2 char(255), primary key(key1))");
120
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
121
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 4}, prefix => 'or replace');
122
-$result = $dbi->execute('select * from table1;');
123
-$rows   = $result->all;
124
-is_deeply($rows, [{key1 => 1, key2 => 4}], "basic");
125
-
126
-eval { $dbi->execute('drop table table1') };
127
-$dbi->execute($create_table1);
128
-$dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
129
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
130
-$result = $dbi->execute('select * from table1;');
131
-$rows   = $result->all;
132
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
133
-
134 68
 test 'update';
135 69
 eval { $dbi->execute('drop table table1') };
136 70
 $dbi->execute($create_table1_2);