Showing 9 changed files with 1627 additions and 1434 deletions
+5
t/_run/common-db2.run
... ...
@@ -0,0 +1,5 @@
1
+### DB2 Install
2
+
3
+cd /usr/local/src
4
+
5
+curl -L https://www6.software.ibm.com/sdfdl/v2/regs2/db2pmopn/db2_v97/expc/Xa.2/Xb.aA_60_-iVlRRTUNBO90Dq4FHTisv_wdecoCQFeRQbw/Xc.db2exc_974_LNX_x86.tar.gz/Xd./Xf.LPr.D1vk/Xg.6107654/Xi.swg-db2expressc/XY.regsrvs/XZ.2ygJIAbTC5bn3tv2hlm2PnXUcz8/db2exc_974_LNX_x86.tar.gz > db2exc_974_LNX_x86.tar.gz
+5
t/_run/common-mysql.run
... ...
@@ -0,0 +1,5 @@
1
+# Create database
2
+create database dbix_custom;
3
+
4
+# Create User
5
+GRANT ALL PRIVILEGES ON dbix_custom.* TO dbix_custom@"localhost" IDENTIFIED BY 'dbix_custom';
+55
t/_run/common-oracle.run
... ...
@@ -0,0 +1,55 @@
1
+# Download
2
+http://download.oracle.com/otn/linux/oracle10g/xe/10201/oracle-xe-univ-10.2.0.1-1.0.i386.rpm
3
+
4
+# Install
5
+rpm -ivh oracle-xe-univ-10.2.0.1-1.0.i386.rpm
6
+/etc/init.d/oracle-xe configure
7
+
8
+# Note
9
+Port number is set to 8090
10
+
11
+# HTTP access
12
+http://127.0.0.1:8090/apex
13
+
14
+# Create user
15
+id: dbix_custom
16
+password: dbix_custom
17
+
18
+Add all privirage
19
+
20
+# DBD::Oracle
21
+You must be install install client
22
+oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm
23
+oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm
24
+oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
25
+
26
+rpm -hiv oracle-instantclient11.2-basic-11.2.0.2.0.i386.rpm
27
+rpm -hiv oracle-instantclient11.2-devel-11.2.0.2.0.i386.rpm
28
+rpm -hiv oracle-instantclient11.2-sqlplus-11.2.0.2.0.i386.rpm
29
+
30
+vi /etc/profile.d/oracle.sh
31
+export ORACLE_HOME='/usr/lib/oracle/11.2/client'
32
+export C_INCLUDE_PATH='/usr/include/oracle/11.2/client'
33
+export LD_LIBRARY_PATH='/usr/lib/oracle/11.2/client/lib'
34
+
35
+vi /etc/ld.so.conf.d/oracle.conf
36
+/usr/lib/oracle/11.2/client/lib
37
+
38
+cpan DBD::Oracle
39
+
40
+sqlplus dbix_custom/dbix_custom@localhost:1521/XE
41
+
42
+mkdir -p $ORACLE_HOME/network/admin/
43
+vi $ORACLE_HOME/network/admin/tnsnames.ora
44
+
45
+XE =
46
+  (DESCRIPTION =
47
+    (ADDRESS_LIST =
48
+      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
49
+    )
50
+    (CONNECT_DATA =
51
+      (SID = orcl)
52
+    )
53
+  )
54
+
55
+
+35
t/_run/common-postgresql.run
... ...
@@ -0,0 +1,35 @@
1
+### CentOS5
2
+
3
+# Install
4
+yum -y install postgresql-server
5
+yum -y install postgresql
6
+yum -y install postgresql-devel
7
+chkconfig --level 2345 postgresql on
8
+
9
+# Start server
10
+service postgresql start
11
+
12
+# Change config file
13
+vi /var/lib/pgsql/data/pg_hba.conf
14
+  # "local" is for Unix domain socket connections only
15
+  local   all         all                               trust
16
+
17
+# Create user and database
18
+su - postgres
19
+createuser -a -d -U postgres -P dbix_custom
20
+  # Shall the new role be a superuser? (y/n) -> y
21
+  # Shall the new role be allowed to create databases? (y/n) -> y
22
+  # Shall the new role be allowed to create more new roles? (y/n) -> y
23
+
24
+createdb dbix_custom -U dbix_custom
25
+
26
+# Connect to database
27
+psql -U dbix_custom dbix_custom
28
+
29
+# Install DBD::pg
30
+cpanm DBD::Pg
31
+
32
+### Memo
33
+
34
+# Drop user
35
+dropuser dbix_custom
+13
t/_run/common-sqlserver.run
... ...
@@ -0,0 +1,13 @@
1
+# Site
2
+http://awoni.net/fc/sql-server-2008-express/
3
+
4
+
5
+# Install
6
+http://www.microsoft.com/downloads/ja-jp/details.aspx?displaylang=ja&FamilyID=967225eb-207b-4950-91df-eeb5f35a80ee
7
+
8
+
9
+# Note
10
+You enable SQL Server authentication.
11
+You create user "dbix_custom", password "dbix_custom"
12
+You give create_table, insert, update, delete, select authority to user "dbix_custom".
13
+
t/_run/mysql.run
No changes.
+38
t/common-sqlite-quote.t_
... ...
@@ -0,0 +1,38 @@
1
+use strict;
2
+use warnings;
3
+
4
+use FindBin;
5
+$ENV{DBIX_CUSTOM_TEST_RUN} = 1;
6
+
7
+use DBIx::Custom;
8
+{
9
+    package DBIx::Custom;
10
+    no warnings 'redefine';
11
+
12
+    my $date_typename = 'Date';
13
+    my $datetime_typename = 'Datetime';
14
+    
15
+    sub date_typename { lc $date_typename }
16
+    sub datetime_typename { lc $datetime_typename }
17
+
18
+    my $date_datatype = 'Date';
19
+    my $datetime_datatype = 'Datetime';
20
+    
21
+    sub date_datatype { lc $date_datatype }
22
+    sub datetime_datatype { lc $datetime_datatype }
23
+
24
+    has dsn => 'dbi:SQLite:dbname=:memory:';
25
+    sub quote { '""' }
26
+    sub create_table1 { 'create table table1 (key1 varchar, key2 varchar);' }
27
+    sub create_table1_2 {'create table table1 (key1 varchar, key2 varchar, key3 varchar, key4 varchar, key5 varchar);' }
28
+    sub create_table1_type { "create table table1 (key1 $date_typename, key2 $datetime_typename);" }
29
+    
30
+    sub create_table1_highperformance { "create table table1 (ab varchar, bc varchar, ik varchar, hi varchar, ui varchar, pq varchar, dc varchar);" }
31
+    
32
+    sub create_table2 { 'create table table2 (key1 varchar, key3 varchar);' }
33
+    sub create_table2_2 { "create table table2 (key1 varchar, key2 varchar, key3 varchar)" }
34
+    sub create_table3 { "create table table3 (key1 varchar, key2 varchar, key3 varchar)" }
35
+    sub create_table_reserved { 'create table "table" ("select" varchar, "update" varchar)' }
36
+}
37
+
38
+require "$FindBin::Bin/common.t";
+37 -7
t/common-sqlite.t
... ...
@@ -9,6 +9,36 @@ use DBIx::Custom;
9 9
     package DBIx::Custom;
10 10
     no warnings 'redefine';
11 11
     
12
+    my $table1 = 'table1';
13
+    my $table2 = 'table2';
14
+    my $table2_alias = 'table2_alias';
15
+    my $table3 = 'table3';
16
+    my $key1 = 'key1';
17
+    my $key2 = 'key2';
18
+    my $key3 = 'key3';
19
+    my $key4 = 'key4';
20
+    my $key5 = 'key5';
21
+    my $key6 = 'key6';
22
+    my $key7 = 'key7';
23
+    my $key8 = 'key8';
24
+    my $key9 = 'key9';
25
+    my $key10 = 'key10';
26
+    
27
+    has table1 => $table1;
28
+    has table2 => $table2;
29
+    has table2_alias => $table2_alias;
30
+    has table3 => $table3;
31
+    has key1 => $key1;
32
+    has key2 => $key2;
33
+    has key3 => $key3;
34
+    has key4 => $key4;
35
+    has key5 => $key5;
36
+    has key6 => $key6;
37
+    has key7 => $key7;
38
+    has key8 => $key8;
39
+    has key9 => $key9;
40
+    has key10 => $key10;
41
+    
12 42
     my $date_typename = 'Date';
13 43
     my $datetime_typename = 'Datetime';
14 44
     
... ...
@@ -22,15 +52,15 @@ use DBIx::Custom;
22 52
     sub datetime_datatype { lc $datetime_datatype }
23 53
 
24 54
     has dsn => 'dbi:SQLite:dbname=:memory:';
25
-    sub create_table1 { 'create table table1 (key1 varchar, key2 varchar);' }
26
-    sub create_table1_2 {'create table table1 (key1 varchar, key2 varchar, key3 varchar, key4 varchar, key5 varchar);' }
27
-    sub create_table1_type { "create table table1 (key1 $date_typename, key2 $datetime_typename);" }
55
+    sub create_table1 { "create table $table1 ($key1 varchar, $key2 varchar);" }
56
+    sub create_table1_2 {"create table $table1 ($key1 varchar, $key2 varchar, $key3 varchar, key4 varchar, key5 varchar);" }
57
+    sub create_table1_type { "create table $table1 ($key1 $date_typename, $key2 $datetime_typename);" }
28 58
     
29
-    sub create_table1_highperformance { "create table table1 (ab varchar, bc varchar, ik varchar, hi varchar, ui varchar, pq varchar, dc varchar);" }
59
+    sub create_table1_highperformance { "create table $table1 (ab varchar, bc varchar, ik varchar, hi varchar, ui varchar, pq varchar, dc varchar);" }
30 60
     
31
-    sub create_table2 { 'create table table2 (key1 varchar, key3 varchar);' }
32
-    sub create_table2_2 { "create table table2 (key1 varchar, key2 varchar, key3 varchar)" }
33
-    sub create_table3 { "create table table3 (key1 varchar, key2 varchar, key3 varchar)" }
61
+    sub create_table2 { "create table $table2 ($key1 varchar, $key3 varchar);" }
62
+    sub create_table2_2 { "create table $table2 ($key1 varchar, $key2 varchar, $key3 varchar)" }
63
+    sub create_table3 { "create table $table3 ($key1 varchar, $key2 varchar, $key3 varchar)" }
34 64
     sub create_table_reserved { 'create table "table" ("select" varchar, "update" varchar)' }
35 65
     
36 66
 }
+1439 -1427
t/common.t
... ...
@@ -144,6 +144,20 @@ $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
144 144
 sub test { print "# $_[0]\n" }
145 145
 
146 146
 # Constant
147
+my $table1 = $dbi->table1;
148
+my $table2 = $dbi->table2;
149
+my $table2_alias = $dbi->table2_alias;
150
+my $table3 = $dbi->table3;
151
+my $key1 = $dbi->key1;
152
+my $key2 = $dbi->key2;
153
+my $key3 = $dbi->key3;
154
+my $key4 = $dbi->key4;
155
+my $key5 = $dbi->key5;
156
+my $key6 = $dbi->key6;
157
+my $key7 = $dbi->key7;
158
+my $key8 = $dbi->key8;
159
+my $key9 = $dbi->key9;
160
+my $key10 = $dbi->key10;
147 161
 my $create_table1 = $dbi->create_table1;
148 162
 my $create_table1_2 = $dbi->create_table1_2;
149 163
 my $create_table1_type = $dbi->create_table1_type;
... ...
@@ -159,7 +173,6 @@ my $datetime_typename = $dbi->datetime_typename;
159 173
 my $date_datatype = $dbi->date_datatype;
160 174
 my $datetime_datatype = $dbi->datetime_datatype;
161 175
 
162
-# Variable
163 176
 # Variables
164 177
 my $builder;
165 178
 my $datas;
... ...
@@ -193,24 +206,23 @@ my $binary;
193 206
 
194 207
 
195 208
 # Drop table
196
-eval { $dbi->execute('drop table table1') };
209
+eval { $dbi->execute("drop table $table1") };
197 210
 
198 211
 test 'type_rule into';
199 212
 $dbi = DBIx::Custom->connect;
200
-eval { $dbi->execute('drop table table1') };
201
-$DB::single = 1;
213
+eval { $dbi->execute("drop table $table1") };
202 214
 $dbi->execute($create_table1_type);
203 215
 $dbi->type_rule(
204 216
     into1 => {
205 217
         $date_typename => sub { '2010-' . $_[0] }
206 218
     }
207 219
 );
208
-$dbi->insert({key1 => '01-01'}, table => 'table1');
209
-$result = $dbi->select(table => 'table1');
210
-like($result->one->{key1}, qr/^2010-01-01/);
220
+$dbi->insert({$key1 => '01-01'}, table => $table1);
221
+$result = $dbi->select(table => $table1);
222
+like($result->one->{$key1}, qr/^2010-01-01/);
211 223
 
212 224
 $dbi = DBIx::Custom->connect;
213
-eval { $dbi->execute('drop table table1') };
225
+eval { $dbi->execute('drop table $table1') };
214 226
 $dbi->execute($create_table1_type);
215 227
 $dbi->type_rule(
216 228
     into1 => [
... ...
@@ -221,16 +233,16 @@ $dbi->type_rule(
221 233
          }
222 234
     ]
223 235
 );
224
-$dbi->insert({key1 => '2010-01-02', key2 => '2010-01-01 01:01:02'}, table => 'table1');
225
-$result = $dbi->select(table => 'table1');
236
+$dbi->insert({$key1 => '2010-01-02', $key2 => '2010-01-01 01:01:02'}, table => $table1);
237
+$result = $dbi->select(table => $table1);
226 238
 $row = $result->one;
227
-like($row->{key1}, qr/^2010-01-03/);
228
-like($row->{key2}, qr/^2010-01-01 01:01:03/);
239
+like($row->{$key1}, qr/^2010-01-03/);
240
+like($row->{$key2}, qr/^2010-01-01 01:01:03/);
229 241
 
230 242
 $dbi = DBIx::Custom->connect;
231
-eval { $dbi->execute('drop table table1') };
243
+eval { $dbi->execute('drop table $table1') };
232 244
 $dbi->execute($create_table1_type);
233
-$dbi->insert({key1 => '2010-01-03', key2 => '2010-01-01 01:01:03'}, table => 'table1');
245
+$dbi->insert({$key1 => '2010-01-03', $key2 => '2010-01-01 01:01:03'}, table => $table1);
234 246
 $dbi->type_rule(
235 247
     into1 => [
236 248
         [$date_typename, $datetime_typename] => sub {
... ...
@@ -241,17 +253,17 @@ $dbi->type_rule(
241 253
     ]
242 254
 );
243 255
 $result = $dbi->execute(
244
-    "select * from table1 where key1 = :key1 and key2 = :table1.key2;",
245
-    param => {key1 => '2010-01-03', 'table1.key2' => '2010-01-01 01:01:02'}
256
+    "select * from $table1 where $key1 = :$key1 and $key2 = :$table1.$key2;",
257
+    param => {$key1 => '2010-01-03', "$table1.$key2" => '2010-01-01 01:01:02'}
246 258
 );
247 259
 $row = $result->one;
248
-like($row->{key1}, qr/^2010-01-03/);
249
-like($row->{key2}, qr/^2010-01-01 01:01:03/);
260
+like($row->{$key1}, qr/^2010-01-03/);
261
+like($row->{$key2}, qr/^2010-01-01 01:01:03/);
250 262
 
251 263
 $dbi = DBIx::Custom->connect;
252
-eval { $dbi->execute('drop table table1') };
264
+eval { $dbi->execute('drop table $table1') };
253 265
 $dbi->execute($create_table1_type);
254
-$dbi->insert({key1 => '2010-01-03', key2 => '2010-01-01 01:01:03'}, table => 'table1');
266
+$dbi->insert({$key1 => '2010-01-03', $key2 => '2010-01-01 01:01:03'}, table => $table1);
255 267
 $dbi->type_rule(
256 268
     into1 => [
257 269
         [$date_typename, $datetime_typename] => sub {
... ...
@@ -262,16 +274,16 @@ $dbi->type_rule(
262 274
     ]
263 275
 );
264 276
 $result = $dbi->execute(
265
-    "select * from table1 where key1 = :key1 and key2 = :table1.key2;",
266
-    param => {key1 => '2010-01-02', 'table1.key2' => '2010-01-01 01:01:02'},
267
-    table => 'table1'
277
+    "select * from $table1 where $key1 = :$key1 and $key2 = :$table1.$key2;",
278
+    param => {$key1 => '2010-01-02', "$table1.$key2" => '2010-01-01 01:01:02'},
279
+    table => $table1
268 280
 );
269 281
 $row = $result->one;
270
-like($row->{key1}, qr/^2010-01-03/);
271
-like($row->{key2}, qr/2010-01-01 01:01:03/);
282
+like($row->{$key1}, qr/^2010-01-03/);
283
+like($row->{$key2}, qr/2010-01-01 01:01:03/);
272 284
 
273 285
 $dbi = DBIx::Custom->connect;
274
-eval { $dbi->execute('drop table table1') };
286
+eval { $dbi->execute('drop table $table1') };
275 287
 $dbi->execute($create_table1_type);
276 288
 $dbi->register_filter(convert => sub {
277 289
     my $value = shift || '';
... ...
@@ -286,13 +298,13 @@ $dbi->type_rule(
286 298
         $date_typename => 'convert',
287 299
     }
288 300
 );
289
-$dbi->insert({key1 => '2010-02-02'}, table => 'table1');
290
-$result = $dbi->select(table => 'table1');
301
+$dbi->insert({$key1 => '2010-02-02'}, table => $table1);
302
+$result = $dbi->select(table => $table1);
291 303
 like($result->fetch->[0], qr/^2010-03-03/);
292 304
 
293 305
 test 'type_rule and filter order';
294 306
 $dbi = DBIx::Custom->connect;
295
-eval { $dbi->execute('drop table table1') };
307
+eval { $dbi->execute('drop table $table1') };
296 308
 $dbi->execute($create_table1_type);
297 309
 $dbi->type_rule(
298 310
     into1 => {
... ...
@@ -308,15 +320,15 @@ $dbi->type_rule(
308 320
         $date_datatype => sub { my $v = shift || ''; $v =~ s/7/8/; return $v }
309 321
     }
310 322
 );
311
-$dbi->insert({key1 => '2010-01-03'}, 
312
-  table => 'table1', filter => {key1 => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }});
313
-$result = $dbi->select(table => 'table1');
314
-$result->filter(key1 => sub { my $v = shift || ''; $v =~ s/8/9/; return $v });
323
+$dbi->insert({$key1 => '2010-01-03'}, 
324
+  table => $table1, filter => {$key1 => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }});
325
+$result = $dbi->select(table => $table1);
326
+$result->filter($key1 => sub { my $v = shift || ''; $v =~ s/8/9/; return $v });
315 327
 like($result->fetch_first->[0], qr/^2010-01-09/);
316 328
 
317 329
 
318 330
 $dbi = DBIx::Custom->connect;
319
-eval { $dbi->execute('drop table table1') };
331
+eval { $dbi->execute('drop table $table1') };
320 332
 $dbi->execute($create_table1_type);
321 333
 $dbi->type_rule(
322 334
     from1 => {
... ...
@@ -326,8 +338,8 @@ $dbi->type_rule(
326 338
         $date_datatype => sub { my $v = shift || ''; $v =~ s/4/5/; return $v }
327 339
     },
328 340
 );
329
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
330
-$result = $dbi->select(table => 'table1');
341
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
342
+$result = $dbi->select(table => $table1);
331 343
 $result->type_rule(
332 344
     from1 => {
333 345
         $date_datatype => sub { my $v = shift || ''; $v =~ s/3/6/; return $v }
... ...
@@ -336,12 +348,12 @@ $result->type_rule(
336 348
         $date_datatype => sub { my $v = shift || ''; $v =~ s/6/8/; return $v }
337 349
     }
338 350
 );
339
-$result->filter(key1 => sub { my $v = shift || ''; $v =~ s/8/9/; return $v });
351
+$result->filter($key1 => sub { my $v = shift || ''; $v =~ s/8/9/; return $v });
340 352
 like($result->fetch_first->[0], qr/^2010-01-09/);
341 353
 
342 354
 test 'type_rule_off';
343 355
 $dbi = DBIx::Custom->connect;
344
-eval { $dbi->execute('drop table table1') };
356
+eval { $dbi->execute('drop table $table1') };
345 357
 $dbi->execute($create_table1_type);
346 358
 $dbi->type_rule(
347 359
     from1 => {
... ...
@@ -351,12 +363,12 @@ $dbi->type_rule(
351 363
         $date_typename => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }
352 364
     }
353 365
 );
354
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1', type_rule_off => 1);
355
-$result = $dbi->select(table => 'table1', type_rule_off => 1);
366
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1, type_rule_off => 1);
367
+$result = $dbi->select(table => $table1, type_rule_off => 1);
356 368
 like($result->type_rule_off->fetch->[0], qr/^2010-01-03/);
357 369
 
358 370
 $dbi = DBIx::Custom->connect;
359
-eval { $dbi->execute('drop table table1') };
371
+eval { $dbi->execute('drop table $table1') };
360 372
 $dbi->execute($create_table1_type);
361 373
 $dbi->type_rule(
362 374
     from1 => {
... ...
@@ -366,12 +378,12 @@ $dbi->type_rule(
366 378
         $date_typename => sub { my $v = shift || ''; $v =~ s/3/5/; return $v }
367 379
     }
368 380
 );
369
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1', type_rule_off => 1);
370
-$result = $dbi->select(table => 'table1', type_rule_off => 1);
371
-like($result->one->{key1}, qr/^2010-01-04/);
381
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1, type_rule_off => 1);
382
+$result = $dbi->select(table => $table1, type_rule_off => 1);
383
+like($result->one->{$key1}, qr/^2010-01-04/);
372 384
 
373 385
 $dbi = DBIx::Custom->connect;
374
-eval { $dbi->execute('drop table table1') };
386
+eval { $dbi->execute('drop table $table1') };
375 387
 $dbi->execute($create_table1_type);
376 388
 $dbi->type_rule(
377 389
     from1 => {
... ...
@@ -381,12 +393,12 @@ $dbi->type_rule(
381 393
         $date_typename => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }
382 394
     }
383 395
 );
384
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
385
-$result = $dbi->select(table => 'table1');
386
-like($result->one->{key1}, qr/^2010-01-05/);
396
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
397
+$result = $dbi->select(table => $table1);
398
+like($result->one->{$key1}, qr/^2010-01-05/);
387 399
 
388 400
 $dbi = DBIx::Custom->connect;
389
-eval { $dbi->execute('drop table table1') };
401
+eval { $dbi->execute('drop table $table1') };
390 402
 $dbi->execute($create_table1_type);
391 403
 $dbi->type_rule(
392 404
     from1 => {
... ...
@@ -396,12 +408,12 @@ $dbi->type_rule(
396 408
         $date_typename => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }
397 409
     }
398 410
 );
399
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
400
-$result = $dbi->select(table => 'table1');
411
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
412
+$result = $dbi->select(table => $table1);
401 413
 like($result->fetch->[0], qr/2010-01-05/);
402 414
 
403 415
 $dbi = DBIx::Custom->connect;
404
-eval { $dbi->execute('drop table table1') };
416
+eval { $dbi->execute('drop table $table1') };
405 417
 $dbi->execute($create_table1_type);
406 418
 $dbi->register_filter(ppp => sub { my $v = shift || ''; $v =~ s/3/4/; return $v });
407 419
 $dbi->type_rule(
... ...
@@ -409,9 +421,9 @@ $dbi->type_rule(
409 421
         $date_typename => 'ppp'
410 422
     }
411 423
 );
412
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
413
-$result = $dbi->select(table => 'table1');
414
-like($result->one->{key1}, qr/^2010-01-04/);
424
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
425
+$result = $dbi->select(table => $table1);
426
+like($result->one->{$key1}, qr/^2010-01-04/);
415 427
 
416 428
 eval{$dbi->type_rule(
417 429
     into1 => {
... ...
@@ -421,7 +433,7 @@ eval{$dbi->type_rule(
421 433
 like($@, qr/not registered/);
422 434
 
423 435
 $dbi = DBIx::Custom->connect;
424
-eval { $dbi->execute('drop table table1') };
436
+eval { $dbi->execute('drop table $table1') };
425 437
 $dbi->execute($create_table1_type);
426 438
 eval {
427 439
     $dbi->type_rule(
... ...
@@ -442,7 +454,7 @@ eval {
442 454
 like($@, qr/lower/);
443 455
 
444 456
 $dbi = DBIx::Custom->connect;
445
-eval { $dbi->execute('drop table table1') };
457
+eval { $dbi->execute('drop table $table1') };
446 458
 $dbi->execute($create_table1_type);
447 459
 $dbi->type_rule(
448 460
     from1 => {
... ...
@@ -452,13 +464,13 @@ $dbi->type_rule(
452 464
         $date_typename => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }
453 465
     }
454 466
 );
455
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
456
-$result = $dbi->select(table => 'table1');
467
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
468
+$result = $dbi->select(table => $table1);
457 469
 $result->type_rule_off;
458
-like($result->one->{key1}, qr/^2010-01-04/);
470
+like($result->one->{$key1}, qr/^2010-01-04/);
459 471
 
460 472
 $dbi = DBIx::Custom->connect;
461
-eval { $dbi->execute('drop table table1') };
473
+eval { $dbi->execute('drop table $table1') };
462 474
 $dbi->execute($create_table1_type);
463 475
 $dbi->type_rule(
464 476
     from1 => {
... ...
@@ -466,90 +478,90 @@ $dbi->type_rule(
466 478
         $datetime_datatype => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }
467 479
     },
468 480
 );
469
-$dbi->insert({key1 => '2010-01-03', key2 => '2010-01-01 01:01:03'}, table => 'table1');
470
-$result = $dbi->select(table => 'table1');
481
+$dbi->insert({$key1 => '2010-01-03', $key2 => '2010-01-01 01:01:03'}, table => $table1);
482
+$result = $dbi->select(table => $table1);
471 483
 $result->type_rule(
472 484
     from1 => {
473 485
         $date_datatype => sub { my $v = shift || ''; $v =~ s/3/5/; return $v }
474 486
     }
475 487
 );
476 488
 $row = $result->one;
477
-like($row->{key1}, qr/^2010-01-05/);
478
-like($row->{key2}, qr/^2010-01-01 01:01:03/);
489
+like($row->{$key1}, qr/^2010-01-05/);
490
+like($row->{$key2}, qr/^2010-01-01 01:01:03/);
479 491
 
480
-$result = $dbi->select(table => 'table1');
492
+$result = $dbi->select(table => $table1);
481 493
 $result->type_rule(
482 494
     from1 => {
483 495
         $date_datatype => sub { my $v = shift || ''; $v =~ s/3/5/; return $v }
484 496
     }
485 497
 );
486 498
 $row = $result->one;
487
-like($row->{key1}, qr/2010-01-05/);
488
-like($row->{key2}, qr/2010-01-01 01:01:03/);
499
+like($row->{$key1}, qr/2010-01-05/);
500
+like($row->{$key2}, qr/2010-01-01 01:01:03/);
489 501
 
490
-$result = $dbi->select(table => 'table1');
502
+$result = $dbi->select(table => $table1);
491 503
 $result->type_rule(
492 504
     from1 => {
493 505
         $date_datatype => sub { my $v = shift || ''; $v =~ s/3/5/; return $v }
494 506
     }
495 507
 );
496 508
 $row = $result->one;
497
-like($row->{key1}, qr/2010-01-05/);
498
-like($row->{key2}, qr/2010-01-01 01:01:03/);
509
+like($row->{$key1}, qr/2010-01-05/);
510
+like($row->{$key2}, qr/2010-01-01 01:01:03/);
499 511
 
500
-$result = $dbi->select(table => 'table1');
512
+$result = $dbi->select(table => $table1);
501 513
 $result->type_rule(
502 514
     from1 => [$date_datatype => sub { my $v = shift || ''; $v =~ s/3/5/; return $v }]
503 515
 );
504 516
 $row = $result->one;
505
-like($row->{key1}, qr/2010-01-05/);
506
-like($row->{key2}, qr/2010-01-01 01:01:03/);
517
+like($row->{$key1}, qr/2010-01-05/);
518
+like($row->{$key2}, qr/2010-01-01 01:01:03/);
507 519
 
508 520
 $dbi->register_filter(five => sub { my $v = shift || ''; $v =~ s/3/5/; return $v });
509
-$result = $dbi->select(table => 'table1');
521
+$result = $dbi->select(table => $table1);
510 522
 $result->type_rule(
511 523
     from1 => [$date_datatype => 'five']
512 524
 );
513 525
 $row = $result->one;
514
-like($row->{key1}, qr/^2010-01-05/);
515
-like($row->{key2}, qr/^2010-01-01 01:01:03/);
526
+like($row->{$key1}, qr/^2010-01-05/);
527
+like($row->{$key2}, qr/^2010-01-01 01:01:03/);
516 528
 
517
-$result = $dbi->select(table => 'table1');
529
+$result = $dbi->select(table => $table1);
518 530
 $result->type_rule(
519 531
     from1 => [$date_datatype => undef]
520 532
 );
521 533
 $row = $result->one;
522
-like($row->{key1}, qr/^2010-01-03/);
523
-like($row->{key2}, qr/^2010-01-01 01:01:03/);
534
+like($row->{$key1}, qr/^2010-01-03/);
535
+like($row->{$key2}, qr/^2010-01-01 01:01:03/);
524 536
 
525 537
 $dbi = DBIx::Custom->connect;
526
-eval { $dbi->execute('drop table table1') };
538
+eval { $dbi->execute('drop table $table1') };
527 539
 $dbi->execute($create_table1_type);
528 540
 $dbi->type_rule(
529 541
     from1 => {
530 542
         $date_datatype => sub { my $v = shift || ''; $v =~ s/3/4/; return $v },
531 543
     },
532 544
 );
533
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
534
-$result = $dbi->select(table => 'table1');
535
-$result->filter(key1 => sub { my $v = shift || ''; $v =~ s/4/5/; return $v });
536
-like($result->one->{key1}, qr/^2010-01-05/);
545
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
546
+$result = $dbi->select(table => $table1);
547
+$result->filter($key1 => sub { my $v = shift || ''; $v =~ s/4/5/; return $v });
548
+like($result->one->{$key1}, qr/^2010-01-05/);
537 549
 
538 550
 $dbi = DBIx::Custom->connect;
539
-eval { $dbi->execute('drop table table1') };
551
+eval { $dbi->execute('drop table $table1') };
540 552
 $dbi->execute($create_table1_type);
541 553
 $dbi->type_rule(
542 554
     from1 => {
543 555
         $date_datatype => sub { my $v = shift || ''; $v =~ s/3/4/; return $v }
544 556
     },
545 557
 );
546
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1');
547
-$result = $dbi->select(table => 'table1');
548
-$result->filter(key1 => sub { my $v = shift || ''; $v =~ s/4/5/; return $v });
558
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1);
559
+$result = $dbi->select(table => $table1);
560
+$result->filter($key1 => sub { my $v = shift || ''; $v =~ s/4/5/; return $v });
549 561
 like($result->fetch->[0], qr/^2010-01-05/);
550 562
 
551 563
 $dbi = DBIx::Custom->connect;
552
-eval { $dbi->execute('drop table table1') };
564
+eval { $dbi->execute('drop table $table1') };
553 565
 $dbi->execute($create_table1_type);
554 566
 $dbi->type_rule(
555 567
     into1 => {
... ...
@@ -565,14 +577,14 @@ $dbi->type_rule(
565 577
         $date_datatype => sub { my $v = shift || ''; $v =~ s/(3|6)/7/; return $v }
566 578
     }
567 579
 );
568
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1', type_rule_off => 1);
569
-$result = $dbi->select(table => 'table1');
580
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1, type_rule_off => 1);
581
+$result = $dbi->select(table => $table1);
570 582
 like($result->type_rule_off->fetch_first->[0], qr/^2010-01-03/);
571
-$result = $dbi->select(table => 'table1');
583
+$result = $dbi->select(table => $table1);
572 584
 like($result->type_rule_on->fetch_first->[0], qr/^2010-01-07/);
573 585
 
574 586
 $dbi = DBIx::Custom->connect;
575
-eval { $dbi->execute('drop table table1') };
587
+eval { $dbi->execute('drop table $table1') };
576 588
 $dbi->execute($create_table1_type);
577 589
 $dbi->type_rule(
578 590
     into1 => {
... ...
@@ -588,14 +600,14 @@ $dbi->type_rule(
588 600
         $date_datatype => sub { my $v = shift || ''; $v =~ s/6/7/; return $v }
589 601
     }
590 602
 );
591
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1', type_rule1_off => 1);
592
-$result = $dbi->select(table => 'table1');
603
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1, type_rule1_off => 1);
604
+$result = $dbi->select(table => $table1);
593 605
 like($result->type_rule1_off->fetch_first->[0], qr/^2010-01-05/);
594
-$result = $dbi->select(table => 'table1');
606
+$result = $dbi->select(table => $table1);
595 607
 like($result->type_rule1_on->fetch_first->[0], qr/^2010-01-07/);
596 608
 
597 609
 $dbi = DBIx::Custom->connect;
598
-eval { $dbi->execute('drop table table1') };
610
+eval { $dbi->execute('drop table $table1') };
599 611
 $dbi->execute($create_table1_type);
600 612
 $dbi->type_rule(
601 613
     into1 => {
... ...
@@ -611,27 +623,27 @@ $dbi->type_rule(
611 623
         $date_datatype => sub { my $v = shift || ''; $v =~ s/(3|6)/7/; return $v }
612 624
     }
613 625
 );
614
-$dbi->insert({key1 => '2010-01-03'}, table => 'table1', type_rule2_off => 1);
615
-$result = $dbi->select(table => 'table1');
626
+$dbi->insert({$key1 => '2010-01-03'}, table => $table1, type_rule2_off => 1);
627
+$result = $dbi->select(table => $table1);
616 628
 like($result->type_rule2_off->fetch_first->[0], qr/^2010-01-06/);
617
-$result = $dbi->select(table => 'table1');
629
+$result = $dbi->select(table => $table1);
618 630
 like($result->type_rule2_on->fetch_first->[0], qr/^2010-01-07/);
619 631
 
620 632
 
621 633
 
622 634
 # Create table
623 635
 $dbi = DBIx::Custom->connect;
624
-eval { $dbi->execute('drop table table1') };
636
+eval { $dbi->execute('drop table $table1') };
625 637
 $dbi->execute($create_table1);
626
-$model = $dbi->create_model(table => 'table1');
627
-$model->insert({key1 => 1, key2 => 2});
628
-is_deeply($model->select->all, [{key1 => 1, key2 => 2}]);
638
+$model = $dbi->create_model(table => $table1);
639
+$model->insert({$key1 => 1, $key2 => 2});
640
+is_deeply($model->select->all, [{$key1 => 1, $key2 => 2}]);
629 641
 
630 642
 test 'DBIx::Custom::Result test';
631
-$dbi->delete_all(table => 'table1');
632
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
633
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
634
-$source = "select key1, key2 from table1";
643
+$dbi->delete_all(table => $table1);
644
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
645
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
646
+$source = "select $key1, $key2 from $table1";
635 647
 $query = $dbi->create_query($source);
636 648
 $result = $dbi->execute($query);
637 649
 
... ...
@@ -646,7 +658,7 @@ $result = $dbi->execute($query);
646 658
 while (my $row = $result->fetch_hash) {
647 659
     push @rows, {%$row};
648 660
 }
649
-is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "fetch_hash");
661
+is_deeply(\@rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "fetch_hash");
650 662
 
651 663
 $result = $dbi->execute($query);
652 664
 $rows = $result->fetch_all;
... ...
@@ -654,158 +666,158 @@ is_deeply($rows, [[1, 2], [3, 4]], "fetch_all");
654 666
 
655 667
 $result = $dbi->execute($query);
656 668
 $rows = $result->fetch_hash_all;
657
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "all");
669
+is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "all");
658 670
 
659 671
 test 'Insert query return value';
660
-$source = "insert into table1 {insert_param key1 key2}";
672
+$source = "insert into $table1 {insert_param $key1 $key2}";
661 673
 $query = $dbi->execute($source, {}, query => 1);
662
-$ret_val = $dbi->execute($query, param => {key1 => 1, key2 => 2});
674
+$ret_val = $dbi->execute($query, param => {$key1 => 1, $key2 => 2});
663 675
 ok($ret_val);
664 676
 
665 677
 test 'Direct query';
666
-$dbi->delete_all(table => 'table1');
667
-$insert_source = "insert into table1 {insert_param key1 key2}";
668
-$dbi->execute($insert_source, param => {key1 => 1, key2 => 2});
669
-$result = $dbi->execute('select * from table1;');
678
+$dbi->delete_all(table => $table1);
679
+$insert_source = "insert into $table1 {insert_param $key1 $key2}";
680
+$dbi->execute($insert_source, param => {$key1 => 1, $key2 => 2});
681
+$result = $dbi->execute("select * from $table1;");
670 682
 $rows = $result->all;
671
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
683
+is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
672 684
 
673 685
 test 'Filter basic';
674
-$dbi->delete_all(table => 'table1');
686
+$dbi->delete_all(table => $table1);
675 687
 $dbi->register_filter(twice       => sub { $_[0] * 2}, 
676 688
                     three_times => sub { $_[0] * 3});
677 689
 
678
-$insert_source  = "insert into table1 {insert_param key1 key2};";
690
+$insert_source  = "insert into $table1 {insert_param $key1 $key2};";
679 691
 $insert_query = $dbi->execute($insert_source, {}, query => 1);
680
-$insert_query->filter({key1 => 'twice'});
681
-$dbi->execute($insert_query, param => {key1 => 1, key2 => 2});
682
-$result = $dbi->execute('select * from table1;');
683
-$rows = $result->filter({key2 => 'three_times'})->all;
684
-is_deeply($rows, [{key1 => 2, key2 => 6}], "filter fetch_filter");
692
+$insert_query->filter({$key1 => 'twice'});
693
+$dbi->execute($insert_query, param => {$key1 => 1, $key2 => 2});
694
+$result = $dbi->execute("select * from $table1;");
695
+$rows = $result->filter({$key2 => 'three_times'})->all;
696
+is_deeply($rows, [{$key1 => 2, $key2 => 6}], "filter fetch_filter");
685 697
 
686 698
 test 'Filter in';
687
-$dbi->delete_all(table => 'table1');
688
-$insert_source  = "insert into table1 {insert_param key1 key2};";
699
+$dbi->delete_all(table => $table1);
700
+$insert_source  = "insert into $table1 {insert_param $key1 $key2};";
689 701
 $insert_query = $dbi->execute($insert_source, {}, query => 1);
690
-$dbi->execute($insert_query, param => {key1 => 2, key2 => 4});
691
-$select_source = "select * from table1 where {in table1.key1 2} and {in table1.key2 2}";
702
+$dbi->execute($insert_query, param => {$key1 => 2, $key2 => 4});
703
+$select_source = "select * from $table1 where {in $table1.$key1 2} and {in $table1.$key2 2}";
692 704
 $select_query = $dbi->execute($select_source,{}, query => 1);
693
-$select_query->filter({'table1.key1' => 'twice'});
694
-$result = $dbi->execute($select_query, param => {'table1.key1' => [1,5], 'table1.key2' => [2,4]});
705
+$select_query->filter({'$table1.$key1' => 'twice'});
706
+$result = $dbi->execute($select_query, param => {"$table1.$key1" => [1,5], "$table1.$key2" => [2,4]});
695 707
 $rows = $result->all;
696
-is_deeply($rows, [{key1 => 2, key2 => 4}], "filter");
708
+is_deeply($rows, [{$key1 => 2, $key2 => 4}], "filter");
697 709
 
698 710
 test 'DBIx::Custom::SQLTemplate basic tag';
699
-$dbi->execute('drop table table1');
711
+$dbi->execute('drop table $table1');
700 712
 $dbi->execute($create_table1_2);
701
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
702
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
713
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
714
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
703 715
 
704
-$source = "select * from table1 where key1 = :key1 and {<> key2} and {< key3} and {> key4} and {>= key5};";
716
+$source = "select * from $table1 where $key1 = :$key1 and {<> $key2} and {< $key3} and {> $key4} and {>= $key5};";
705 717
 $query = $dbi->execute($source, {}, query => 1);
706
-$result = $dbi->execute($query, param => {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5});
718
+$result = $dbi->execute($query, param => {$key1 => 1, $key2 => 3, $key3 => 4, $key4 => 3, $key5 => 5});
707 719
 $rows = $result->all;
708
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1");
720
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}], "basic tag1");
709 721
 
710
-$source = "select * from table1 where key1 = :key1 and {<> key2} and {< key3} and {> key4} and {>= key5};";
722
+$source = "select * from $table1 where $key1 = :$key1 and {<> $key2} and {< $key3} and {> $key4} and {>= $key5};";
711 723
 $query = $dbi->execute($source, {}, query => 1);
712
-$result = $dbi->execute($query, {key1 => 1, key2 => 3, key3 => 4, key4 => 3, key5 => 5});
724
+$result = $dbi->execute($query, {$key1 => 1, $key2 => 3, $key3 => 4, $key4 => 3, $key5 => 5});
713 725
 $rows = $result->all;
714
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag1");
726
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}], "basic tag1");
715 727
 
716
-$source = "select * from table1 where {<= key1} and {like key2};";
728
+$source = "select * from $table1 where {<= $key1} and {like $key2};";
717 729
 $query = $dbi->execute($source, {}, query => 1);
718
-$result = $dbi->execute($query, param => {key1 => 1, key2 => '%2%'});
730
+$result = $dbi->execute($query, param => {$key1 => 1, $key2 => '%2%'});
719 731
 $rows = $result->all;
720
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic tag2");
732
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}], "basic tag2");
721 733
 
722 734
 test 'DIB::Custom::SQLTemplate in tag';
723
-$dbi->execute('drop table table1');
735
+$dbi->execute('drop table $table1');
724 736
 $dbi->execute($create_table1_2);
725
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
726
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
737
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
738
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
727 739
 
728
-$source = "select * from table1 where {in key1 2};";
740
+$source = "select * from $table1 where {in $key1 2};";
729 741
 $query = $dbi->execute($source, {}, query => 1);
730
-$result = $dbi->execute($query, param => {key1 => [9, 1]});
742
+$result = $dbi->execute($query, param => {$key1 => [9, 1]});
731 743
 $rows = $result->all;
732
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic");
744
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}], "basic");
733 745
 
734 746
 test 'DBIx::Custom::SQLTemplate insert tag';
735
-$dbi->delete_all(table => 'table1');
736
-$insert_source = 'insert into table1 {insert_param key1 key2 key3 key4 key5}';
737
-$dbi->execute($insert_source, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
747
+$dbi->delete_all(table => $table1);
748
+$insert_source = "insert into $table1 {insert_param $key1 $key2 $key3 $key4 $key5}";
749
+$dbi->execute($insert_source, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
738 750
 
739
-$result = $dbi->execute('select * from table1;');
751
+$result = $dbi->execute("select * from $table1;");
740 752
 $rows = $result->all;
741
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}], "basic");
753
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}], "basic");
742 754
 
743 755
 test 'DBIx::Custom::SQLTemplate update tag';
744
-$dbi->delete_all(table => 'table1');
745
-$insert_source = "insert into table1 {insert_param key1 key2 key3 key4 key5}";
746
-$dbi->execute($insert_source, param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
747
-$dbi->execute($insert_source, param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
756
+$dbi->delete_all(table => $table1);
757
+$insert_source = "insert into $table1 {insert_param $key1 $key2 $key3 $key4 $key5}";
758
+$dbi->execute($insert_source, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
759
+$dbi->execute($insert_source, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
748 760
 
749
-$update_source = 'update table1 {update_param key1 key2 key3 key4} where {= key5}';
750
-$dbi->execute($update_source, param => {key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5});
761
+$update_source = "update $table1 {update_param $key1 $key2 $key3 $key4} where {= $key5}";
762
+$dbi->execute($update_source, param => {$key1 => 1, $key2 => 1, $key3 => 1, $key4 => 1, $key5 => 5});
751 763
 
752
-$result = $dbi->execute('select * from table1 order by key1;');
764
+$result = $dbi->execute("select * from $table1 order by $key1;");
753 765
 $rows = $result->all;
754
-is_deeply($rows, [{key1 => 1, key2 => 1, key3 => 1, key4 => 1, key5 => 5},
755
-                  {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10}], "basic");
766
+is_deeply($rows, [{$key1 => 1, $key2 => 1, $key3 => 1, $key4 => 1, $key5 => 5},
767
+                  {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10}], "basic");
756 768
 
757 769
 test 'Named placeholder';
758
-$dbi->execute('drop table table1');
770
+$dbi->execute('drop table $table1');
759 771
 $dbi->execute($create_table1_2);
760
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
761
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
772
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
773
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
762 774
 
763
-$source = "select * from table1 where key1 = :key1 and key2 = :key2";
764
-$result = $dbi->execute($source, param => {key1 => 1, key2 => 2});
775
+$source = "select * from $table1 where $key1 = :$key1 and $key2 = :$key2";
776
+$result = $dbi->execute($source, param => {$key1 => 1, $key2 => 2});
765 777
 $rows = $result->all;
766
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
778
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
767 779
 
768
-$source = "select * from table1 where key1 = \n:key1\n and key2 = :key2";
769
-$result = $dbi->execute($source, param => {key1 => 1, key2 => 2});
780
+$source = "select * from $table1 where $key1 = \n:$key1\n and $key2 = :$key2";
781
+$result = $dbi->execute($source, param => {$key1 => 1, $key2 => 2});
770 782
 $rows = $result->all;
771
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
783
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
772 784
 
773
-$source = "select * from table1 where key1 = :key1 or key1 = :key1";
774
-$result = $dbi->execute($source, param => {key1 => [1, 2]});
785
+$source = "select * from $table1 where $key1 = :$key1 or $key1 = :$key1";
786
+$result = $dbi->execute($source, param => {$key1 => [1, 2]});
775 787
 $rows = $result->all;
776
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
788
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
777 789
 
778
-$source = "select * from table1 where key1 = :table1.key1 and key2 = :table1.key2";
790
+$source = "select * from $table1 where $key1 = :$table1.$key1 and $key2 = :$table1.$key2";
779 791
 $result = $dbi->execute(
780 792
     $source,
781
-    param => {'table1.key1' => 1, 'table1.key2' => 1},
782
-    filter => {'table1.key2' => sub { $_[0] * 2 }}
793
+    param => {"$table1.$key1" => 1, "$table1.$key2" => 1},
794
+    filter => {'$table1.$key2' => sub { $_[0] * 2 }}
783 795
 );
784 796
 $rows = $result->all;
785
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
797
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
786 798
 
787
-$dbi->execute('drop table table1');
799
+$dbi->execute('drop table $table1');
788 800
 $dbi->execute($create_table1);
789
-$dbi->insert(table => 'table1', param => {key1 => '2011-10-14 12:19:18', key2 => 2});
790
-$source = "select * from table1 where key1 = '2011-10-14 12:19:18' and key2 = :key2";
801
+$dbi->insert(table => $table1, param => {$key1 => '2011-10-14 12:19:18', $key2 => 2});
802
+$source = "select * from $table1 where $key1 = '2011-10-14 12:19:18' and $key2 = :$key2";
791 803
 $result = $dbi->execute(
792 804
     $source,
793
-    param => {'key2' => 2},
805
+    param => {$key2 => 2},
794 806
 );
795 807
 
796 808
 $rows = $result->all;
797
-like($rows->[0]->{key1}, qr/2011-10-14 12:19:18/);
798
-is($rows->[0]->{key2}, 2);
809
+like($rows->[0]->{$key1}, qr/2011-10-14 12:19:18/);
810
+is($rows->[0]->{$key2}, 2);
799 811
 
800
-$dbi->delete_all(table => 'table1');
801
-$dbi->insert(table => 'table1', param => {key1 => 'a:b c:d', key2 => 2});
802
-$source = "select * from table1 where key1 = 'a\\:b c\\:d' and key2 = :key2";
812
+$dbi->delete_all(table => $table1);
813
+$dbi->insert(table => $table1, param => {$key1 => 'a:b c:d', $key2 => 2});
814
+$source = "select * from $table1 where $key1 = 'a\\:b c\\:d' and $key2 = :$key2";
803 815
 $result = $dbi->execute(
804 816
     $source,
805
-    param => {'key2' => 2},
817
+    param => {$key2 => 2},
806 818
 );
807 819
 $rows = $result->all;
808
-is_deeply($rows, [{key1 => 'a:b c:d', key2 => 2}]);
820
+is_deeply($rows, [{$key1 => 'a:b c:d', $key2 => 2}]);
809 821
 
810 822
 test 'Error case';
811 823
 eval {DBIx::Custom->connect(dsn => 'dbi:SQLit')};
... ...
@@ -815,33 +827,33 @@ eval{$dbi->execute("{p }", {}, query => 1)};
815 827
 ok($@, "create_query invalid SQL template");
816 828
 
817 829
 test 'insert';
818
-eval { $dbi->execute('drop table table1') };
830
+eval { $dbi->execute('drop table $table1') };
819 831
 $dbi->execute($create_table1);
820
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
821
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
822
-$result = $dbi->execute('select * from table1;');
832
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
833
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
834
+$result = $dbi->execute("select * from $table1;");
823 835
 $rows   = $result->all;
824
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
836
+is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "basic");
825 837
 
826
-$dbi->execute('delete from table1');
838
+$dbi->execute('delete from $table1');
827 839
 $dbi->register_filter(
828 840
     twice       => sub { $_[0] * 2 },
829 841
     three_times => sub { $_[0] * 3 }
830 842
 );
831 843
 $dbi->default_bind_filter('twice');
832
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => 'three_times'});
833
-$result = $dbi->execute('select * from table1;');
844
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}, filter => {$key1 => 'three_times'});
845
+$result = $dbi->execute("select * from $table1;");
834 846
 $rows   = $result->all;
835
-is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
847
+is_deeply($rows, [{$key1 => 3, $key2 => 4}], "filter");
836 848
 $dbi->default_bind_filter(undef);
837 849
 
838
-$dbi->execute('drop table table1');
850
+$dbi->execute('drop table $table1');
839 851
 $dbi->execute($create_table1);
840
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, append => '   ');
841
-$rows = $dbi->select(table => 'table1')->all;
842
-is_deeply($rows, [{key1 => 1, key2 => 2}], 'insert append');
852
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}, append => '   ');
853
+$rows = $dbi->select(table => $table1)->all;
854
+is_deeply($rows, [{$key1 => 1, $key2 => 2}], 'insert append');
843 855
 
844
-eval{$dbi->insert(table => 'table1', noexist => 1)};
856
+eval{$dbi->insert(table => $table1, noexist => 1)};
845 857
 like($@, qr/noexist/, "invalid");
846 858
 
847 859
 eval{$dbi->insert(table => 'table', param => {';' => 1})};
... ...
@@ -855,112 +867,112 @@ $result = $dbi->execute("select * from ${q}table$p");
855 867
 $rows   = $result->all;
856 868
 is_deeply($rows, [{select => 2, update => undef}], "reserved word");
857 869
 
858
-eval { $dbi->execute('drop table table1') };
870
+eval { $dbi->execute('drop table $table1') };
859 871
 $dbi->execute($create_table1);
860
-$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
861
-$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
862
-$result = $dbi->execute('select * from table1;');
872
+$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
873
+$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1);
874
+$result = $dbi->execute("select * from $table1;");
863 875
 $rows   = $result->all;
864
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
876
+is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "basic");
865 877
 
866
-eval { $dbi->execute('drop table table1') };
878
+eval { $dbi->execute('drop table $table1') };
867 879
 $dbi->execute($create_table1);
868
-$dbi->insert(table => 'table1', param => {key1 => \"'1'", key2 => 2});
869
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
870
-$result = $dbi->execute('select * from table1;');
880
+$dbi->insert(table => $table1, param => {$key1 => \"'1'", $key2 => 2});
881
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
882
+$result = $dbi->execute("select * from $table1;");
871 883
 $rows   = $result->all;
872
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "basic");
884
+is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "basic");
873 885
 
874 886
 test 'update';
875
-eval { $dbi->execute('drop table table1') };
887
+eval { $dbi->execute('drop table $table1') };
876 888
 $dbi->execute($create_table1_2);
877
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
878
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
879
-$dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1});
880
-$result = $dbi->execute('select * from table1 order by key1;');
889
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
890
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
891
+$dbi->update(table => $table1, param => {$key2 => 11}, where => {$key1 => 1});
892
+$result = $dbi->execute("select * from $table1 order by $key1;");
881 893
 $rows   = $result->all;
882
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
883
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
894
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
895
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
884 896
                   "basic");
885 897
                   
886
-$dbi->execute("delete from table1");
887
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
888
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
889
-$dbi->update(table => 'table1', param => {key2 => 12}, where => {key2 => 2, key3 => 3});
890
-$result = $dbi->execute('select * from table1 order by key1;');
898
+$dbi->execute("delete from $table1");
899
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
900
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
901
+$dbi->update(table => $table1, param => {$key2 => 12}, where => {$key2 => 2, $key3 => 3});
902
+$result = $dbi->execute("select * from $table1 order by $key1;");
891 903
 $rows   = $result->all;
892
-is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
893
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
904
+is_deeply($rows, [{$key1 => 1, $key2 => 12, $key3 => 3, $key4 => 4, $key5 => 5},
905
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
894 906
                   "update key same as search key");
895 907
 
896
-$dbi->update(table => 'table1', param => {key2 => [12]}, where => {key2 => 2, key3 => 3});
897
-$result = $dbi->execute('select * from table1 order by key1;');
908
+$dbi->update(table => $table1, param => {$key2 => [12]}, where => {$key2 => 2, $key3 => 3});
909
+$result = $dbi->execute("select * from $table1 order by $key1;");
898 910
 $rows   = $result->all;
899
-is_deeply($rows, [{key1 => 1, key2 => 12, key3 => 3, key4 => 4, key5 => 5},
900
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
911
+is_deeply($rows, [{$key1 => 1, $key2 => 12, $key3 => 3, $key4 => 4, $key5 => 5},
912
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
901 913
                   "update key same as search key : param is array ref");
902 914
 
903
-$dbi->execute("delete from table1");
904
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
905
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
915
+$dbi->execute("delete from $table1");
916
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
917
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
906 918
 $dbi->register_filter(twice => sub { $_[0] * 2 });
907
-$dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1},
908
-              filter => {key2 => sub { $_[0] * 2 }});
909
-$result = $dbi->execute('select * from table1 order by key1;');
919
+$dbi->update(table => $table1, param => {$key2 => 11}, where => {$key1 => 1},
920
+              filter => {$key2 => sub { $_[0] * 2 }});
921
+$result = $dbi->execute("select * from $table1 order by $key1;");
910 922
 $rows   = $result->all;
911
-is_deeply($rows, [{key1 => 1, key2 => 22, key3 => 3, key4 => 4, key5 => 5},
912
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
923
+is_deeply($rows, [{$key1 => 1, $key2 => 22, $key3 => 3, $key4 => 4, $key5 => 5},
924
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
913 925
                   "filter");
914 926
 
915
-$result = $dbi->update(table => 'table1', param => {key2 => 11}, where => {key1 => 1}, append => '   ');
927
+$result = $dbi->update(table => $table1, param => {$key2 => 11}, where => {$key1 => 1}, append => '   ');
916 928
 
917
-eval{$dbi->update(table => 'table1', where => {key1 => 1}, noexist => 1)};
929
+eval{$dbi->update(table => $table1, where => {$key1 => 1}, noexist => 1)};
918 930
 like($@, qr/noexist/, "invalid");
919 931
 
920
-eval{$dbi->update(table => 'table1')};
932
+eval{$dbi->update(table => $table1)};
921 933
 like($@, qr/where/, "not contain where");
922 934
 
923
-eval { $dbi->execute('drop table table1') };
935
+eval { $dbi->execute('drop table $table1') };
924 936
 $dbi->execute($create_table1);
925
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
937
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
926 938
 $where = $dbi->where;
927
-$where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
928
-$where->param({key1 => 1, key2 => 2});
929
-$dbi->update(table => 'table1', param => {key1 => 3}, where => $where);
930
-$result = $dbi->select(table => 'table1');
931
-is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
939
+$where->clause(['and', "$key1 = :$key1", "$key2 = :$key2"]);
940
+$where->param({$key1 => 1, $key2 => 2});
941
+$dbi->update(table => $table1, param => {$key1 => 3}, where => $where);
942
+$result = $dbi->select(table => $table1);
943
+is_deeply($result->all, [{$key1 => 3, $key2 => 2}], 'update() where');
932 944
 
933
-eval { $dbi->execute('drop table table1') };
945
+eval { $dbi->execute('drop table $table1') };
934 946
 $dbi->execute($create_table1);
935
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
947
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
936 948
 $dbi->update(
937
-    table => 'table1',
938
-    param => {key1 => 3},
949
+    table => $table1,
950
+    param => {$key1 => 3},
939 951
     where => [
940
-        ['and', 'key1 = :key1', 'key2 = :key2'],
941
-        {key1 => 1, key2 => 2}
952
+        ['and', "$key1 = :$key1", "$key2 = :$key2"],
953
+        {$key1 => 1, $key2 => 2}
942 954
     ]
943 955
 );
944
-$result = $dbi->select(table => 'table1');
945
-is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
956
+$result = $dbi->select(table => $table1);
957
+is_deeply($result->all, [{$key1 => 3, $key2 => 2}], 'update() where');
946 958
 
947
-eval { $dbi->execute('drop table table1') };
959
+eval { $dbi->execute('drop table $table1') };
948 960
 $dbi->execute($create_table1);
949
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
961
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
950 962
 $where = $dbi->where;
951
-$where->clause(['and', 'key2 = :key2']);
952
-$where->param({key2 => 2});
953
-$dbi->update(table => 'table1', param => {key1 => 3}, where => $where);
954
-$result = $dbi->select(table => 'table1');
955
-is_deeply($result->all, [{key1 => 3, key2 => 2}], 'update() where');
963
+$where->clause(['and', "$key2 = :$key2"]);
964
+$where->param({$key2 => 2});
965
+$dbi->update(table => $table1, param => {$key1 => 3}, where => $where);
966
+$result = $dbi->select(table => $table1);
967
+is_deeply($result->all, [{$key1 => 3, $key2 => 2}], 'update() where');
956 968
 
957
-eval{$dbi->update(table => 'table1', param => {';' => 1})};
969
+eval{$dbi->update(table => $table1, param => {';' => 1})};
958 970
 like($@, qr/safety/);
959 971
 
960
-eval{$dbi->update(table => 'table1', param => {'key1' => 1}, where => {';' => 1})};
972
+eval{$dbi->update(table => $table1, param => {$key1 => 1}, where => {';' => 1})};
961 973
 like($@, qr/safety/);
962 974
 
963
-eval { $dbi->execute('drop table table1') };
975
+eval { $dbi->execute('drop table $table1') };
964 976
 eval { $dbi->execute("drop table ${q}table$p") };
965 977
 $dbi->execute($create_table_reserved);
966 978
 $dbi->apply_filter('table', select => {out => sub { $_[0] * 2}});
... ...
@@ -984,114 +996,114 @@ $result = $dbi->execute("select * from ${q}table$p");
984 996
 $rows   = $result->all;
985 997
 is_deeply($rows, [{select => 2, update => 6}], "reserved word");
986 998
 
987
-eval { $dbi->execute('drop table table1') };
999
+eval { $dbi->execute('drop table $table1') };
988 1000
 $dbi->execute($create_table1_2);
989
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
990
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
991
-$dbi->update({key2 => 11}, table => 'table1', where => {key1 => 1});
992
-$result = $dbi->execute('select * from table1 order by key1;');
1001
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
1002
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
1003
+$dbi->update({$key2 => 11}, table => $table1, where => {$key1 => 1});
1004
+$result = $dbi->execute("select * from $table1 order by $key1;");
993 1005
 $rows   = $result->all;
994
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
995
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
1006
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
1007
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
996 1008
                   "basic");
997 1009
 
998
-eval { $dbi->execute('drop table table1') };
1010
+eval { $dbi->execute('drop table $table1') };
999 1011
 $dbi->execute($create_table1_2);
1000
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1001
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1002
-$dbi->update(table => 'table1', param => {key2 => \"'11'"}, where => {key1 => 1});
1003
-$result = $dbi->execute('select * from table1 order by key1;');
1012
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
1013
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
1014
+$dbi->update(table => $table1, param => {$key2 => \"'11'"}, where => {$key1 => 1});
1015
+$result = $dbi->execute("select * from $table1 order by $key1;");
1004 1016
 $rows   = $result->all;
1005
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
1006
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
1017
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
1018
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
1007 1019
                   "basic");
1008 1020
 
1009 1021
 test 'update_all';
1010
-eval { $dbi->execute('drop table table1') };
1022
+eval { $dbi->execute('drop table $table1') };
1011 1023
 $dbi->execute($create_table1_2);
1012
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
1013
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
1024
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
1025
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
1014 1026
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1015
-$dbi->update_all(table => 'table1', param => {key2 => 10}, filter => {key2 => 'twice'});
1016
-$result = $dbi->execute('select * from table1;');
1027
+$dbi->update_all(table => $table1, param => {$key2 => 10}, filter => {$key2 => 'twice'});
1028
+$result = $dbi->execute("select * from $table1;");
1017 1029
 $rows   = $result->all;
1018
-is_deeply($rows, [{key1 => 1, key2 => 20, key3 => 3, key4 => 4, key5 => 5},
1019
-                  {key1 => 6, key2 => 20, key3 => 8, key4 => 9, key5 => 10}],
1030
+is_deeply($rows, [{$key1 => 1, $key2 => 20, $key3 => 3, $key4 => 4, $key5 => 5},
1031
+                  {$key1 => 6, $key2 => 20, $key3 => 8, $key4 => 9, $key5 => 10}],
1020 1032
                   "filter");
1021 1033
 
1022 1034
 
1023 1035
 test 'delete';
1024
-eval { $dbi->execute('drop table table1') };
1036
+eval { $dbi->execute('drop table $table1') };
1025 1037
 $dbi->execute($create_table1);
1026
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1027
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1028
-$dbi->delete(table => 'table1', where => {key1 => 1});
1029
-$result = $dbi->execute('select * from table1;');
1038
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1039
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1040
+$dbi->delete(table => $table1, where => {$key1 => 1});
1041
+$result = $dbi->execute("select * from $table1;");
1030 1042
 $rows   = $result->all;
1031
-is_deeply($rows, [{key1 => 3, key2 => 4}], "basic");
1043
+is_deeply($rows, [{$key1 => 3, $key2 => 4}], "basic");
1032 1044
 
1033
-$dbi->execute("delete from table1;");
1034
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1035
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1045
+$dbi->execute("delete from $table1;");
1046
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1047
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1036 1048
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1037
-$dbi->delete(table => 'table1', where => {key2 => 1}, filter => {key2 => 'twice'});
1038
-$result = $dbi->execute('select * from table1;');
1049
+$dbi->delete(table => $table1, where => {$key2 => 1}, filter => {$key2 => 'twice'});
1050
+$result = $dbi->execute("select * from $table1;");
1039 1051
 $rows   = $result->all;
1040
-is_deeply($rows, [{key1 => 3, key2 => 4}], "filter");
1052
+is_deeply($rows, [{$key1 => 3, $key2 => 4}], "filter");
1041 1053
 
1042
-$dbi->delete(table => 'table1', where => {key1 => 1}, append => '   ');
1054
+$dbi->delete(table => $table1, where => {$key1 => 1}, append => '   ');
1043 1055
 
1044
-$dbi->delete_all(table => 'table1');
1045
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1046
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1047
-$dbi->delete(table => 'table1', where => {key1 => 1, key2 => 2});
1048
-$rows = $dbi->select(table => 'table1')->all;
1049
-is_deeply($rows, [{key1 => 3, key2 => 4}], "delete multi key");
1056
+$dbi->delete_all(table => $table1);
1057
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1058
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1059
+$dbi->delete(table => $table1, where => {$key1 => 1, $key2 => 2});
1060
+$rows = $dbi->select(table => $table1)->all;
1061
+is_deeply($rows, [{$key1 => 3, $key2 => 4}], "delete multi key");
1050 1062
 
1051
-eval{$dbi->delete(table => 'table1', where => {key1 => 1}, noexist => 1)};
1063
+eval{$dbi->delete(table => $table1, where => {$key1 => 1}, noexist => 1)};
1052 1064
 like($@, qr/noexist/, "invalid");
1053 1065
 
1054
-eval { $dbi->execute('drop table table1') };
1066
+eval { $dbi->execute('drop table $table1') };
1055 1067
 $dbi->execute($create_table1);
1056
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1057
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1068
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1069
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1058 1070
 $where = $dbi->where;
1059
-$where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
1060
-$where->param({ke1 => 1, key2 => 2});
1061
-$dbi->delete(table => 'table1', where => $where);
1062
-$result = $dbi->select(table => 'table1');
1063
-is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
1071
+$where->clause(['and', "$key1 = :$key1", "$key2 = :$key2"]);
1072
+$where->param({ke1 => 1, $key2 => 2});
1073
+$dbi->delete(table => $table1, where => $where);
1074
+$result = $dbi->select(table => $table1);
1075
+is_deeply($result->all, [{$key1 => 3, $key2 => 4}], 'delete() where');
1064 1076
 
1065
-eval { $dbi->execute('drop table table1') };
1077
+eval { $dbi->execute('drop table $table1') };
1066 1078
 $dbi->execute($create_table1);
1067
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1068
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1079
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1080
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1069 1081
 $dbi->delete(
1070
-    table => 'table1',
1082
+    table => $table1,
1071 1083
     where => [
1072
-        ['and', 'key1 = :key1', 'key2 = :key2'],
1073
-        {ke1 => 1, key2 => 2}
1084
+        ['and', "$key1 = :$key1", "$key2 = :$key2"],
1085
+        {ke1 => 1, $key2 => 2}
1074 1086
     ]
1075 1087
 );
1076
-$result = $dbi->select(table => 'table1');
1077
-is_deeply($result->all, [{key1 => 3, key2 => 4}], 'delete() where');
1088
+$result = $dbi->select(table => $table1);
1089
+is_deeply($result->all, [{$key1 => 3, $key2 => 4}], 'delete() where');
1078 1090
 
1079
-eval { $dbi->execute('drop table table1') };
1091
+eval { $dbi->execute('drop table $table1') };
1080 1092
 $dbi->execute($create_table1);
1081
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1082
-$dbi->delete(table => 'table1', where => {key1 => 1}, prefix => '    ');
1083
-$result = $dbi->execute('select * from table1;');
1093
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1094
+$dbi->delete(table => $table1, where => {$key1 => 1}, prefix => '    ');
1095
+$result = $dbi->execute("select * from $table1;");
1084 1096
 $rows   = $result->all;
1085 1097
 is_deeply($rows, [], "basic");
1086 1098
 
1087 1099
 test 'delete error';
1088
-eval { $dbi->execute('drop table table1') };
1100
+eval { $dbi->execute('drop table $table1') };
1089 1101
 $dbi->execute($create_table1);
1090
-eval{$dbi->delete(table => 'table1')};
1102
+eval{$dbi->delete(table => $table1)};
1091 1103
 like($@, qr/"where" must be specified/,
1092 1104
          "where key-value pairs not specified");
1093 1105
 
1094
-eval{$dbi->delete(table => 'table1', where => {';' => 1})};
1106
+eval{$dbi->delete(table => $table1, where => {';' => 1})};
1095 1107
 like($@, qr/safety/);
1096 1108
 
1097 1109
 $dbi = undef;
... ...
@@ -1106,58 +1118,58 @@ $rows   = $result->all;
1106 1118
 is_deeply($rows, [], "reserved word");
1107 1119
 
1108 1120
 test 'delete_all';
1109
-eval { $dbi->execute('drop table table1') };
1121
+eval { $dbi->execute('drop table $table1') };
1110 1122
 $dbi->execute($create_table1);
1111
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1112
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1113
-$dbi->delete_all(table => 'table1');
1114
-$result = $dbi->execute('select * from table1;');
1123
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1124
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1125
+$dbi->delete_all(table => $table1);
1126
+$result = $dbi->execute("select * from $table1;");
1115 1127
 $rows   = $result->all;
1116 1128
 is_deeply($rows, [], "basic");
1117 1129
 
1118 1130
 
1119 1131
 test 'select';
1120
-eval { $dbi->execute('drop table table1') };
1132
+eval { $dbi->execute('drop table $table1') };
1121 1133
 $dbi->execute($create_table1);
1122
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1123
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1124
-$rows = $dbi->select(table => 'table1')->all;
1125
-is_deeply($rows, [{key1 => 1, key2 => 2},
1126
-                  {key1 => 3, key2 => 4}], "table");
1134
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1135
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1136
+$rows = $dbi->select(table => $table1)->all;
1137
+is_deeply($rows, [{$key1 => 1, $key2 => 2},
1138
+                  {$key1 => 3, $key2 => 4}], "table");
1127 1139
 
1128
-$rows = $dbi->select(table => 'table1', column => ['key1'])->all;
1129
-is_deeply($rows, [{key1 => 1}, {key1 => 3}], "table and columns and where key");
1140
+$rows = $dbi->select(table => $table1, column => [$key1])->all;
1141
+is_deeply($rows, [{$key1 => 1}, {$key1 => 3}], "table and columns and where key");
1130 1142
 
1131
-$rows = $dbi->select(table => 'table1', where => {key1 => 1})->all;
1132
-is_deeply($rows, [{key1 => 1, key2 => 2}], "table and columns and where key");
1143
+$rows = $dbi->select(table => $table1, where => {$key1 => 1})->all;
1144
+is_deeply($rows, [{$key1 => 1, $key2 => 2}], "table and columns and where key");
1133 1145
 
1134
-$rows = $dbi->select(table => 'table1', column => ['key1'], where => {key1 => 3})->all;
1135
-is_deeply($rows, [{key1 => 3}], "table and columns and where key");
1146
+$rows = $dbi->select(table => $table1, column => [$key1], where => {$key1 => 3})->all;
1147
+is_deeply($rows, [{$key1 => 3}], "table and columns and where key");
1136 1148
 
1137 1149
 $dbi->register_filter(decrement => sub { $_[0] - 1 });
1138
-$rows = $dbi->select(table => 'table1', where => {key1 => 2}, filter => {key1 => 'decrement'})
1150
+$rows = $dbi->select(table => $table1, where => {$key1 => 2}, filter => {$key1 => 'decrement'})
1139 1151
             ->all;
1140
-is_deeply($rows, [{key1 => 1, key2 => 2}], "filter");
1152
+is_deeply($rows, [{$key1 => 1, $key2 => 2}], "filter");
1141 1153
 
1142
-eval { $dbi->execute("drop table table2") };
1154
+eval { $dbi->execute("drop table $table2") };
1143 1155
 $dbi->execute($create_table2);
1144
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
1156
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
1145 1157
 $rows = $dbi->select(
1146
-    table => [qw/table1 table2/],
1147
-    column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3',
1148
-    where   => {'table1.key2' => 2},
1149
-    relation  => {'table1.key1' => 'table2.key1'}
1158
+    table => [$table1, $table2],
1159
+    column => "$table1.$key1 as ${table1}_$key1, $table2.$key1 as ${table2}_$key1, $key2, $key3",
1160
+    where   => {"$table1.$key2" => 2},
1161
+    relation  => {"$table1.$key1" => "$table2.$key1"}
1150 1162
 )->all;
1151
-is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : exists where");
1163
+is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}], "relation : exists where");
1152 1164
 
1153 1165
 $rows = $dbi->select(
1154
-    table => [qw/table1 table2/],
1155
-    column => ['table1.key1 as table1_key1', 'table2.key1 as table2_key1', 'key2', 'key3'],
1156
-    relation  => {'table1.key1' => 'table2.key1'}
1166
+    table => [$table1, $table2],
1167
+    column => ["$table1.$key1 as ${table1}_$key1', '${table2}.$key1 as ${table2}_$key1", $key2, $key3],
1168
+    relation  => {"$table1.$key1" => "$table2.$key1"}
1157 1169
 )->all;
1158
-is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}], "relation : no exists where");
1170
+is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}], "relation : no exists where");
1159 1171
 
1160
-eval{$dbi->select(table => 'table1', noexist => 1)};
1172
+eval{$dbi->select(table => $table1, noexist => 1)};
1161 1173
 like($@, qr/noexist/, "invalid");
1162 1174
 
1163 1175
 $dbi = DBIx::Custom->connect;
... ...
@@ -1170,18 +1182,18 @@ $rows   = $result->all;
1170 1182
 is_deeply($rows, [{select => 2, update => 2}], "reserved word");
1171 1183
 
1172 1184
 test 'fetch filter';
1173
-eval { $dbi->execute('drop table table1') };
1185
+eval { $dbi->execute('drop table $table1') };
1174 1186
 $dbi->register_filter(
1175 1187
     twice       => sub { $_[0] * 2 },
1176 1188
     three_times => sub { $_[0] * 3 }
1177 1189
 );
1178 1190
 $dbi->default_fetch_filter('twice');
1179 1191
 $dbi->execute($create_table1);
1180
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1181
-$result = $dbi->select(table => 'table1');
1182
-$result->filter({key1 => 'three_times'});
1192
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1193
+$result = $dbi->select(table => $table1);
1194
+$result->filter({$key1 => 'three_times'});
1183 1195
 $row = $result->one;
1184
-is_deeply($row, {key1 => 3, key2 => 4}, "default_fetch_filter and filter");
1196
+is_deeply($row, {$key1 => 3, $key2 => 4}, "default_fetch_filter and filter");
1185 1197
 
1186 1198
 test 'filters';
1187 1199
 $dbi = DBIx::Custom->new;
... ...
@@ -1194,97 +1206,97 @@ is($dbi->filters->{encode_utf8}->('あ'),
1194 1206
 
1195 1207
 test 'transaction1';
1196 1208
 $dbi = DBIx::Custom->connect;
1197
-eval { $dbi->execute('drop table table1') };
1209
+eval { $dbi->execute('drop table $table1') };
1198 1210
 $dbi->execute($create_table1);
1199 1211
 $dbi->begin_work;
1200 1212
 $dbi->dbh->{AutoCommit} = 0;
1201
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1213
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1202 1214
 $dbi->rollback;
1203 1215
 $dbi->dbh->{AutoCommit} = 1;
1204 1216
 
1205
-$result = $dbi->select(table => 'table1');
1217
+$result = $dbi->select(table => $table1);
1206 1218
 ok(! $result->fetch_first, "rollback");
1207 1219
 
1208 1220
 
1209 1221
 $dbi = DBIx::Custom->connect;
1210
-eval { $dbi->execute('drop table table1') };
1222
+eval { $dbi->execute('drop table $table1') };
1211 1223
 $dbi->execute($create_table1);
1212 1224
 $dbi->begin_work;
1213 1225
 $dbi->dbh->{AutoCommit} = 0;
1214
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1215
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
1226
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1227
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
1216 1228
 $dbi->commit;
1217 1229
 $dbi->dbh->{AutoCommit} = 1;
1218
-$result = $dbi->select(table => 'table1');
1219
-is_deeply(scalar $result->all, [{key1 => 1, key2 => 2}, {key1 => 2, key2 => 3}],
1230
+$result = $dbi->select(table => $table1);
1231
+is_deeply(scalar $result->all, [{$key1 => 1, $key2 => 2}, {$key1 => 2, $key2 => 3}],
1220 1232
           "commit");
1221 1233
 
1222 1234
 test 'execute';
1223
-eval { $dbi->execute('drop table table1') };
1235
+eval { $dbi->execute('drop table $table1') };
1224 1236
 $dbi->execute($create_table1);
1225 1237
 {
1226 1238
     local $Carp::Verbose = 0;
1227
-    eval{$dbi->execute('select * frm table1')};
1228
-    like($@, qr/\Qselect * frm table1;/, "fail prepare");
1239
+    eval{$dbi->execute('select * frm $table1')};
1240
+    like($@, qr/\Qselect * frm $table1;/, "fail prepare");
1229 1241
     like($@, qr/\.t /, "fail : not verbose");
1230 1242
 }
1231 1243
 {
1232 1244
     local $Carp::Verbose = 1;
1233
-    eval{$dbi->execute('select * frm table1')};
1245
+    eval{$dbi->execute('select * frm $table1')};
1234 1246
     like($@, qr/Custom.*\.t /s, "fail : verbose");
1235 1247
 }
1236 1248
 
1237
-eval{$dbi->execute('select * from table1', no_exists => 1)};
1249
+eval{$dbi->execute('select * from $table1', no_exists => 1)};
1238 1250
 like($@, qr/wrong/, "invald SQL");
1239 1251
 
1240
-$query = $dbi->execute('select * from table1 where key1 = :key1', {}, query => 1);
1252
+$query = $dbi->execute("select * from $table1 where $key1 = :$key1", {}, query => 1);
1241 1253
 $dbi->dbh->disconnect;
1242
-eval{$dbi->execute($query, param => {key1 => {a => 1}})};
1254
+eval{$dbi->execute($query, param => {$key1 => {a => 1}})};
1243 1255
 ok($@, "execute fail");
1244 1256
 
1245 1257
 {
1246 1258
     local $Carp::Verbose = 0;
1247
-    eval{$dbi->execute('select * from table1 where {0 key1}', {}, query => 1)};
1259
+    eval{$dbi->execute("select * from $table1 where {0 $key1}", {}, query => 1)};
1248 1260
     like($@, qr/\Q.t /, "caller spec : not vebose");
1249 1261
 }
1250 1262
 {
1251 1263
     local $Carp::Verbose = 1;
1252
-    eval{$dbi->execute('select * from table1 where {0 key1}', {}, query => 1)};
1264
+    eval{$dbi->execute("select * from $table1 where {0 $key1}", {}, query => 1)};
1253 1265
     like($@, qr/QueryBuilder.*\.t /s, "caller spec : not vebose");
1254 1266
 }
1255 1267
 
1256 1268
 
1257 1269
 test 'transaction2';
1258 1270
 $dbi = DBIx::Custom->connect;
1259
-eval { $dbi->execute('drop table table1') };
1271
+eval { $dbi->execute('drop table $table1') };
1260 1272
 $dbi->execute($create_table1);
1261 1273
 
1262 1274
 $dbi->begin_work;
1263 1275
 
1264 1276
 eval {
1265
-    $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1277
+    $dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1266 1278
     die "Error";
1267
-    $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1279
+    $dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1268 1280
 };
1269 1281
 
1270 1282
 $dbi->rollback if $@;
1271 1283
 
1272
-$result = $dbi->select(table => 'table1');
1284
+$result = $dbi->select(table => $table1);
1273 1285
 $rows = $result->all;
1274 1286
 is_deeply($rows, [], "rollback");
1275 1287
 
1276 1288
 $dbi->begin_work;
1277 1289
 
1278 1290
 eval {
1279
-    $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1280
-    $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1291
+    $dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1292
+    $dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1281 1293
 };
1282 1294
 
1283 1295
 $dbi->commit unless $@;
1284 1296
 
1285
-$result = $dbi->select(table => 'table1');
1297
+$result = $dbi->select(table => $table1);
1286 1298
 $rows = $result->all;
1287
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], "commit");
1299
+is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], "commit");
1288 1300
 
1289 1301
 $dbi->dbh->{AutoCommit} = 0;
1290 1302
 eval{ $dbi->begin_work };
... ...
@@ -1292,52 +1304,52 @@ ok($@, "exception");
1292 1304
 $dbi->dbh->{AutoCommit} = 1;
1293 1305
 
1294 1306
 test 'cache';
1295
-eval { $dbi->execute('drop table table1') };
1307
+eval { $dbi->execute('drop table $table1') };
1296 1308
 $dbi->cache(1);
1297 1309
 $dbi->execute($create_table1);
1298
-$source = 'select * from table1 where key1 = :key1 and key2 = :key2;';
1310
+$source = "select * from $table1 where $key1 = :$key1 and $key2 = :$key2;";
1299 1311
 $dbi->execute($source, {}, query => 1);
1300 1312
 is_deeply($dbi->{_cached}->{$source}, 
1301
-          {sql => "select * from table1 where key1 = ? and key2 = ?;", columns => ['key1', 'key2'], tables => []}, "cache");
1313
+          {sql => "select * from $table1 where $key1 = ? and $key2 = ?;", columns => [$key1, $key2], tables => []}, "cache");
1302 1314
 
1303
-eval { $dbi->execute('drop table table1') };
1315
+eval { $dbi->execute('drop table $table1') };
1304 1316
 $dbi->execute($create_table1);
1305 1317
 $dbi->{_cached} = {};
1306 1318
 $dbi->cache(0);
1307
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1319
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1308 1320
 is(scalar keys %{$dbi->{_cached}}, 0, 'not cache');
1309 1321
 
1310 1322
 test 'execute';
1311
-eval { $dbi->execute('drop table table1') };
1323
+eval { $dbi->execute('drop table $table1') };
1312 1324
 $dbi->execute($create_table1);
1313 1325
 {
1314 1326
     local $Carp::Verbose = 0;
1315
-    eval{$dbi->execute('select * frm table1')};
1316
-    like($@, qr/\Qselect * frm table1;/, "fail prepare");
1327
+    eval{$dbi->execute('select * frm $table1')};
1328
+    like($@, qr/\Qselect * frm $table1;/, "fail prepare");
1317 1329
     like($@, qr/\.t /, "fail : not verbose");
1318 1330
 }
1319 1331
 {
1320 1332
     local $Carp::Verbose = 1;
1321
-    eval{$dbi->execute('select * frm table1')};
1333
+    eval{$dbi->execute('select * frm $table1')};
1322 1334
     like($@, qr/Custom.*\.t /s, "fail : verbose");
1323 1335
 }
1324 1336
 
1325
-eval{$dbi->execute('select * from table1', no_exists => 1)};
1337
+eval{$dbi->execute('select * from $table1', no_exists => 1)};
1326 1338
 like($@, qr/wrong/, "invald SQL");
1327 1339
 
1328
-$query = $dbi->execute('select * from table1 where key1 = :key1', {}, query => 1);
1340
+$query = $dbi->execute("select * from $table1 where $key1 = :$key1", {}, query => 1);
1329 1341
 $dbi->dbh->disconnect;
1330
-eval{$dbi->execute($query, param => {key1 => {a => 1}})};
1342
+eval{$dbi->execute($query, param => {$key1 => {a => 1}})};
1331 1343
 ok($@, "execute fail");
1332 1344
 
1333 1345
 {
1334 1346
     local $Carp::Verbose = 0;
1335
-    eval{$dbi->execute('select * from table1 where {0 key1}', {}, query => 1)};
1347
+    eval{$dbi->execute("select * from $table1 where {0 $key1}", {}, query => 1)};
1336 1348
     like($@, qr/\Q.t /, "caller spec : not vebose");
1337 1349
 }
1338 1350
 {
1339 1351
     local $Carp::Verbose = 1;
1340
-    eval{$dbi->execute('select * from table1 where {0 key1}', {}, query => 1)};
1352
+    eval{$dbi->execute("select * from $table1 where {0 $key1}", {}, query => 1)};
1341 1353
     like($@, qr/QueryBuilder.*\.t /s, "caller spec : not vebose");
1342 1354
 }
1343 1355
 
... ...
@@ -1364,142 +1376,142 @@ ok($@, "not exists");
1364 1376
 
1365 1377
 test 'out filter';
1366 1378
 $dbi = DBIx::Custom->connect;
1367
-eval { $dbi->execute('drop table table1') };
1379
+eval { $dbi->execute('drop table $table1') };
1368 1380
 $dbi->execute($create_table1);
1369 1381
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1370 1382
 $dbi->register_filter(three_times => sub { $_[0] * 3});
1371 1383
 $dbi->apply_filter(
1372
-    'table1', 'key1' => {out => 'twice', in => 'three_times'}, 
1373
-              'key2' => {out => 'three_times', in => 'twice'});
1374
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1375
-$result = $dbi->execute('select * from table1;');
1384
+    $table1, $key1 => {out => 'twice', in => 'three_times'}, 
1385
+              $key2 => {out => 'three_times', in => 'twice'});
1386
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1387
+$result = $dbi->execute("select * from $table1;");
1376 1388
 $row   = $result->fetch_hash_first;
1377
-is_deeply($row, {key1 => 2, key2 => 6}, "insert");
1378
-$result = $dbi->select(table => 'table1');
1389
+is_deeply($row, {$key1 => 2, $key2 => 6}, "insert");
1390
+$result = $dbi->select(table => $table1);
1379 1391
 $row   = $result->one;
1380
-is_deeply($row, {key1 => 6, key2 => 12}, "insert");
1392
+is_deeply($row, {$key1 => 6, $key2 => 12}, "insert");
1381 1393
 
1382 1394
 $dbi = DBIx::Custom->connect;
1383
-eval { $dbi->execute('drop table table1') };
1395
+eval { $dbi->execute('drop table $table1') };
1384 1396
 $dbi->execute($create_table1);
1385 1397
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1386 1398
 $dbi->register_filter(three_times => sub { $_[0] * 3});
1387 1399
 $dbi->apply_filter(
1388
-    'table1', 'key1' => {out => 'twice', in => 'three_times'}, 
1389
-              'key2' => {out => 'three_times', in => 'twice'});
1400
+    $table1, $key1 => {out => 'twice', in => 'three_times'}, 
1401
+              $key2 => {out => 'three_times', in => 'twice'});
1390 1402
 $dbi->apply_filter(
1391
-    'table1', 'key1' => {out => undef}
1403
+    $table1, $key1 => {out => undef}
1392 1404
 ); 
1393
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1394
-$result = $dbi->execute('select * from table1;');
1405
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1406
+$result = $dbi->execute("select * from $table1;");
1395 1407
 $row   = $result->one;
1396
-is_deeply($row, {key1 => 1, key2 => 6}, "insert");
1408
+is_deeply($row, {$key1 => 1, $key2 => 6}, "insert");
1397 1409
 
1398 1410
 $dbi = DBIx::Custom->connect;
1399
-eval { $dbi->execute('drop table table1') };
1411
+eval { $dbi->execute('drop table $table1') };
1400 1412
 $dbi->execute($create_table1);
1401 1413
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1402 1414
 $dbi->apply_filter(
1403
-    'table1', 'key1' => {out => 'twice', in => 'twice'}
1415
+    $table1, $key1 => {out => 'twice', in => 'twice'}
1404 1416
 );
1405
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, filter => {key1 => undef});
1406
-$dbi->update(table => 'table1', param => {key1 => 2}, where => {key2 => 2});
1407
-$result = $dbi->execute('select * from table1;');
1417
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}, filter => {$key1 => undef});
1418
+$dbi->update(table => $table1, param => {$key1 => 2}, where => {$key2 => 2});
1419
+$result = $dbi->execute("select * from $table1;");
1408 1420
 $row   = $result->one;
1409
-is_deeply($row, {key1 => 4, key2 => 2}, "update");
1421
+is_deeply($row, {$key1 => 4, $key2 => 2}, "update");
1410 1422
 
1411 1423
 $dbi = DBIx::Custom->connect;
1412
-eval { $dbi->execute('drop table table1') };
1424
+eval { $dbi->execute('drop table $table1') };
1413 1425
 $dbi->execute($create_table1);
1414 1426
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1415 1427
 $dbi->apply_filter(
1416
-    'table1', 'key1' => {out => 'twice', in => 'twice'}
1428
+    $table1, $key1 => {out => 'twice', in => 'twice'}
1417 1429
 );
1418
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1=> undef});
1419
-$dbi->delete(table => 'table1', where => {key1 => 1});
1420
-$result = $dbi->execute('select * from table1;');
1430
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 2}, filter => {$key1=> undef});
1431
+$dbi->delete(table => $table1, where => {$key1 => 1});
1432
+$result = $dbi->execute("select * from $table1;");
1421 1433
 $rows   = $result->all;
1422 1434
 is_deeply($rows, [], "delete");
1423 1435
 
1424 1436
 $dbi = DBIx::Custom->connect;
1425
-eval { $dbi->execute('drop table table1') };
1437
+eval { $dbi->execute('drop table $table1') };
1426 1438
 $dbi->execute($create_table1);
1427 1439
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1428 1440
 $dbi->apply_filter(
1429
-    'table1', 'key1' => {out => 'twice', in => 'twice'}
1441
+    $table1, $key1 => {out => 'twice', in => 'twice'}
1430 1442
 );
1431
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef});
1432
-$result = $dbi->select(table => 'table1', where => {key1 => 1});
1433
-$result->filter({'key2' => 'twice'});
1443
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 2}, filter => {$key1 => undef});
1444
+$result = $dbi->select(table => $table1, where => {$key1 => 1});
1445
+$result->filter({$key2 => 'twice'});
1434 1446
 $rows   = $result->all;
1435
-is_deeply($rows, [{key1 => 4, key2 => 4}], "select");
1447
+is_deeply($rows, [{$key1 => 4, $key2 => 4}], "select");
1436 1448
 
1437 1449
 $dbi = DBIx::Custom->connect;
1438
-eval { $dbi->execute('drop table table1') };
1450
+eval { $dbi->execute('drop table $table1') };
1439 1451
 $dbi->execute($create_table1);
1440 1452
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1441 1453
 $dbi->apply_filter(
1442
-    'table1', 'key1' => {out => 'twice', in => 'twice'}
1454
+    $table1, $key1 => {out => 'twice', in => 'twice'}
1443 1455
 );
1444
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef});
1445
-$result = $dbi->execute("select * from table1 where key1 = :key1 and key2 = :key2;",
1446
-                        param => {key1 => 1, key2 => 2},
1447
-                        table => ['table1']);
1456
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 2}, filter => {$key1 => undef});
1457
+$result = $dbi->execute("select * from $table1 where $key1 = :$key1 and $key2 = :$key2;",
1458
+                        param => {$key1 => 1, $key2 => 2},
1459
+                        table => [$table1]);
1448 1460
 $rows   = $result->all;
1449
-is_deeply($rows, [{key1 => 4, key2 => 2}], "execute");
1461
+is_deeply($rows, [{$key1 => 4, $key2 => 2}], "execute");
1450 1462
 
1451 1463
 $dbi = DBIx::Custom->connect;
1452
-eval { $dbi->execute('drop table table1') };
1464
+eval { $dbi->execute('drop table $table1') };
1453 1465
 $dbi->execute($create_table1);
1454 1466
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1455 1467
 $dbi->apply_filter(
1456
-    'table1', 'key1' => {out => 'twice', in => 'twice'}
1468
+    $table1, $key1 => {out => 'twice', in => 'twice'}
1457 1469
 );
1458
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 2}, filter => {key1 => undef});
1459
-$result = $dbi->execute("select * from {table table1} where key1 = :key1 and key2 = :key2;",
1460
-                        param => {key1 => 1, key2 => 2});
1470
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 2}, filter => {$key1 => undef});
1471
+$result = $dbi->execute("select * from {table $table1} where $key1 = :$key1 and $key2 = :$key2;",
1472
+                        param => {$key1 => 1, $key2 => 2});
1461 1473
 $rows   = $result->all;
1462
-is_deeply($rows, [{key1 => 4, key2 => 2}], "execute table tag");
1474
+is_deeply($rows, [{$key1 => 4, $key2 => 2}], "execute table tag");
1463 1475
 
1464 1476
 $dbi = DBIx::Custom->connect;
1465
-eval { $dbi->execute('drop table table1') };
1466
-eval { $dbi->execute('drop table table2') };
1477
+eval { $dbi->execute('drop table $table1') };
1478
+eval { $dbi->execute('drop table $table2') };
1467 1479
 $dbi->execute($create_table1);
1468 1480
 $dbi->execute($create_table2);
1469 1481
 $dbi->register_filter(twice => sub { $_[0] * 2 });
1470 1482
 $dbi->register_filter(three_times => sub { $_[0] * 3 });
1471 1483
 $dbi->apply_filter(
1472
-    'table1', 'key2' => {out => 'twice', in => 'twice'}
1484
+    $table1, $key2 => {out => 'twice', in => 'twice'}
1473 1485
 );
1474 1486
 $dbi->apply_filter(
1475
-    'table2', 'key3' => {out => 'three_times', in => 'three_times'}
1487
+    $table2, $key3 => {out => 'three_times', in => 'three_times'}
1476 1488
 );
1477
-$dbi->insert(table => 'table1', param => {key1 => 5, key2 => 2}, filter => {key2 => undef});
1478
-$dbi->insert(table => 'table2', param => {key1 => 5, key3 => 6}, filter => {key3 => undef});
1489
+$dbi->insert(table => $table1, param => {$key1 => 5, $key2 => 2}, filter => {$key2 => undef});
1490
+$dbi->insert(table => $table2, param => {$key1 => 5, $key3 => 6}, filter => {$key3 => undef});
1479 1491
 $result = $dbi->select(
1480
-     table => ['table1', 'table2'],
1481
-     column => ['key2', 'key3'],
1482
-     where => {'table1.key2' => 1, 'table2.key3' => 2}, relation => {'table1.key1' => 'table2.key1'});
1492
+     table => [$table1, $table2],
1493
+     column => [$key2, $key3],
1494
+     where => {"$table1.$key2" => 1, "$table2.$key3" => 2}, relation => {"$table1.$key1" => "$table2.$key1"});
1483 1495
 
1484
-$result->filter({'key2' => 'twice'});
1496
+$result->filter({$key2 => 'twice'});
1485 1497
 $rows   = $result->all;
1486
-is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join");
1498
+is_deeply($rows, [{$key2 => 4, $key3 => 18}], "select : join");
1487 1499
 
1488 1500
 $result = $dbi->select(
1489
-     table => ['table1', 'table2'],
1490
-     column => ['key2', 'key3'],
1491
-     where => {'key2' => 1, 'key3' => 2}, relation => {'table1.key1' => 'table2.key1'});
1501
+     table => [$table1, $table2],
1502
+     column => [$key2, $key3],
1503
+     where => {$key2 => 1, $key3 => 2}, relation => {"$table1.$key1" => "$table2.$key1"});
1492 1504
 
1493
-$result->filter({'key2' => 'twice'});
1505
+$result->filter({$key2 => 'twice'});
1494 1506
 $rows   = $result->all;
1495
-is_deeply($rows, [{key2 => 4, key3 => 18}], "select : join : omit");
1507
+is_deeply($rows, [{$key2 => 4, $key3 => 18}], "select : join : omit");
1496 1508
 
1497 1509
 test 'each_column';
1498 1510
 $dbi = DBIx::Custom->connect;
1499 1511
 eval { $dbi->execute("drop table ${q}table$p") };
1500
-eval { $dbi->execute('drop table table1') };
1501
-eval { $dbi->execute('drop table table2') };
1502
-eval { $dbi->execute('drop table table3') };
1512
+eval { $dbi->execute('drop table $table1') };
1513
+eval { $dbi->execute('drop table $table2') };
1514
+eval { $dbi->execute('drop table $table3') };
1503 1515
 $dbi->execute($create_table1_type);
1504 1516
 $dbi->execute($create_table2);
1505 1517
 
... ...
@@ -1515,17 +1527,17 @@ $dbi->each_column(sub {
1515 1527
 $infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos];
1516 1528
 is_deeply($infos, 
1517 1529
     [
1518
-        ['table1', 'key1', 'key1'],
1519
-        ['table1', 'key2', 'key2'],
1520
-        ['table2', 'key1', 'key1'],
1521
-        ['table2', 'key3', 'key3']
1530
+        [$table1, $key1, $key1],
1531
+        [$table1, $key2, $key2],
1532
+        [$table2, $key1, $key1],
1533
+        [$table2, $key3, $key3]
1522 1534
     ]
1523 1535
     
1524 1536
 );
1525 1537
 test 'each_table';
1526 1538
 $dbi = DBIx::Custom->connect;
1527
-eval { $dbi->execute('drop table table1') };
1528
-eval { $dbi->execute('drop table table2') };
1539
+eval { $dbi->execute('drop table $table1') };
1540
+eval { $dbi->execute('drop table $table2') };
1529 1541
 $dbi->execute($create_table2);
1530 1542
 $dbi->execute($create_table1_type);
1531 1543
 
... ...
@@ -1541,200 +1553,200 @@ $dbi->each_table(sub {
1541 1553
 $infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos];
1542 1554
 is_deeply($infos, 
1543 1555
     [
1544
-        ['table1', 'table1'],
1545
-        ['table2', 'table2'],
1556
+        [$table1, $table1],
1557
+        [$table2, $table2],
1546 1558
     ]
1547 1559
 );
1548 1560
 
1549 1561
 test 'connect super';
1550 1562
 $dbi = DBIx::Custom->connect;
1551
-eval { $dbi->execute('drop table table1') };
1563
+eval { $dbi->execute('drop table $table1') };
1552 1564
 $dbi->execute($create_table1);
1553
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1554
-is($dbi->select(table => 'table1')->one->{key1}, 1);
1565
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1566
+is($dbi->select(table => $table1)->one->{$key1}, 1);
1555 1567
 
1556 1568
 $dbi = DBIx::Custom->new;
1557 1569
 $dbi->connect;
1558
-eval { $dbi->execute('drop table table1') };
1570
+eval { $dbi->execute('drop table $table1') };
1559 1571
 $dbi->execute($create_table1);
1560
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1561
-is($dbi->select(table => 'table1')->one->{key1}, 1);
1572
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1573
+is($dbi->select(table => $table1)->one->{$key1}, 1);
1562 1574
 
1563 1575
 $dbi = DBIx::Custom->connect;
1564
-eval { $dbi->execute('drop table table1') };
1576
+eval { $dbi->execute('drop table $table1') };
1565 1577
 $dbi->execute($create_table1);
1566
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1567
-is($dbi->select(table => 'table1')->one->{key1}, 1);
1578
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1579
+is($dbi->select(table => $table1)->one->{$key1}, 1);
1568 1580
 
1569 1581
 test 'end_filter';
1570 1582
 $dbi = DBIx::Custom->connect;
1571
-eval { $dbi->execute('drop table table1') };
1583
+eval { $dbi->execute('drop table $table1') };
1572 1584
 $dbi->execute($create_table1);
1573
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1574
-$result = $dbi->select(table => 'table1');
1575
-$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
1576
-$result->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 });
1585
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1586
+$result = $dbi->select(table => $table1);
1587
+$result->filter($key1 => sub { $_[0] * 2 }, $key2 => sub { $_[0] * 4 });
1588
+$result->end_filter($key1 => sub { $_[0] * 3 }, $key2 => sub { $_[0] * 5 });
1577 1589
 $row = $result->fetch_first;
1578 1590
 is_deeply($row, [6, 40]);
1579 1591
 
1580 1592
 $dbi = DBIx::Custom->connect;
1581
-eval { $dbi->execute('drop table table1') };
1593
+eval { $dbi->execute('drop table $table1') };
1582 1594
 $dbi->execute($create_table1);
1583
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1584
-$result = $dbi->select(table => 'table1');
1585
-$result->filter([qw/key1 key2/] => sub { $_[0] * 2 });
1586
-$result->end_filter([[qw/key1 key2/] => sub { $_[0] * 3 }]);
1595
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1596
+$result = $dbi->select(table => $table1);
1597
+$result->filter([qw/$key1 $key2/] => sub { $_[0] * 2 });
1598
+$result->end_filter([[qw/$key1 $key2/] => sub { $_[0] * 3 }]);
1587 1599
 $row = $result->fetch_first;
1588 1600
 is_deeply($row, [6, 12]);
1589 1601
 
1590 1602
 $dbi = DBIx::Custom->connect;
1591
-eval { $dbi->execute('drop table table1') };
1603
+eval { $dbi->execute('drop table $table1') };
1592 1604
 $dbi->execute($create_table1);
1593
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1594
-$result = $dbi->select(table => 'table1');
1595
-$result->filter([[qw/key1 key2/] => sub { $_[0] * 2 }]);
1596
-$result->end_filter([qw/key1 key2/] => sub { $_[0] * 3 });
1605
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1606
+$result = $dbi->select(table => $table1);
1607
+$result->filter([[qw/$key1 $key2/] => sub { $_[0] * 2 }]);
1608
+$result->end_filter([qw/$key1 $key2/] => sub { $_[0] * 3 });
1597 1609
 $row = $result->fetch_first;
1598 1610
 is_deeply($row, [6, 12]);
1599 1611
 
1600 1612
 $dbi->register_filter(five_times => sub { $_[0] * 5 });
1601
-$result = $dbi->select(table => 'table1');
1602
-$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
1603
-$result->end_filter({key1 => sub { $_[0] * 3 }, key2 => 'five_times' });
1613
+$result = $dbi->select(table => $table1);
1614
+$result->filter($key1 => sub { $_[0] * 2 }, $key2 => sub { $_[0] * 4 });
1615
+$result->end_filter({$key1 => sub { $_[0] * 3 }, $key2 => 'five_times' });
1604 1616
 $row = $result->one;
1605
-is_deeply($row, {key1 => 6, key2 => 40});
1617
+is_deeply($row, {$key1 => 6, $key2 => 40});
1606 1618
 
1607 1619
 $dbi->register_filter(five_times => sub { $_[0] * 5 });
1608
-$dbi->apply_filter('table1',
1609
-    key1 => {end => sub { $_[0] * 3 } },
1610
-    key2 => {end => 'five_times'}
1620
+$dbi->apply_filter($table1,
1621
+    $key1 => {end => sub { $_[0] * 3 } },
1622
+    $key2 => {end => 'five_times'}
1611 1623
 );
1612
-$result = $dbi->select(table => 'table1');
1613
-$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
1624
+$result = $dbi->select(table => $table1);
1625
+$result->filter($key1 => sub { $_[0] * 2 }, $key2 => sub { $_[0] * 4 });
1614 1626
 $row = $result->one;
1615
-is_deeply($row, {key1 => 6, key2 => 40}, 'apply_filter');
1627
+is_deeply($row, {$key1 => 6, $key2 => 40}, 'apply_filter');
1616 1628
 
1617 1629
 $dbi->register_filter(five_times => sub { $_[0] * 5 });
1618
-$dbi->apply_filter('table1',
1619
-    key1 => {end => sub { $_[0] * 3 } },
1620
-    key2 => {end => 'five_times'}
1621
-);
1622
-$result = $dbi->select(table => 'table1');
1623
-$result->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 });
1624
-$result->filter(key1 => undef);
1625
-$result->end_filter(key1 => undef);
1630
+$dbi->apply_filter($table1,
1631
+    $key1 => {end => sub { $_[0] * 3 } },
1632
+    $key2 => {end => 'five_times'}
1633
+);
1634
+$result = $dbi->select(table => $table1);
1635
+$result->filter($key1 => sub { $_[0] * 2 }, $key2 => sub { $_[0] * 4 });
1636
+$result->filter($key1 => undef);
1637
+$result->end_filter($key1 => undef);
1626 1638
 $row = $result->one;
1627
-is_deeply($row, {key1 => 1, key2 => 40}, 'apply_filter overwrite');
1639
+is_deeply($row, {$key1 => 1, $key2 => 40}, 'apply_filter overwrite');
1628 1640
 
1629 1641
 test 'remove_end_filter and remove_filter';
1630 1642
 $dbi = DBIx::Custom->connect;
1631
-eval { $dbi->execute('drop table table1') };
1643
+eval { $dbi->execute('drop table $table1') };
1632 1644
 $dbi->execute($create_table1);
1633
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1634
-$result = $dbi->select(table => 'table1');
1645
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1646
+$result = $dbi->select(table => $table1);
1635 1647
 $row = $result
1636
-       ->filter(key1 => sub { $_[0] * 2 }, key2 => sub { $_[0] * 4 })
1648
+       ->filter($key1 => sub { $_[0] * 2 }, $key2 => sub { $_[0] * 4 })
1637 1649
        ->remove_filter
1638
-       ->end_filter(key1 => sub { $_[0] * 3 }, key2 => sub { $_[0] * 5 })
1650
+       ->end_filter($key1 => sub { $_[0] * 3 }, $key2 => sub { $_[0] * 5 })
1639 1651
        ->remove_end_filter
1640 1652
        ->fetch_first;
1641 1653
 is_deeply($row, [1, 2]);
1642 1654
 
1643 1655
 test 'empty where select';
1644 1656
 $dbi = DBIx::Custom->connect;
1645
-eval { $dbi->execute('drop table table1') };
1657
+eval { $dbi->execute('drop table $table1') };
1646 1658
 $dbi->execute($create_table1);
1647
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1648
-$result = $dbi->select(table => 'table1', where => {});
1659
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1660
+$result = $dbi->select(table => $table1, where => {});
1649 1661
 $row = $result->one;
1650
-is_deeply($row, {key1 => 1, key2 => 2});
1662
+is_deeply($row, {$key1 => 1, $key2 => 2});
1651 1663
 
1652 1664
 test 'select query option';
1653 1665
 $dbi = DBIx::Custom->connect;
1654
-eval { $dbi->execute('drop table table1') };
1666
+eval { $dbi->execute('drop table $table1') };
1655 1667
 $dbi->execute($create_table1);
1656
-$query = $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2}, query => 1);
1668
+$query = $dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2}, query => 1);
1657 1669
 is(ref $query, 'DBIx::Custom::Query');
1658
-$query = $dbi->update(table => 'table1', where => {key1 => 1}, param => {key2 => 2}, query => 1);
1670
+$query = $dbi->update(table => $table1, where => {$key1 => 1}, param => {$key2 => 2}, query => 1);
1659 1671
 is(ref $query, 'DBIx::Custom::Query');
1660
-$query = $dbi->delete(table => 'table1', where => {key1 => 1}, query => 1);
1672
+$query = $dbi->delete(table => $table1, where => {$key1 => 1}, query => 1);
1661 1673
 is(ref $query, 'DBIx::Custom::Query');
1662
-$query = $dbi->select(table => 'table1', where => {key1 => 1, key2 => 2}, query => 1);
1674
+$query = $dbi->select(table => $table1, where => {$key1 => 1, $key2 => 2}, query => 1);
1663 1675
 is(ref $query, 'DBIx::Custom::Query');
1664 1676
 
1665 1677
 test 'where';
1666 1678
 $dbi = DBIx::Custom->connect;
1667
-eval { $dbi->execute('drop table table1') };
1679
+eval { $dbi->execute('drop table $table1') };
1668 1680
 $dbi->execute($create_table1);
1669
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
1670
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
1671
-$where = $dbi->where->clause(['and', 'key1 = :key1', 'key2 = :key2']);
1672
-is("$where", "where ( key1 = :key1 and key2 = :key2 )", 'no param');
1681
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
1682
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
1683
+$where = $dbi->where->clause(['and', "$key1 = :$key1", "$key2 = :$key2"]);
1684
+is("$where", "where ( $key1 = :$key1 and $key2 = :$key2 )", 'no param');
1673 1685
 
1674 1686
 $where = $dbi->where
1675
-             ->clause(['and', 'key1 = :key1', 'key2 = :key2'])
1676
-             ->param({key1 => 1});
1687
+             ->clause(['and', "$key1 = :$key1", "$key2 = :$key2"])
1688
+             ->param({$key1 => 1});
1677 1689
 
1678 1690
 $result = $dbi->select(
1679
-    table => 'table1',
1691
+    table => $table1,
1680 1692
     where => $where
1681 1693
 );
1682 1694
 $row = $result->all;
1683
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1695
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1684 1696
 
1685 1697
 $result = $dbi->select(
1686
-    table => 'table1',
1698
+    table => $table1,
1687 1699
     where => [
1688
-        ['and', 'key1 = :key1', 'key2 = :key2'],
1689
-        {key1 => 1}
1700
+        ['and', "$key1 = :$key1", "$key2 = :$key2"],
1701
+        {$key1 => 1}
1690 1702
     ]
1691 1703
 );
1692 1704
 $row = $result->all;
1693
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1705
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1694 1706
 
1695 1707
 $where = $dbi->where
1696
-             ->clause(['and', 'key1 = :key1', 'key2 = :key2'])
1697
-             ->param({key1 => 1, key2 => 2});
1708
+             ->clause(['and', "$key1 = :$key1", "$key2 = :$key2"])
1709
+             ->param({$key1 => 1, $key2 => 2});
1698 1710
 $result = $dbi->select(
1699
-    table => 'table1',
1711
+    table => $table1,
1700 1712
     where => $where
1701 1713
 );
1702 1714
 $row = $result->all;
1703
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1715
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1704 1716
 
1705 1717
 $where = $dbi->where
1706
-             ->clause(['and', 'key1 = :key1', 'key2 = :key2'])
1718
+             ->clause(['and', "$key1 = :$key1", "$key2 = :$key2"])
1707 1719
              ->param({});
1708 1720
 $result = $dbi->select(
1709
-    table => 'table1',
1721
+    table => $table1,
1710 1722
     where => $where,
1711 1723
 );
1712 1724
 $row = $result->all;
1713
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1725
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1714 1726
 
1715 1727
 $where = $dbi->where
1716
-             ->clause(['and', ['or', 'key1 > :key1', 'key1 < :key1'], 'key2 = :key2'])
1717
-             ->param({key1 => [0, 3], key2 => 2});
1728
+             ->clause(['and', ['or', "$key1 > :$key1", "$key1 < :$key1"], "$key2 = :$key2"])
1729
+             ->param({$key1 => [0, 3], $key2 => 2});
1718 1730
 $result = $dbi->select(
1719
-    table => 'table1',
1731
+    table => $table1,
1720 1732
     where => $where,
1721 1733
 ); 
1722 1734
 $row = $result->all;
1723
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1735
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1724 1736
 
1725 1737
 $where = $dbi->where;
1726 1738
 $result = $dbi->select(
1727
-    table => 'table1',
1739
+    table => $table1,
1728 1740
     where => $where
1729 1741
 );
1730 1742
 $row = $result->all;
1731
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1743
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1732 1744
 
1733 1745
 eval {
1734 1746
 $where = $dbi->where
1735 1747
              ->clause(['uuu']);
1736 1748
 $result = $dbi->select(
1737
-    table => 'table1',
1749
+    table => $table1,
1738 1750
     where => $where
1739 1751
 );
1740 1752
 };
... ...
@@ -1744,306 +1756,306 @@ $where = $dbi->where;
1744 1756
 is("$where", '');
1745 1757
 
1746 1758
 $where = $dbi->where
1747
-             ->clause(['or', ('key1 = :key1') x 2])
1748
-             ->param({key1 => [1, 3]});
1759
+             ->clause(['or', ("$key1 = :$key1") x 2])
1760
+             ->param({$key1 => [1, 3]});
1749 1761
 $result = $dbi->select(
1750
-    table => 'table1',
1762
+    table => $table1,
1751 1763
     where => $where,
1752 1764
 );
1753 1765
 $row = $result->all;
1754
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1766
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1755 1767
 
1756 1768
 $where = $dbi->where
1757
-             ->clause(['or', ('key1 = :key1') x 2])
1758
-             ->param({key1 => [1]});
1769
+             ->clause(['or', ("$key1 = :$key1") x 2])
1770
+             ->param({$key1 => [1]});
1759 1771
 $result = $dbi->select(
1760
-    table => 'table1',
1772
+    table => $table1,
1761 1773
     where => $where,
1762 1774
 );
1763 1775
 $row = $result->all;
1764
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1776
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1765 1777
 
1766 1778
 $where = $dbi->where
1767
-             ->clause(['or', ('key1 = :key1') x 2])
1768
-             ->param({key1 => 1});
1779
+             ->clause(['or', ("$key1 = :$key1") x 2])
1780
+             ->param({$key1 => 1});
1769 1781
 $result = $dbi->select(
1770
-    table => 'table1',
1782
+    table => $table1,
1771 1783
     where => $where,
1772 1784
 );
1773 1785
 $row = $result->all;
1774
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1786
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1775 1787
 
1776 1788
 $where = $dbi->where
1777
-             ->clause('key1 = :key1')
1778
-             ->param({key1 => 1});
1789
+             ->clause('$key1 = :$key1')
1790
+             ->param({$key1 => 1});
1779 1791
 $result = $dbi->select(
1780
-    table => 'table1',
1792
+    table => $table1,
1781 1793
     where => $where,
1782 1794
 );
1783 1795
 $row = $result->all;
1784
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1796
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1785 1797
 
1786 1798
 $where = $dbi->where
1787
-             ->clause('key1 = :key1 key2 = :key2')
1788
-             ->param({key1 => 1});
1799
+             ->clause("$key1 = :$key1 $key2 = :$key2")
1800
+             ->param({$key1 => 1});
1789 1801
 eval{$where->to_string};
1790 1802
 like($@, qr/one column/);
1791 1803
 
1792 1804
 $where = $dbi->where
1793
-             ->clause(['or', ('key1 = :key1') x 3])
1794
-             ->param({key1 => [$dbi->not_exists, 1, 3]});
1805
+             ->clause(['or', ("$key1 = :$key1") x 3])
1806
+             ->param({$key1 => [$dbi->not_exists, 1, 3]});
1795 1807
 $result = $dbi->select(
1796
-    table => 'table1',
1808
+    table => $table1,
1797 1809
     where => $where,
1798 1810
 );
1799 1811
 $row = $result->all;
1800
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1812
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], 'not_exists');
1801 1813
 
1802 1814
 $where = $dbi->where
1803
-             ->clause(['or', ('key1 = :key1') x 3])
1804
-             ->param({key1 => [1, $dbi->not_exists, 3]});
1815
+             ->clause(['or', ("$key1 = :$key1") x 3])
1816
+             ->param({$key1 => [1, $dbi->not_exists, 3]});
1805 1817
 $result = $dbi->select(
1806
-    table => 'table1',
1818
+    table => $table1,
1807 1819
     where => $where,
1808 1820
 );
1809 1821
 $row = $result->all;
1810
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1822
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], 'not_exists');
1811 1823
 
1812 1824
 $where = $dbi->where
1813
-             ->clause(['or', ('key1 = :key1') x 3])
1814
-             ->param({key1 => [1, 3, $dbi->not_exists]});
1825
+             ->clause(['or', ("$key1 = :$key1") x 3])
1826
+             ->param({$key1 => [1, 3, $dbi->not_exists]});
1815 1827
 $result = $dbi->select(
1816
-    table => 'table1',
1828
+    table => $table1,
1817 1829
     where => $where,
1818 1830
 );
1819 1831
 $row = $result->all;
1820
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1832
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], 'not_exists');
1821 1833
 
1822 1834
 $where = $dbi->where
1823
-             ->clause(['or', ('key1 = :key1') x 3])
1824
-             ->param({key1 => [1, $dbi->not_exists, $dbi->not_exists]});
1835
+             ->clause(['or', ("$key1 = :$key1") x 3])
1836
+             ->param({$key1 => [1, $dbi->not_exists, $dbi->not_exists]});
1825 1837
 $result = $dbi->select(
1826
-    table => 'table1',
1838
+    table => $table1,
1827 1839
     where => $where,
1828 1840
 );
1829 1841
 $row = $result->all;
1830
-is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1842
+is_deeply($row, [{$key1 => 1, $key2 => 2}], 'not_exists');
1831 1843
 
1832 1844
 $where = $dbi->where
1833
-             ->clause(['or', ('key1 = :key1') x 3])
1834
-             ->param({key1 => [$dbi->not_exists, 1, $dbi->not_exists]});
1845
+             ->clause(['or', ("$key1 = :$key1") x 3])
1846
+             ->param({$key1 => [$dbi->not_exists, 1, $dbi->not_exists]});
1835 1847
 $result = $dbi->select(
1836
-    table => 'table1',
1848
+    table => $table1,
1837 1849
     where => $where,
1838 1850
 );
1839 1851
 $row = $result->all;
1840
-is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1852
+is_deeply($row, [{$key1 => 1, $key2 => 2}], 'not_exists');
1841 1853
 
1842 1854
 $where = $dbi->where
1843
-             ->clause(['or', ('key1 = :key1') x 3])
1844
-             ->param({key1 => [$dbi->not_exists, $dbi->not_exists, 1]});
1855
+             ->clause(['or', ("$key1 = :$key1") x 3])
1856
+             ->param({$key1 => [$dbi->not_exists, $dbi->not_exists, 1]});
1845 1857
 $result = $dbi->select(
1846
-    table => 'table1',
1858
+    table => $table1,
1847 1859
     where => $where,
1848 1860
 );
1849 1861
 $row = $result->all;
1850
-is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1862
+is_deeply($row, [{$key1 => 1, $key2 => 2}], 'not_exists');
1851 1863
 
1852 1864
 $where = $dbi->where
1853
-             ->clause(['or', ('key1 = :key1') x 3])
1854
-             ->param({key1 => [$dbi->not_exists, $dbi->not_exists, $dbi->not_exists]});
1865
+             ->clause(['or', ("$key1 = :$key1") x 3])
1866
+             ->param({$key1 => [$dbi->not_exists, $dbi->not_exists, $dbi->not_exists]});
1855 1867
 $result = $dbi->select(
1856
-    table => 'table1',
1868
+    table => $table1,
1857 1869
     where => $where,
1858 1870
 );
1859 1871
 $row = $result->all;
1860
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1872
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], 'not_exists');
1861 1873
 
1862 1874
 $where = $dbi->where
1863
-             ->clause(['or', ('key1 = :key1') x 3])
1864
-             ->param({key1 => []});
1875
+             ->clause(['or', ("$key1 = :$key1") x 3])
1876
+             ->param({$key1 => []});
1865 1877
 $result = $dbi->select(
1866
-    table => 'table1',
1878
+    table => $table1,
1867 1879
     where => $where,
1868 1880
 );
1869 1881
 $row = $result->all;
1870
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1882
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], 'not_exists');
1871 1883
 
1872 1884
 $where = $dbi->where
1873
-             ->clause(['and', '{> key1}', '{< key1}' ])
1874
-             ->param({key1 => [2, $dbi->not_exists]});
1885
+             ->clause(['and', "{> $key1}", "{< $key1}" ])
1886
+             ->param({$key1 => [2, $dbi->not_exists]});
1875 1887
 $result = $dbi->select(
1876
-    table => 'table1',
1888
+    table => $table1,
1877 1889
     where => $where,
1878 1890
 );
1879 1891
 $row = $result->all;
1880
-is_deeply($row, [{key1 => 3, key2 => 4}], 'not_exists');
1892
+is_deeply($row, [{$key1 => 3, $key2 => 4}], 'not_exists');
1881 1893
 
1882 1894
 $where = $dbi->where
1883
-             ->clause(['and', '{> key1}', '{< key1}' ])
1884
-             ->param({key1 => [$dbi->not_exists, 2]});
1895
+             ->clause(['and', "{> $key1}", "{< $key1}" ])
1896
+             ->param({$key1 => [$dbi->not_exists, 2]});
1885 1897
 $result = $dbi->select(
1886
-    table => 'table1',
1898
+    table => $table1,
1887 1899
     where => $where,
1888 1900
 );
1889 1901
 $row = $result->all;
1890
-is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1902
+is_deeply($row, [{$key1 => 1, $key2 => 2}], 'not_exists');
1891 1903
 
1892 1904
 $where = $dbi->where
1893
-             ->clause(['and', '{> key1}', '{< key1}' ])
1894
-             ->param({key1 => [$dbi->not_exists, $dbi->not_exists]});
1905
+             ->clause(['and', "{> $key1}", "{< $key1}" ])
1906
+             ->param({$key1 => [$dbi->not_exists, $dbi->not_exists]});
1895 1907
 $result = $dbi->select(
1896
-    table => 'table1',
1908
+    table => $table1,
1897 1909
     where => $where,
1898 1910
 );
1899 1911
 $row = $result->all;
1900
-is_deeply($row, [{key1 => 1, key2 => 2},{key1 => 3, key2 => 4}], 'not_exists');
1912
+is_deeply($row, [{$key1 => 1, $key2 => 2},{$key1 => 3, $key2 => 4}], 'not_exists');
1901 1913
 
1902 1914
 $where = $dbi->where
1903
-             ->clause(['and', '{> key1}', '{< key1}' ])
1904
-             ->param({key1 => [0, 2]});
1915
+             ->clause(['and', "{> $key1}", "{< $key1}" ])
1916
+             ->param({$key1 => [0, 2]});
1905 1917
 $result = $dbi->select(
1906
-    table => 'table1',
1918
+    table => $table1,
1907 1919
     where => $where,
1908 1920
 );
1909 1921
 $row = $result->all;
1910
-is_deeply($row, [{key1 => 1, key2 => 2}], 'not_exists');
1922
+is_deeply($row, [{$key1 => 1, $key2 => 2}], 'not_exists');
1911 1923
 
1912 1924
 $where = $dbi->where
1913
-             ->clause(['and', 'key1 is not null', 'key2 is not null' ]);
1925
+             ->clause(['and',"$key1 is not null", "$key2 is not null" ]);
1914 1926
 $result = $dbi->select(
1915
-    table => 'table1',
1927
+    table => $table1,
1916 1928
     where => $where,
1917 1929
 );
1918 1930
 $row = $result->all;
1919
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}], 'not_exists');
1931
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}], 'not_exists');
1920 1932
 
1921 1933
 eval {$dbi->where(ppp => 1) };
1922 1934
 like($@, qr/invalid/);
1923 1935
 
1924 1936
 $where = $dbi->where(
1925
-    clause => ['and', ['or'], ['and', 'key1 = :key1', 'key2 = :key2']],
1926
-    param => {key1 => 1, key2 => 2}
1937
+    clause => ['and', ['or'], ['and', "$key1 = :$key1", "$key2 = :$key2"]],
1938
+    param => {$key1 => 1, $key2 => 2}
1927 1939
 );
1928 1940
 $result = $dbi->select(
1929
-    table => 'table1',
1941
+    table => $table1,
1930 1942
     where => $where,
1931 1943
 );
1932 1944
 $row = $result->all;
1933
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1945
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1934 1946
 
1935 1947
 
1936 1948
 $where = $dbi->where(
1937
-    clause => ['and', ['or'], ['or', ':key1', ':key2']],
1949
+    clause => ['and', ['or'], ['or', ":$key1", ":$key2"]],
1938 1950
     param => {}
1939 1951
 );
1940 1952
 $result = $dbi->select(
1941
-    table => 'table1',
1953
+    table => $table1,
1942 1954
     where => $where,
1943 1955
 );
1944 1956
 $row = $result->all;
1945
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1957
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1946 1958
 
1947 1959
 $where = $dbi->where;
1948
-$where->clause(['and', ':key1{=}']);
1949
-$where->param({key1 => undef});
1950
-$result = $dbi->execute("select * from table1 $where", {key1 => 1});
1960
+$where->clause(['and', ":${key1}{=}"]);
1961
+$where->param({$key1 => undef});
1962
+$result = $dbi->execute("select * from $table1 $where", {$key1 => 1});
1951 1963
 $row = $result->all;
1952
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1964
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1953 1965
 
1954 1966
 $where = $dbi->where;
1955
-$where->clause(['and', ':key1{=}']);
1956
-$where->param({key1 => undef});
1967
+$where->clause(['and', ":${key1}{=}"]);
1968
+$where->param({$key1 => undef});
1957 1969
 $where->if('defined');
1958 1970
 $where->map;
1959
-$result = $dbi->execute("select * from table1 $where", {key1 => 1});
1971
+$result = $dbi->execute("select * from $table1 $where", {$key1 => 1});
1960 1972
 $row = $result->all;
1961
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1973
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1962 1974
 
1963 1975
 $where = $dbi->where;
1964
-$where->clause(['or', ':key1{=}', ':key1{=}']);
1965
-$where->param({key1 => [undef, undef]});
1966
-$result = $dbi->execute("select * from table1 $where", {key1 => [1, 0]});
1976
+$where->clause(['or', ":${key1}{=}", ":${key1}{=}"]);
1977
+$where->param({$key1 => [undef, undef]});
1978
+$result = $dbi->execute("select * from $table1 $where", {$key1 => [1, 0]});
1967 1979
 $row = $result->all;
1968
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1969
-$result = $dbi->execute("select * from table1 $where", {key1 => [0, 1]});
1980
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1981
+$result = $dbi->execute("select * from $table1 $where", {$key1 => [0, 1]});
1970 1982
 $row = $result->all;
1971
-is_deeply($row, [{key1 => 1, key2 => 2}]);
1983
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1972 1984
 
1973 1985
 $where = $dbi->where;
1974
-$where->clause(['and', ':key1{=}']);
1975
-$where->param({key1 => [undef, undef]});
1986
+$where->clause(['and', ":${key1}{=}"]);
1987
+$where->param({$key1 => [undef, undef]});
1976 1988
 $where->if('defined');
1977 1989
 $where->map;
1978
-$result = $dbi->execute("select * from table1 $where", {key1 => [1, 0]});
1990
+$result = $dbi->execute("select * from $table1 $where", {$key1 => [1, 0]});
1979 1991
 $row = $result->all;
1980
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1981
-$result = $dbi->execute("select * from table1 $where", {key1 => [0, 1]});
1992
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1993
+$result = $dbi->execute("select * from $table1 $where", {$key1 => [0, 1]});
1982 1994
 $row = $result->all;
1983
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
1995
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
1984 1996
 
1985 1997
 $where = $dbi->where;
1986
-$where->clause(['and', ':key1{=}']);
1987
-$where->param({key1 => 0});
1998
+$where->clause(['and', ":${key1}{=}"]);
1999
+$where->param({$key1 => 0});
1988 2000
 $where->if('length');
1989 2001
 $where->map;
1990
-$result = $dbi->execute("select * from table1 $where", {key1 => 1});
2002
+$result = $dbi->execute("select * from $table1 $where", {$key1 => 1});
1991 2003
 $row = $result->all;
1992
-is_deeply($row, [{key1 => 1, key2 => 2}]);
2004
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
1993 2005
 
1994 2006
 $where = $dbi->where;
1995
-$where->clause(['and', ':key1{=}']);
1996
-$where->param({key1 => ''});
2007
+$where->clause(['and', ":${key1}{=}"]);
2008
+$where->param({$key1 => ''});
1997 2009
 $where->if('length');
1998 2010
 $where->map;
1999
-$result = $dbi->execute("select * from table1 $where", {key1 => 1});
2011
+$result = $dbi->execute("select * from $table1 $where", {$key1 => 1});
2000 2012
 $row = $result->all;
2001
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
2013
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
2002 2014
 
2003 2015
 $where = $dbi->where;
2004
-$where->clause(['and', ':key1{=}']);
2005
-$where->param({key1 => 5});
2016
+$where->clause(['and', ":${key1}{=}"]);
2017
+$where->param({$key1 => 5});
2006 2018
 $where->if(sub { ($_[0] || '') eq 5 });
2007 2019
 $where->map;
2008
-$result = $dbi->execute("select * from table1 $where", {key1 => 1});
2020
+$result = $dbi->execute("select * from $table1 $where", {$key1 => 1});
2009 2021
 $row = $result->all;
2010
-is_deeply($row, [{key1 => 1, key2 => 2}]);
2022
+is_deeply($row, [{$key1 => 1, $key2 => 2}]);
2011 2023
 
2012 2024
 $where = $dbi->where;
2013
-$where->clause(['and', ':key1{=}']);
2014
-$where->param({key1 => 7});
2025
+$where->clause(['and', ":${key1}{=}"]);
2026
+$where->param({$key1 => 7});
2015 2027
 $where->if(sub { ($_[0] || '') eq 5 });
2016 2028
 $where->map;
2017
-$result = $dbi->execute("select * from table1 $where", {key1 => 1});
2029
+$result = $dbi->execute("select * from $table1 $where", {$key1 => 1});
2018 2030
 $row = $result->all;
2019
-is_deeply($row, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
2031
+is_deeply($row, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
2020 2032
 
2021 2033
 $where = $dbi->where;
2022 2034
 $where->param({id => 1, author => 'Ken', price => 1900});
2023
-$where->map(id => 'table1.id',
2024
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2025
-    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2035
+$where->map(id => '$table1.id',
2036
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
2037
+    price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
2026 2038
 );
2027
-is_deeply($where->param, {'table1.id' => 1, 'table1.author' => '%Ken%',
2028
-  'table1.price' => 1900});
2039
+is_deeply($where->param, {"$table1.id" => 1, "$table1.author" => '%Ken%',
2040
+  '$table1.price' => 1900});
2029 2041
 
2030 2042
 $where = $dbi->where;
2031 2043
 $where->param({id => 0, author => 0, price => 0});
2032 2044
 $where->map(
2033
-    id => 'table1.id',
2034
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2035
-    price => ['table1.price', sub { '%' . $_[0] . '%' },
2045
+    id => '$table1.id',
2046
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
2047
+    price => ['$table1.price', sub { '%' . $_[0] . '%' },
2036 2048
       {if => sub { $_[0] eq 0 }}]
2037 2049
 );
2038
-is_deeply($where->param, {'table1.id' => 0, 'table1.author' => '%0%', 'table1.price' => '%0%'});
2050
+is_deeply($where->param, {"$table1.id" => 0, "$table1.author" => '%0%', "$table1.price" => '%0%'});
2039 2051
 
2040 2052
 $where = $dbi->where;
2041 2053
 $where->param({id => '', author => '', price => ''});
2042 2054
 $where->if('length');
2043 2055
 $where->map(
2044
-    id => 'table1.id',
2045
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2046
-    price => ['table1.price', sub { '%' . $_[0] . '%' },
2056
+    id => '$table1.id',
2057
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
2058
+    price => ['$table1.price', sub { '%' . $_[0] . '%' },
2047 2059
       {if => sub { $_[0] eq 1 }}]
2048 2060
 );
2049 2061
 is_deeply($where->param, {});
... ...
@@ -2052,50 +2064,50 @@ $where = $dbi->where;
2052 2064
 $where->param({id => undef, author => undef, price => undef});
2053 2065
 $where->if('length');
2054 2066
 $where->map(
2055
-    id => 'table1.id',
2056
-    price => ['table1.price', {if => 'exists'}]
2067
+    id => '$table1.id',
2068
+    price => ['$table1.price', {if => 'exists'}]
2057 2069
 );
2058
-is_deeply($where->param, {'table1.price' => undef});
2070
+is_deeply($where->param, {'$table1.price' => undef});
2059 2071
 
2060 2072
 $where = $dbi->where;
2061 2073
 $where->param({price => 'a'});
2062 2074
 $where->if('length');
2063 2075
 $where->map(
2064
-    id => ['table1.id', {if => 'exists'}],
2065
-    price => ['table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
2076
+    id => ['$table1.id', {if => 'exists'}],
2077
+    price => ['$table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
2066 2078
 );
2067
-is_deeply($where->param, {'table1.price' => '%a'});
2079
+is_deeply($where->param, {'$table1.price' => '%a'});
2068 2080
 
2069 2081
 $where = $dbi->where;
2070 2082
 $where->param({id => [1, 2], author => 'Ken', price => 1900});
2071 2083
 $where->map(
2072
-    id => 'table1.id',
2073
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2074
-    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2084
+    id => '$table1.id',
2085
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
2086
+    price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
2075 2087
 );
2076
-is_deeply($where->param, {'table1.id' => [1, 2], 'table1.author' => '%Ken%',
2077
-  'table1.price' => 1900});
2088
+is_deeply($where->param, {"$table1.id" => [1, 2], "$table1.author" => '%Ken%',
2089
+  '$table1.price' => 1900});
2078 2090
 
2079 2091
 $where = $dbi->where;
2080 2092
 $where->if('length');
2081 2093
 $where->param({id => ['', ''], author => 'Ken', price => 1900});
2082 2094
 $where->map(
2083
-    id => 'table1.id',
2084
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
2085
-    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2095
+    id => '$table1.id',
2096
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
2097
+    price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
2086 2098
 );
2087
-is_deeply($where->param, {'table1.id' => [$dbi->not_exists, $dbi->not_exists], 'table1.author' => '%Ken%',
2088
-  'table1.price' => 1900});
2099
+is_deeply($where->param, {"$table1.id" => [$dbi->not_exists, $dbi->not_exists], "$table1.author" => '%Ken%',
2100
+  '$table1.price' => 1900});
2089 2101
 
2090 2102
 $where = $dbi->where;
2091 2103
 $where->param({id => ['', ''], author => 'Ken', price => 1900});
2092 2104
 $where->map(
2093
-    id => ['table1.id', {if => 'length'}],
2094
-    author => ['table1.author', sub { '%' . $_[0] . '%' }, {if => 'defined'}],
2095
-    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
2105
+    id => ['$table1.id', {if => 'length'}],
2106
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }, {if => 'defined'}],
2107
+    price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
2096 2108
 );
2097
-is_deeply($where->param, {'table1.id' => [$dbi->not_exists, $dbi->not_exists], 'table1.author' => '%Ken%',
2098
-  'table1.price' => 1900});
2109
+is_deeply($where->param, {"$table1.id" => [$dbi->not_exists, $dbi->not_exists], "$table1.author" => '%Ken%',
2110
+  '$table1.price' => 1900});
2099 2111
 
2100 2112
 test 'dbi_option default';
2101 2113
 $dbi = DBIx::Custom->new;
... ...
@@ -2138,28 +2150,28 @@ $dbi->apply_filter(
2138 2150
 
2139 2151
 );
2140 2152
 $dbi = DBIx::Custom->connect;
2141
-eval { $dbi->execute('drop table table1') };
2153
+eval { $dbi->execute('drop table $table1') };
2142 2154
 $dbi->execute($create_table1);
2143
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2144
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
2145
-$dbi->apply_filter('table1', 'key2', 
2155
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2156
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
2157
+$dbi->apply_filter($table1, $key2, 
2146 2158
                    {in => sub { $_[0] * 3 }, out => sub { $_[0] * 2 }});
2147
-$rows = $dbi->select(table => 'table1', where => {key2 => 1})->all;
2148
-is_deeply($rows, [{key1 => 1, key2 => 6}]);
2159
+$rows = $dbi->select(table => $table1, where => {$key2 => 1})->all;
2160
+is_deeply($rows, [{$key1 => 1, $key2 => 6}]);
2149 2161
 
2150 2162
 $dbi = DBIx::Custom->connect;
2151
-eval { $dbi->execute('drop table table1') };
2163
+eval { $dbi->execute('drop table $table1') };
2152 2164
 $dbi->execute($create_table1);
2153
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2154
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
2155
-$dbi->apply_filter('table1', 'key2', {});
2156
-$rows = $dbi->select(table => 'table1', where => {key2 => 2})->all;
2157
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
2165
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2166
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
2167
+$dbi->apply_filter($table1, $key2, {});
2168
+$rows = $dbi->select(table => $table1, where => {$key2 => 2})->all;
2169
+is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
2158 2170
 
2159 2171
 $dbi = DBIx::Custom->connect;
2160
-eval {$dbi->apply_filter('table1', 'key2', {out => 'no'})};
2172
+eval {$dbi->apply_filter($table1, $key2, {out => 'no'})};
2161 2173
 like($@, qr/not registered/);
2162
-eval {$dbi->apply_filter('table1', 'key2', {in => 'no'})};
2174
+eval {$dbi->apply_filter($table1, $key2, {in => 'no'})};
2163 2175
 like($@, qr/not registered/);
2164 2176
 $dbi->method({one => sub { 1 }});
2165 2177
 is($dbi->one, 1);
... ...
@@ -2168,15 +2180,15 @@ eval{DBIx::Custom->connect(dsn => undef)};
2168 2180
 like($@, qr/_connect/);
2169 2181
 
2170 2182
 $dbi = DBIx::Custom->connect;
2171
-eval { $dbi->execute('drop table table1') };
2183
+eval { $dbi->execute('drop table $table1') };
2172 2184
 $dbi->execute($create_table1);
2173 2185
 $dbi->register_filter(twice => sub { $_[0] * 2 });
2174
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
2175
-             filter => {key1 => 'twice'});
2176
-$row = $dbi->select(table => 'table1')->one;
2177
-is_deeply($row, {key1 => 2, key2 => 2});
2178
-eval {$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2},
2179
-             filter => {key1 => 'no'}) };
2186
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2},
2187
+             filter => {$key1 => 'twice'});
2188
+$row = $dbi->select(table => $table1)->one;
2189
+is_deeply($row, {$key1 => 2, $key2 => 2});
2190
+eval {$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2},
2191
+             filter => {$key1 => 'no'}) };
2180 2192
 like($@, qr//);
2181 2193
 
2182 2194
 $dbi->register_filter(one => sub { });
... ...
@@ -2192,17 +2204,17 @@ $dbi->default_bind_filter(undef);
2192 2204
 ok(!defined $dbi->default_bind_filter);
2193 2205
 $dbi->default_fetch_filter(undef);
2194 2206
 ok(!defined $dbi->default_fetch_filter);
2195
-eval {$dbi->execute('select * from table1 {} {= author') };
2207
+eval {$dbi->execute("select * from $table1 {} {= author") };
2196 2208
 like($@, qr/Tag not finished/);
2197 2209
 
2198 2210
 $dbi = DBIx::Custom->connect;
2199
-eval { $dbi->execute('drop table table1') };
2211
+eval { $dbi->execute('drop table $table1') };
2200 2212
 $dbi->execute($create_table1);
2201 2213
 $dbi->register_filter(one => sub { 1 });
2202
-$result = $dbi->select(table => 'table1');
2203
-eval {$result->filter(key1 => 'no')};
2214
+$result = $dbi->select(table => $table1);
2215
+eval {$result->filter($key1 => 'no')};
2204 2216
 like($@, qr/not registered/);
2205
-eval {$result->end_filter(key1 => 'no')};
2217
+eval {$result->end_filter($key1 => 'no')};
2206 2218
 like($@, qr/not registered/);
2207 2219
 $result->default_filter(undef);
2208 2220
 ok(!defined $result->default_filter);
... ...
@@ -2223,158 +2235,158 @@ is($result->stash->{foo}, 1, 'get and set');
2223 2235
 
2224 2236
 test 'delete_at';
2225 2237
 $dbi = DBIx::Custom->connect;
2226
-eval { $dbi->execute('drop table table1') };
2238
+eval { $dbi->execute('drop table $table1') };
2227 2239
 $dbi->execute($create_table1_2);
2228
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2240
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2229 2241
 $dbi->delete_at(
2230
-    table => 'table1',
2231
-    primary_key => ['key1', 'key2'],
2242
+    table => $table1,
2243
+    primary_key => [$key1, $key2],
2232 2244
     where => [1, 2],
2233 2245
 );
2234
-is_deeply($dbi->select(table => 'table1')->all, []);
2246
+is_deeply($dbi->select(table => $table1)->all, []);
2235 2247
 
2236
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2248
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2237 2249
 $dbi->delete_at(
2238
-    table => 'table1',
2239
-    primary_key => 'key1',
2250
+    table => $table1,
2251
+    primary_key => $key1,
2240 2252
     where => 1,
2241 2253
 );
2242
-is_deeply($dbi->select(table => 'table1')->all, []);
2254
+is_deeply($dbi->select(table => $table1)->all, []);
2243 2255
 
2244 2256
 test 'insert_at';
2245 2257
 $dbi = DBIx::Custom->connect;
2246
-eval { $dbi->execute('drop table table1') };
2258
+eval { $dbi->execute('drop table $table1') };
2247 2259
 $dbi->execute($create_table1_2);
2248 2260
 $dbi->insert_at(
2249
-    primary_key => ['key1', 'key2'], 
2250
-    table => 'table1',
2261
+    primary_key => [$key1, $key2], 
2262
+    table => $table1,
2251 2263
     where => [1, 2],
2252
-    param => {key3 => 3}
2264
+    param => {$key3 => 3}
2253 2265
 );
2254
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2255
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2256
-is($dbi->select(table => 'table1')->one->{key3}, 3);
2266
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2267
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2268
+is($dbi->select(table => $table1)->one->{$key3}, 3);
2257 2269
 
2258
-$dbi->delete_all(table => 'table1');
2259
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2270
+$dbi->delete_all(table => $table1);
2271
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2260 2272
 $dbi->insert_at(
2261
-    primary_key => 'key1', 
2262
-    table => 'table1',
2273
+    primary_key => $key1, 
2274
+    table => $table1,
2263 2275
     where => 1,
2264
-    param => {key2 => 2, key3 => 3}
2276
+    param => {$key2 => 2, $key3 => 3}
2265 2277
 );
2266 2278
 
2267
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2268
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2269
-is($dbi->select(table => 'table1')->one->{key3}, 3);
2279
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2280
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2281
+is($dbi->select(table => $table1)->one->{$key3}, 3);
2270 2282
 
2271 2283
 eval {
2272 2284
     $dbi->insert_at(
2273
-        table => 'table1',
2274
-        primary_key => ['key1', 'key2'],
2285
+        table => $table1,
2286
+        primary_key => [$key1, $key2],
2275 2287
         where => {},
2276
-        param => {key1 => 1, key2 => 2, key3 => 3},
2288
+        param => {$key1 => 1, $key2 => 2, $key3 => 3},
2277 2289
     );
2278 2290
 };
2279 2291
 like($@, qr/must be/);
2280 2292
 
2281 2293
 $dbi = DBIx::Custom->connect;
2282
-eval { $dbi->execute('drop table table1') };
2294
+eval { $dbi->execute('drop table $table1') };
2283 2295
 $dbi->execute($create_table1_2);
2284 2296
 $dbi->insert_at(
2285
-    {key3 => 3},
2286
-    primary_key => ['key1', 'key2'], 
2287
-    table => 'table1',
2297
+    {$key3 => 3},
2298
+    primary_key => [$key1, $key2], 
2299
+    table => $table1,
2288 2300
     where => [1, 2],
2289 2301
 );
2290
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2291
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2292
-is($dbi->select(table => 'table1')->one->{key3}, 3);
2302
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2303
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2304
+is($dbi->select(table => $table1)->one->{$key3}, 3);
2293 2305
 
2294 2306
 test 'update_at';
2295 2307
 $dbi = DBIx::Custom->connect;
2296
-eval { $dbi->execute('drop table table1') };
2308
+eval { $dbi->execute('drop table $table1') };
2297 2309
 $dbi->execute($create_table1_2);
2298
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2310
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2299 2311
 $dbi->update_at(
2300
-    table => 'table1',
2301
-    primary_key => ['key1', 'key2'],
2312
+    table => $table1,
2313
+    primary_key => [$key1, $key2],
2302 2314
     where => [1, 2],
2303
-    param => {key3 => 4}
2315
+    param => {$key3 => 4}
2304 2316
 );
2305
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2306
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2307
-is($dbi->select(table => 'table1')->one->{key3}, 4);
2317
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2318
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2319
+is($dbi->select(table => $table1)->one->{$key3}, 4);
2308 2320
 
2309
-$dbi->delete_all(table => 'table1');
2310
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2321
+$dbi->delete_all(table => $table1);
2322
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2311 2323
 $dbi->update_at(
2312
-    table => 'table1',
2313
-    primary_key => 'key1',
2324
+    table => $table1,
2325
+    primary_key => $key1,
2314 2326
     where => 1,
2315
-    param => {key3 => 4}
2327
+    param => {$key3 => 4}
2316 2328
 );
2317
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2318
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2319
-is($dbi->select(table => 'table1')->one->{key3}, 4);
2329
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2330
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2331
+is($dbi->select(table => $table1)->one->{$key3}, 4);
2320 2332
 
2321 2333
 $dbi = DBIx::Custom->connect;
2322
-eval { $dbi->execute('drop table table1') };
2334
+eval { $dbi->execute('drop table $table1') };
2323 2335
 $dbi->execute($create_table1_2);
2324
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2336
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2325 2337
 $dbi->update_at(
2326
-    {key3 => 4},
2327
-    table => 'table1',
2328
-    primary_key => ['key1', 'key2'],
2338
+    {$key3 => 4},
2339
+    table => $table1,
2340
+    primary_key => [$key1, $key2],
2329 2341
     where => [1, 2]
2330 2342
 );
2331
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2332
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2333
-is($dbi->select(table => 'table1')->one->{key3}, 4);
2343
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2344
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2345
+is($dbi->select(table => $table1)->one->{$key3}, 4);
2334 2346
 
2335 2347
 test 'select_at';
2336 2348
 $dbi = DBIx::Custom->connect;
2337
-eval { $dbi->execute('drop table table1') };
2349
+eval { $dbi->execute('drop table $table1') };
2338 2350
 $dbi->execute($create_table1_2);
2339
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2351
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2340 2352
 $result = $dbi->select_at(
2341
-    table => 'table1',
2342
-    primary_key => ['key1', 'key2'],
2353
+    table => $table1,
2354
+    primary_key => [$key1, $key2],
2343 2355
     where => [1, 2]
2344 2356
 );
2345 2357
 $row = $result->one;
2346
-is($row->{key1}, 1);
2347
-is($row->{key2}, 2);
2348
-is($row->{key3}, 3);
2358
+is($row->{$key1}, 1);
2359
+is($row->{$key2}, 2);
2360
+is($row->{$key3}, 3);
2349 2361
 
2350
-$dbi->delete_all(table => 'table1');
2351
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2362
+$dbi->delete_all(table => $table1);
2363
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2352 2364
 $result = $dbi->select_at(
2353
-    table => 'table1',
2354
-    primary_key => 'key1',
2365
+    table => $table1,
2366
+    primary_key => $key1,
2355 2367
     where => 1,
2356 2368
 );
2357 2369
 $row = $result->one;
2358
-is($row->{key1}, 1);
2359
-is($row->{key2}, 2);
2360
-is($row->{key3}, 3);
2370
+is($row->{$key1}, 1);
2371
+is($row->{$key2}, 2);
2372
+is($row->{$key3}, 3);
2361 2373
 
2362
-$dbi->delete_all(table => 'table1');
2363
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2374
+$dbi->delete_all(table => $table1);
2375
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2364 2376
 $result = $dbi->select_at(
2365
-    table => 'table1',
2366
-    primary_key => ['key1', 'key2'],
2377
+    table => $table1,
2378
+    primary_key => [$key1, $key2],
2367 2379
     where => [1, 2]
2368 2380
 );
2369 2381
 $row = $result->one;
2370
-is($row->{key1}, 1);
2371
-is($row->{key2}, 2);
2372
-is($row->{key3}, 3);
2382
+is($row->{$key1}, 1);
2383
+is($row->{$key2}, 2);
2384
+is($row->{$key3}, 3);
2373 2385
 
2374 2386
 eval {
2375 2387
     $result = $dbi->select_at(
2376
-        table => 'table1',
2377
-        primary_key => ['key1', 'key2'],
2388
+        table => $table1,
2389
+        primary_key => [$key1, $key2],
2378 2390
         where => {},
2379 2391
     );
2380 2392
 };
... ...
@@ -2382,8 +2394,8 @@ like($@, qr/must be/);
2382 2394
 
2383 2395
 eval {
2384 2396
     $result = $dbi->select_at(
2385
-        table => 'table1',
2386
-        primary_key => ['key1', 'key2'],
2397
+        table => $table1,
2398
+        primary_key => [$key1, $key2],
2387 2399
         where => [1],
2388 2400
     );
2389 2401
 };
... ...
@@ -2391,18 +2403,18 @@ like($@, qr/same/);
2391 2403
 
2392 2404
 eval {
2393 2405
     $result = $dbi->update_at(
2394
-        table => 'table1',
2395
-        primary_key => ['key1', 'key2'],
2406
+        table => $table1,
2407
+        primary_key => [$key1, $key2],
2396 2408
         where => {},
2397
-        param => {key1 => 1, key2 => 2},
2409
+        param => {$key1 => 1, $key2 => 2},
2398 2410
     );
2399 2411
 };
2400 2412
 like($@, qr/must be/);
2401 2413
 
2402 2414
 eval {
2403 2415
     $result = $dbi->delete_at(
2404
-        table => 'table1',
2405
-        primary_key => ['key1', 'key2'],
2416
+        table => $table1,
2417
+        primary_key => [$key1, $key2],
2406 2418
         where => {},
2407 2419
     );
2408 2420
 };
... ...
@@ -2411,609 +2423,609 @@ like($@, qr/must be/);
2411 2423
 test 'columns';
2412 2424
 use MyDBI1;
2413 2425
 $dbi = MyDBI1->connect;
2414
-$model = $dbi->model('table1');
2426
+$model = $dbi->model($table1);
2415 2427
 
2416 2428
 
2417 2429
 test 'model delete_at';
2418 2430
 $dbi = MyDBI6->connect;
2419
-eval { $dbi->execute('drop table table1') };
2420
-eval { $dbi->execute('drop table table2') };
2421
-eval { $dbi->execute('drop table table3') };
2431
+eval { $dbi->execute('drop table $table1') };
2432
+eval { $dbi->execute('drop table $table2') };
2433
+eval { $dbi->execute('drop table $table3') };
2422 2434
 $dbi->execute($create_table1_2);
2423 2435
 $dbi->execute($create_table2_2);
2424 2436
 $dbi->execute($create_table3);
2425
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2426
-$dbi->model('table1')->delete_at(where => [1, 2]);
2427
-is_deeply($dbi->select(table => 'table1')->all, []);
2428
-$dbi->insert(table => 'table2', param => {key1 => 1, key2 => 2, key3 => 3});
2429
-$dbi->model('table1')->delete_at(where => [1, 2]);
2430
-is_deeply($dbi->select(table => 'table1')->all, []);
2431
-$dbi->insert(table => 'table3', param => {key1 => 1, key2 => 2, key3 => 3});
2432
-$dbi->model('table3')->delete_at(where => [1, 2]);
2433
-is_deeply($dbi->select(table => 'table3')->all, []);
2437
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2438
+$dbi->model($table1)->delete_at(where => [1, 2]);
2439
+is_deeply($dbi->select(table => $table1)->all, []);
2440
+$dbi->insert(table => $table2, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2441
+$dbi->model($table1)->delete_at(where => [1, 2]);
2442
+is_deeply($dbi->select(table => $table1)->all, []);
2443
+$dbi->insert(table => $table3, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2444
+$dbi->model($table3)->delete_at(where => [1, 2]);
2445
+is_deeply($dbi->select(table => $table3)->all, []);
2434 2446
 
2435 2447
 test 'model insert_at';
2436 2448
 $dbi = MyDBI6->connect;
2437
-eval { $dbi->execute('drop table table1') };
2449
+eval { $dbi->execute('drop table $table1') };
2438 2450
 $dbi->execute($create_table1_2);
2439
-$dbi->model('table1')->insert_at(
2451
+$dbi->model($table1)->insert_at(
2440 2452
     where => [1, 2],
2441
-    param => {key3 => 3}
2453
+    param => {$key3 => 3}
2442 2454
 );
2443
-$result = $dbi->model('table1')->select;
2455
+$result = $dbi->model($table1)->select;
2444 2456
 $row = $result->one;
2445
-is($row->{key1}, 1);
2446
-is($row->{key2}, 2);
2447
-is($row->{key3}, 3);
2457
+is($row->{$key1}, 1);
2458
+is($row->{$key2}, 2);
2459
+is($row->{$key3}, 3);
2448 2460
 
2449 2461
 test 'model update_at';
2450 2462
 $dbi = MyDBI6->connect;
2451
-eval { $dbi->execute('drop table table1') };
2463
+eval { $dbi->execute('drop table $table1') };
2452 2464
 $dbi->execute($create_table1_2);
2453
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2454
-$dbi->model('table1')->update_at(
2465
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2466
+$dbi->model($table1)->update_at(
2455 2467
     where => [1, 2],
2456
-    param => {key3 => 4}
2468
+    param => {$key3 => 4}
2457 2469
 );
2458
-$result = $dbi->model('table1')->select;
2470
+$result = $dbi->model($table1)->select;
2459 2471
 $row = $result->one;
2460
-is($row->{key1}, 1);
2461
-is($row->{key2}, 2);
2462
-is($row->{key3}, 4);
2472
+is($row->{$key1}, 1);
2473
+is($row->{$key2}, 2);
2474
+is($row->{$key3}, 4);
2463 2475
 
2464 2476
 test 'model select_at';
2465 2477
 $dbi = MyDBI6->connect;
2466
-eval { $dbi->execute('drop table table1') };
2478
+eval { $dbi->execute('drop table $table1') };
2467 2479
 $dbi->execute($create_table1_2);
2468
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2469
-$result = $dbi->model('table1')->select_at(where => [1, 2]);
2480
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2481
+$result = $dbi->model($table1)->select_at(where => [1, 2]);
2470 2482
 $row = $result->one;
2471
-is($row->{key1}, 1);
2472
-is($row->{key2}, 2);
2473
-is($row->{key3}, 3);
2483
+is($row->{$key1}, 1);
2484
+is($row->{$key2}, 2);
2485
+is($row->{$key3}, 3);
2474 2486
 
2475 2487
 
2476 2488
 test 'mycolumn and column';
2477 2489
 $dbi = MyDBI7->connect;
2478
-eval { $dbi->execute('drop table table1') };
2479
-eval { $dbi->execute('drop table table2') };
2490
+eval { $dbi->execute('drop table $table1') };
2491
+eval { $dbi->execute('drop table $table2') };
2480 2492
 $dbi->execute($create_table1);
2481 2493
 $dbi->execute($create_table2);
2482 2494
 $dbi->separator('__');
2483 2495
 $dbi->setup_model;
2484
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2485
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2486
-$model = $dbi->model('table1');
2496
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2497
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
2498
+$model = $dbi->model($table1);
2487 2499
 $result = $model->select(
2488
-    column => [$model->mycolumn, $model->column('table2')],
2489
-    where => {'table1.key1' => 1}
2500
+    column => [$model->mycolumn, $model->column($table2)],
2501
+    where => {'$table1.$key1' => 1}
2490 2502
 );
2491 2503
 is_deeply($result->one,
2492
-          {key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3});
2504
+          {$key1 => 1, $key2 => 2, "${table2}__$key1" => 1, "${table2}__$key3" => 3});
2493 2505
 
2494 2506
 test 'insert_param';
2495 2507
 $dbi = DBIx::Custom->connect;
2496
-eval { $dbi->execute('drop table table1') };
2508
+eval { $dbi->execute('drop table $table1') };
2497 2509
 $dbi->execute($create_table1_2);
2498
-$param = {key1 => 1, key2 => 2};
2510
+$param = {$key1 => 1, $key2 => 2};
2499 2511
 $insert_param = $dbi->insert_param($param);
2500 2512
 $sql = <<"EOS";
2501
-insert into table1 $insert_param
2513
+insert into $table1 $insert_param
2502 2514
 EOS
2503
-$dbi->execute($sql, param => $param, table => 'table1');
2504
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2505
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2515
+$dbi->execute($sql, param => $param, table => $table1);
2516
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2517
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2506 2518
 
2507 2519
 $dbi = DBIx::Custom->connect;
2508
-eval { $dbi->execute('drop table table1') };
2520
+eval { $dbi->execute('drop table $table1') };
2509 2521
 $dbi->execute($create_table1_2);
2510
-$param = {key1 => 1, key2 => 2};
2522
+$param = {$key1 => 1, $key2 => 2};
2511 2523
 $insert_param = $dbi->insert_param($param);
2512 2524
 $sql = <<"EOS";
2513
-insert into table1 $insert_param
2525
+insert into $table1 $insert_param
2514 2526
 EOS
2515
-$dbi->execute($sql, param => $param, table => 'table1');
2516
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2517
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2527
+$dbi->execute($sql, param => $param, table => $table1);
2528
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2529
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2518 2530
 
2519 2531
 eval { $dbi->insert_param({";" => 1}) };
2520 2532
 like($@, qr/not safety/);
2521 2533
 
2522 2534
 test 'mycolumn';
2523 2535
 $dbi = MyDBI8->connect;
2524
-eval { $dbi->execute('drop table table1') };
2525
-eval { $dbi->execute('drop table table2') };
2536
+eval { $dbi->execute('drop table $table1') };
2537
+eval { $dbi->execute('drop table $table2') };
2526 2538
 $dbi->execute($create_table1);
2527 2539
 $dbi->execute($create_table2);
2528 2540
 $dbi->setup_model;
2529
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2530
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2531
-$model = $dbi->model('table1');
2541
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2542
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
2543
+$model = $dbi->model($table1);
2532 2544
 $result = $model->select_at(
2533 2545
     column => [
2534 2546
         $model->mycolumn,
2535
-        $model->column('table2')
2547
+        $model->column($table2)
2536 2548
     ]
2537 2549
 );
2538 2550
 is_deeply($result->one,
2539
-          {key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3});
2551
+          {$key1 => 1, $key2 => 2, "$table2.$key1" => 1, "$table2.$key3" => 3});
2540 2552
 
2541 2553
 $result = $model->select_at(
2542 2554
     column => [
2543
-        $model->mycolumn(['key1']),
2544
-        $model->column(table2 => ['key1'])
2555
+        $model->mycolumn([$key1]),
2556
+        $model->column($table2 => [$key1])
2545 2557
     ]
2546 2558
 );
2547 2559
 is_deeply($result->one,
2548
-          {key1 => 1, 'table2.key1' => 1});
2560
+          {$key1 => 1, '$table2.$key1' => 1});
2549 2561
 $result = $model->select_at(
2550 2562
     column => [
2551
-        $model->mycolumn(['key1']),
2552
-        {table2 => ['key1']}
2563
+        $model->mycolumn([$key1]),
2564
+        {$table2 => [$key1]}
2553 2565
     ]
2554 2566
 );
2555 2567
 is_deeply($result->one,
2556
-          {key1 => 1, 'table2.key1' => 1});
2568
+          {$key1 => 1, '$table2.$key1' => 1});
2557 2569
 
2558 2570
 $result = $model->select_at(
2559 2571
     column => [
2560
-        $model->mycolumn(['key1']),
2561
-        ['table2.key1', as => 'table2.key1']
2572
+        $model->mycolumn([$key1]),
2573
+        ["$table2.$key1", as => "$table2.$key1"]
2562 2574
     ]
2563 2575
 );
2564 2576
 is_deeply($result->one,
2565
-          {key1 => 1, 'table2.key1' => 1});
2577
+          {$key1 => 1, '$table2.$key1' => 1});
2566 2578
 
2567 2579
 $result = $model->select_at(
2568 2580
     column => [
2569
-        $model->mycolumn(['key1']),
2570
-        ['table2.key1' => 'table2.key1']
2581
+        $model->mycolumn([$key1]),
2582
+        ["$table2.$key1" => "$table2.$key1"]
2571 2583
     ]
2572 2584
 );
2573 2585
 is_deeply($result->one,
2574
-          {key1 => 1, 'table2.key1' => 1});
2586
+          {$key1 => 1, '$table2.$key1' => 1});
2575 2587
 
2576 2588
 test 'merge_param';
2577 2589
 $dbi = DBIx::Custom->new;
2578 2590
 $params = [
2579
-    {key1 => 1, key2 => 2, key3 => 3},
2580
-    {key1 => 1, key2 => 2},
2581
-    {key1 => 1}
2591
+    {$key1 => 1, $key2 => 2, $key3 => 3},
2592
+    {$key1 => 1, $key2 => 2},
2593
+    {$key1 => 1}
2582 2594
 ];
2583 2595
 $param = $dbi->merge_param($params->[0], $params->[1], $params->[2]);
2584
-is_deeply($param, {key1 => [1, 1, 1], key2 => [2, 2], key3 => 3});
2596
+is_deeply($param, {$key1 => [1, 1, 1], $key2 => [2, 2], $key3 => 3});
2585 2597
 
2586 2598
 $params = [
2587
-    {key1 => [1, 2], key2 => 1, key3 => [1, 2]},
2588
-    {key1 => [3, 4], key2 => [2, 3], key3 => 3}
2599
+    {$key1 => [1, 2], $key2 => 1, $key3 => [1, 2]},
2600
+    {$key1 => [3, 4], $key2 => [2, 3], $key3 => 3}
2589 2601
 ];
2590 2602
 $param = $dbi->merge_param($params->[0], $params->[1]);
2591
-is_deeply($param, {key1 => [1, 2, 3, 4], key2 => [1, 2, 3], key3 => [1, 2, 3]});
2603
+is_deeply($param, {$key1 => [1, 2, 3, 4], $key2 => [1, 2, 3], $key3 => [1, 2, 3]});
2592 2604
 
2593 2605
 test 'select() param option';
2594 2606
 $dbi = DBIx::Custom->connect;
2595
-eval { $dbi->execute('drop table table1') };
2607
+eval { $dbi->execute('drop table $table1') };
2596 2608
 $dbi->execute($create_table1);
2597
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2598
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2599
-eval { $dbi->execute('drop table table2') };
2609
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2610
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
2611
+eval { $dbi->execute('drop table $table2') };
2600 2612
 $dbi->execute($create_table2);
2601
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
2602
-$dbi->insert(table => 'table2', param => {key1 => 2, key3 => 5});
2613
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 4});
2614
+$dbi->insert(table => $table2, param => {$key1 => 2, $key3 => 5});
2603 2615
 $rows = $dbi->select(
2604
-    table => 'table1',
2605
-    column => 'table1.key1 as table1_key1, key2, key3',
2606
-    where   => {'table1.key2' => 3},
2607
-    join  => ['inner join (select * from table2 where {= table2.key3})' . 
2608
-              ' as table2 on table1.key1 = table2.key1'],
2609
-    param => {'table2.key3' => 5}
2616
+    table => $table1,
2617
+    column => "$table1.$key1 as ${table1}_$key1, $key2, $key3",
2618
+    where   => {'$table1.$key2' => 3},
2619
+    join  => ["inner join (select * from $table2 where {= $table2.$key3})" . 
2620
+              " as $table2 on $table1.$key1 = $table2.$key1"],
2621
+    param => {'$table2.$key3' => 5}
2610 2622
 )->all;
2611
-is_deeply($rows, [{table1_key1 => 2, key2 => 3, key3 => 5}]);
2623
+is_deeply($rows, [{"${table1}_$key1" => 2, $key2 => 3, $key3 => 5}]);
2612 2624
 
2613 2625
 test 'select() string where';
2614 2626
 $dbi = DBIx::Custom->connect;
2615
-eval { $dbi->execute('drop table table1') };
2627
+eval { $dbi->execute('drop table $table1') };
2616 2628
 $dbi->execute($create_table1);
2617
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2618
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2629
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2630
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
2619 2631
 $rows = $dbi->select(
2620
-    table => 'table1',
2621
-    where => 'key1 = :key1 and key2 = :key2',
2622
-    where_param => {key1 => 1, key2 => 2}
2632
+    table => $table1,
2633
+    where => "$key1 = :$key1 and $key2 = :$key2",
2634
+    where_param => {$key1 => 1, $key2 => 2}
2623 2635
 )->all;
2624
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
2636
+is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
2625 2637
 
2626 2638
 $dbi = DBIx::Custom->connect;
2627
-eval { $dbi->execute('drop table table1') };
2639
+eval { $dbi->execute('drop table $table1') };
2628 2640
 $dbi->execute($create_table1);
2629
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2630
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2641
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2642
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
2631 2643
 $rows = $dbi->select(
2632
-    table => 'table1',
2644
+    table => $table1,
2633 2645
     where => [
2634
-        'key1 = :key1 and key2 = :key2',
2635
-        {key1 => 1, key2 => 2}
2646
+        "$key1 = :$key1 and $key2 = :$key2",
2647
+        {$key1 => 1, $key2 => 2}
2636 2648
     ]
2637 2649
 )->all;
2638
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
2650
+is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
2639 2651
 
2640 2652
 test 'delete() string where';
2641 2653
 $dbi = DBIx::Custom->connect;
2642
-eval { $dbi->execute('drop table table1') };
2654
+eval { $dbi->execute('drop table $table1') };
2643 2655
 $dbi->execute($create_table1);
2644
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2645
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2656
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2657
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
2646 2658
 $dbi->delete(
2647
-    table => 'table1',
2648
-    where => 'key1 = :key1 and key2 = :key2',
2649
-    where_param => {key1 => 1, key2 => 2}
2659
+    table => $table1,
2660
+    where => "$key1 = :$key1 and $key2 = :$key2",
2661
+    where_param => {$key1 => 1, $key2 => 2}
2650 2662
 );
2651
-$rows = $dbi->select(table => 'table1')->all;
2652
-is_deeply($rows, [{key1 => 2, key2 => 3}]);
2663
+$rows = $dbi->select(table => $table1)->all;
2664
+is_deeply($rows, [{$key1 => 2, $key2 => 3}]);
2653 2665
 
2654 2666
 $dbi = DBIx::Custom->connect;
2655
-eval { $dbi->execute('drop table table1') };
2667
+eval { $dbi->execute('drop table $table1') };
2656 2668
 $dbi->execute($create_table1);
2657
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2658
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
2669
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2670
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
2659 2671
 $dbi->delete(
2660
-    table => 'table1',
2672
+    table => $table1,
2661 2673
     where => [
2662
-        'key1 = :key1 and key2 = :key2',
2663
-         {key1 => 1, key2 => 2}
2674
+        "$key1 = :$key1 and $key2 = :$key2",
2675
+         {$key1 => 1, $key2 => 2}
2664 2676
     ]
2665 2677
 );
2666
-$rows = $dbi->select(table => 'table1')->all;
2667
-is_deeply($rows, [{key1 => 2, key2 => 3}]);
2678
+$rows = $dbi->select(table => $table1)->all;
2679
+is_deeply($rows, [{$key1 => 2, $key2 => 3}]);
2668 2680
 
2669 2681
 
2670 2682
 test 'update() string where';
2671 2683
 $dbi = DBIx::Custom->connect;
2672
-eval { $dbi->execute('drop table table1') };
2684
+eval { $dbi->execute('drop table $table1') };
2673 2685
 $dbi->execute($create_table1);
2674
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2686
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2675 2687
 $dbi->update(
2676
-    table => 'table1',
2677
-    param => {key1 => 5},
2678
-    where => 'key1 = :key1 and key2 = :key2',
2679
-    where_param => {key1 => 1, key2 => 2}
2688
+    table => $table1,
2689
+    param => {$key1 => 5},
2690
+    where => "$key1 = :$key1 and $key2 = :$key2",
2691
+    where_param => {$key1 => 1, $key2 => 2}
2680 2692
 );
2681
-$rows = $dbi->select(table => 'table1')->all;
2682
-is_deeply($rows, [{key1 => 5, key2 => 2}]);
2693
+$rows = $dbi->select(table => $table1)->all;
2694
+is_deeply($rows, [{$key1 => 5, $key2 => 2}]);
2683 2695
 
2684 2696
 $dbi = DBIx::Custom->connect;
2685
-eval { $dbi->execute('drop table table1') };
2697
+eval { $dbi->execute('drop table $table1') };
2686 2698
 $dbi->execute($create_table1);
2687
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2699
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2688 2700
 $dbi->update(
2689
-    table => 'table1',
2690
-    param => {key1 => 5},
2701
+    table => $table1,
2702
+    param => {$key1 => 5},
2691 2703
     where => [
2692
-        'key1 = :key1 and key2 = :key2',
2693
-        {key1 => 1, key2 => 2}
2704
+        "$key1 = :$key1 and $key2 = :$key2",
2705
+        {$key1 => 1, $key2 => 2}
2694 2706
     ]
2695 2707
 );
2696
-$rows = $dbi->select(table => 'table1')->all;
2697
-is_deeply($rows, [{key1 => 5, key2 => 2}]);
2708
+$rows = $dbi->select(table => $table1)->all;
2709
+is_deeply($rows, [{$key1 => 5, $key2 => 2}]);
2698 2710
 
2699 2711
 test 'insert id and primary_key option';
2700 2712
 $dbi = DBIx::Custom->connect;
2701
-eval { $dbi->execute('drop table table1') };
2713
+eval { $dbi->execute('drop table $table1') };
2702 2714
 $dbi->execute($create_table1_2);
2703 2715
 $dbi->insert(
2704
-    primary_key => ['key1', 'key2'], 
2705
-    table => 'table1',
2716
+    primary_key => [$key1, $key2], 
2717
+    table => $table1,
2706 2718
     id => [1, 2],
2707
-    param => {key3 => 3}
2719
+    param => {$key3 => 3}
2708 2720
 );
2709
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2710
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2711
-is($dbi->select(table => 'table1')->one->{key3}, 3);
2721
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2722
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2723
+is($dbi->select(table => $table1)->one->{$key3}, 3);
2712 2724
 
2713
-$dbi->delete_all(table => 'table1');
2725
+$dbi->delete_all(table => $table1);
2714 2726
 $dbi->insert(
2715
-    primary_key => 'key1', 
2716
-    table => 'table1',
2727
+    primary_key => $key1, 
2728
+    table => $table1,
2717 2729
     id => 0,
2718
-    param => {key2 => 2, key3 => 3}
2730
+    param => {$key2 => 2, $key3 => 3}
2719 2731
 );
2720 2732
 
2721
-is($dbi->select(table => 'table1')->one->{key1}, 0);
2722
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2723
-is($dbi->select(table => 'table1')->one->{key3}, 3);
2733
+is($dbi->select(table => $table1)->one->{$key1}, 0);
2734
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2735
+is($dbi->select(table => $table1)->one->{$key3}, 3);
2724 2736
 
2725 2737
 $dbi = DBIx::Custom->connect;
2726
-eval { $dbi->execute('drop table table1') };
2738
+eval { $dbi->execute('drop table $table1') };
2727 2739
 $dbi->execute($create_table1_2);
2728 2740
 $dbi->insert(
2729
-    {key3 => 3},
2730
-    primary_key => ['key1', 'key2'], 
2731
-    table => 'table1',
2741
+    {$key3 => 3},
2742
+    primary_key => [$key1, $key2], 
2743
+    table => $table1,
2732 2744
     id => [1, 2],
2733 2745
 );
2734
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2735
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2736
-is($dbi->select(table => 'table1')->one->{key3}, 3);
2746
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2747
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2748
+is($dbi->select(table => $table1)->one->{$key3}, 3);
2737 2749
 
2738 2750
 test 'model insert id and primary_key option';
2739 2751
 $dbi = MyDBI6->connect;
2740
-eval { $dbi->execute('drop table table1') };
2752
+eval { $dbi->execute('drop table $table1') };
2741 2753
 $dbi->execute($create_table1_2);
2742
-$dbi->model('table1')->insert(
2754
+$dbi->model($table1)->insert(
2743 2755
     id => [1, 2],
2744
-    param => {key3 => 3}
2756
+    param => {$key3 => 3}
2745 2757
 );
2746
-$result = $dbi->model('table1')->select;
2758
+$result = $dbi->model($table1)->select;
2747 2759
 $row = $result->one;
2748
-is($row->{key1}, 1);
2749
-is($row->{key2}, 2);
2750
-is($row->{key3}, 3);
2760
+is($row->{$key1}, 1);
2761
+is($row->{$key2}, 2);
2762
+is($row->{$key3}, 3);
2751 2763
 
2752 2764
 $dbi = MyDBI6->connect;
2753
-eval { $dbi->execute('drop table table1') };
2765
+eval { $dbi->execute('drop table $table1') };
2754 2766
 $dbi->execute($create_table1_2);
2755
-$dbi->model('table1')->insert(
2756
-    {key3 => 3},
2767
+$dbi->model($table1)->insert(
2768
+    {$key3 => 3},
2757 2769
     id => [1, 2]
2758 2770
 );
2759
-$result = $dbi->model('table1')->select;
2771
+$result = $dbi->model($table1)->select;
2760 2772
 $row = $result->one;
2761
-is($row->{key1}, 1);
2762
-is($row->{key2}, 2);
2763
-is($row->{key3}, 3);
2773
+is($row->{$key1}, 1);
2774
+is($row->{$key2}, 2);
2775
+is($row->{$key3}, 3);
2764 2776
 
2765 2777
 test 'update and id option';
2766 2778
 $dbi = DBIx::Custom->connect;
2767
-eval { $dbi->execute('drop table table1') };
2779
+eval { $dbi->execute('drop table $table1') };
2768 2780
 $dbi->execute($create_table1_2);
2769
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2781
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2770 2782
 $dbi->update(
2771
-    table => 'table1',
2772
-    primary_key => ['key1', 'key2'],
2783
+    table => $table1,
2784
+    primary_key => [$key1, $key2],
2773 2785
     id => [1, 2],
2774
-    param => {key3 => 4}
2786
+    param => {$key3 => 4}
2775 2787
 );
2776
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2777
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2778
-is($dbi->select(table => 'table1')->one->{key3}, 4);
2788
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2789
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2790
+is($dbi->select(table => $table1)->one->{$key3}, 4);
2779 2791
 
2780
-$dbi->delete_all(table => 'table1');
2781
-$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
2792
+$dbi->delete_all(table => $table1);
2793
+$dbi->insert(table => $table1, param => {$key1 => 0, $key2 => 2, $key3 => 3});
2782 2794
 $dbi->update(
2783
-    table => 'table1',
2784
-    primary_key => 'key1',
2795
+    table => $table1,
2796
+    primary_key => $key1,
2785 2797
     id => 0,
2786
-    param => {key3 => 4}
2798
+    param => {$key3 => 4}
2787 2799
 );
2788
-is($dbi->select(table => 'table1')->one->{key1}, 0);
2789
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2790
-is($dbi->select(table => 'table1')->one->{key3}, 4);
2800
+is($dbi->select(table => $table1)->one->{$key1}, 0);
2801
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2802
+is($dbi->select(table => $table1)->one->{$key3}, 4);
2791 2803
 
2792 2804
 $dbi = DBIx::Custom->connect;
2793
-eval { $dbi->execute('drop table table1') };
2805
+eval { $dbi->execute('drop table $table1') };
2794 2806
 $dbi->execute($create_table1_2);
2795
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2807
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2796 2808
 $dbi->update(
2797
-    {key3 => 4},
2798
-    table => 'table1',
2799
-    primary_key => ['key1', 'key2'],
2809
+    {$key3 => 4},
2810
+    table => $table1,
2811
+    primary_key => [$key1, $key2],
2800 2812
     id => [1, 2]
2801 2813
 );
2802
-is($dbi->select(table => 'table1')->one->{key1}, 1);
2803
-is($dbi->select(table => 'table1')->one->{key2}, 2);
2804
-is($dbi->select(table => 'table1')->one->{key3}, 4);
2814
+is($dbi->select(table => $table1)->one->{$key1}, 1);
2815
+is($dbi->select(table => $table1)->one->{$key2}, 2);
2816
+is($dbi->select(table => $table1)->one->{$key3}, 4);
2805 2817
 
2806 2818
 
2807 2819
 test 'model update and id option';
2808 2820
 $dbi = MyDBI6->connect;
2809
-eval { $dbi->execute('drop table table1') };
2821
+eval { $dbi->execute('drop table $table1') };
2810 2822
 $dbi->execute($create_table1_2);
2811
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2812
-$dbi->model('table1')->update(
2823
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2824
+$dbi->model($table1)->update(
2813 2825
     id => [1, 2],
2814
-    param => {key3 => 4}
2826
+    param => {$key3 => 4}
2815 2827
 );
2816
-$result = $dbi->model('table1')->select;
2828
+$result = $dbi->model($table1)->select;
2817 2829
 $row = $result->one;
2818
-is($row->{key1}, 1);
2819
-is($row->{key2}, 2);
2820
-is($row->{key3}, 4);
2830
+is($row->{$key1}, 1);
2831
+is($row->{$key2}, 2);
2832
+is($row->{$key3}, 4);
2821 2833
 
2822 2834
 
2823 2835
 test 'delete and id option';
2824 2836
 $dbi = DBIx::Custom->connect;
2825
-eval { $dbi->execute('drop table table1') };
2837
+eval { $dbi->execute('drop table $table1') };
2826 2838
 $dbi->execute($create_table1_2);
2827
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2839
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2828 2840
 $dbi->delete(
2829
-    table => 'table1',
2830
-    primary_key => ['key1', 'key2'],
2841
+    table => $table1,
2842
+    primary_key => [$key1, $key2],
2831 2843
     id => [1, 2],
2832 2844
 );
2833
-is_deeply($dbi->select(table => 'table1')->all, []);
2845
+is_deeply($dbi->select(table => $table1)->all, []);
2834 2846
 
2835
-$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
2847
+$dbi->insert(table => $table1, param => {$key1 => 0, $key2 => 2, $key3 => 3});
2836 2848
 $dbi->delete(
2837
-    table => 'table1',
2838
-    primary_key => 'key1',
2849
+    table => $table1,
2850
+    primary_key => $key1,
2839 2851
     id => 0,
2840 2852
 );
2841
-is_deeply($dbi->select(table => 'table1')->all, []);
2853
+is_deeply($dbi->select(table => $table1)->all, []);
2842 2854
 
2843 2855
 
2844 2856
 test 'model delete and id option';
2845 2857
 $dbi = MyDBI6->connect;
2846
-eval { $dbi->execute('drop table table1') };
2847
-eval { $dbi->execute('drop table table2') };
2848
-eval { $dbi->execute('drop table table3') };
2858
+eval { $dbi->execute('drop table $table1') };
2859
+eval { $dbi->execute('drop table $table2') };
2860
+eval { $dbi->execute('drop table $table3') };
2849 2861
 $dbi->execute($create_table1_2);
2850 2862
 $dbi->execute($create_table2_2);
2851 2863
 $dbi->execute($create_table3);
2852
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2853
-$dbi->model('table1')->delete(id => [1, 2]);
2854
-is_deeply($dbi->select(table => 'table1')->all, []);
2855
-$dbi->insert(table => 'table2', param => {key1 => 1, key2 => 2, key3 => 3});
2856
-$dbi->model('table1')->delete(id => [1, 2]);
2857
-is_deeply($dbi->select(table => 'table1')->all, []);
2858
-$dbi->insert(table => 'table3', param => {key1 => 1, key2 => 2, key3 => 3});
2859
-$dbi->model('table3')->delete(id => [1, 2]);
2860
-is_deeply($dbi->select(table => 'table3')->all, []);
2864
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2865
+$dbi->model($table1)->delete(id => [1, 2]);
2866
+is_deeply($dbi->select(table => $table1)->all, []);
2867
+$dbi->insert(table => $table2, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2868
+$dbi->model($table1)->delete(id => [1, 2]);
2869
+is_deeply($dbi->select(table => $table1)->all, []);
2870
+$dbi->insert(table => $table3, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2871
+$dbi->model($table3)->delete(id => [1, 2]);
2872
+is_deeply($dbi->select(table => $table3)->all, []);
2861 2873
 
2862 2874
 
2863 2875
 test 'select and id option';
2864 2876
 $dbi = DBIx::Custom->connect;
2865
-eval { $dbi->execute('drop table table1') };
2877
+eval { $dbi->execute('drop table $table1') };
2866 2878
 $dbi->execute($create_table1_2);
2867
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2879
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2868 2880
 $result = $dbi->select(
2869
-    table => 'table1',
2870
-    primary_key => ['key1', 'key2'],
2881
+    table => $table1,
2882
+    primary_key => [$key1, $key2],
2871 2883
     id => [1, 2]
2872 2884
 );
2873 2885
 $row = $result->one;
2874
-is($row->{key1}, 1);
2875
-is($row->{key2}, 2);
2876
-is($row->{key3}, 3);
2886
+is($row->{$key1}, 1);
2887
+is($row->{$key2}, 2);
2888
+is($row->{$key3}, 3);
2877 2889
 
2878
-$dbi->delete_all(table => 'table1');
2879
-$dbi->insert(table => 'table1', param => {key1 => 0, key2 => 2, key3 => 3});
2890
+$dbi->delete_all(table => $table1);
2891
+$dbi->insert(table => $table1, param => {$key1 => 0, $key2 => 2, $key3 => 3});
2880 2892
 $result = $dbi->select(
2881
-    table => 'table1',
2882
-    primary_key => 'key1',
2893
+    table => $table1,
2894
+    primary_key => $key1,
2883 2895
     id => 0,
2884 2896
 );
2885 2897
 $row = $result->one;
2886
-is($row->{key1}, 0);
2887
-is($row->{key2}, 2);
2888
-is($row->{key3}, 3);
2898
+is($row->{$key1}, 0);
2899
+is($row->{$key2}, 2);
2900
+is($row->{$key3}, 3);
2889 2901
 
2890
-$dbi->delete_all(table => 'table1');
2891
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2902
+$dbi->delete_all(table => $table1);
2903
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2892 2904
 $result = $dbi->select(
2893
-    table => 'table1',
2894
-    primary_key => ['key1', 'key2'],
2905
+    table => $table1,
2906
+    primary_key => [$key1, $key2],
2895 2907
     id => [1, 2]
2896 2908
 );
2897 2909
 $row = $result->one;
2898
-is($row->{key1}, 1);
2899
-is($row->{key2}, 2);
2900
-is($row->{key3}, 3);
2910
+is($row->{$key1}, 1);
2911
+is($row->{$key2}, 2);
2912
+is($row->{$key3}, 3);
2901 2913
 
2902 2914
 
2903 2915
 test 'model select_at';
2904 2916
 $dbi = MyDBI6->connect;
2905
-eval { $dbi->execute('drop table table1') };
2917
+eval { $dbi->execute('drop table $table1') };
2906 2918
 $dbi->execute($create_table1_2);
2907
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3});
2908
-$result = $dbi->model('table1')->select(id => [1, 2]);
2919
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3});
2920
+$result = $dbi->model($table1)->select(id => [1, 2]);
2909 2921
 $row = $result->one;
2910
-is($row->{key1}, 1);
2911
-is($row->{key2}, 2);
2912
-is($row->{key3}, 3);
2922
+is($row->{$key1}, 1);
2923
+is($row->{$key2}, 2);
2924
+is($row->{$key3}, 3);
2913 2925
 
2914 2926
 test 'column separator is default .';
2915 2927
 $dbi = MyDBI7->connect;
2916
-eval { $dbi->execute('drop table table1') };
2917
-eval { $dbi->execute('drop table table2') };
2928
+eval { $dbi->execute('drop table $table1') };
2929
+eval { $dbi->execute('drop table $table2') };
2918 2930
 $dbi->execute($create_table1);
2919 2931
 $dbi->execute($create_table2);
2920 2932
 $dbi->setup_model;
2921
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2922
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2923
-$model = $dbi->model('table1');
2933
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2934
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
2935
+$model = $dbi->model($table1);
2924 2936
 $result = $model->select(
2925
-    column => [$model->column('table2')],
2926
-    where => {'table1.key1' => 1}
2937
+    column => [$model->column($table2)],
2938
+    where => {'$table1.$key1' => 1}
2927 2939
 );
2928 2940
 is_deeply($result->one,
2929
-          {'table2.key1' => 1, 'table2.key3' => 3});
2941
+          {"$table2.$key1" => 1, "$table2.$key3" => 3});
2930 2942
 
2931 2943
 $result = $model->select(
2932
-    column => [$model->column('table2' => [qw/key1 key3/])],
2933
-    where => {'table1.key1' => 1}
2944
+    column => [$model->column($table2 => [qw/$key1 $key3/])],
2945
+    where => {'$table1.$key1' => 1}
2934 2946
 );
2935 2947
 is_deeply($result->one,
2936
-          {'table2.key1' => 1, 'table2.key3' => 3});
2948
+          {"$table2.$key1" => 1, "$table2.$key3" => 3});
2937 2949
 
2938 2950
 test 'separator';
2939 2951
 $dbi = DBIx::Custom->connect;
2940
-eval { $dbi->execute('drop table table1') };
2941
-eval { $dbi->execute('drop table table2') };
2952
+eval { $dbi->execute('drop table $table1') };
2953
+eval { $dbi->execute('drop table $table2') };
2942 2954
 $dbi->execute($create_table1);
2943 2955
 $dbi->execute($create_table2);
2944 2956
 
2945 2957
 $dbi->create_model(
2946
-    table => 'table1',
2958
+    table => $table1,
2947 2959
     join => [
2948
-       'left outer join table2 on table1.key1 = table2.key1'
2960
+       "left outer join $table2 on $table1.$key1 = $table2.$key1"
2949 2961
     ],
2950
-    primary_key => ['key1'],
2962
+    primary_key => [$key1],
2951 2963
 );
2952 2964
 $model2 = $dbi->create_model(
2953
-    table => 'table2',
2965
+    table => $table2,
2954 2966
 );
2955 2967
 $dbi->setup_model;
2956
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2957
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
2958
-$model = $dbi->model('table1');
2968
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
2969
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
2970
+$model = $dbi->model($table1);
2959 2971
 $result = $model->select(
2960 2972
     column => [
2961 2973
         $model->mycolumn,
2962
-        {table2 => [qw/key1 key3/]}
2974
+        {$table2 => [qw/$key1 $key3/]}
2963 2975
     ],
2964
-    where => {'table1.key1' => 1}
2976
+    where => {'$table1.$key1' => 1}
2965 2977
 );
2966 2978
 is_deeply($result->one,
2967
-          {key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3});
2968
-is_deeply($model2->select->one, {key1 => 1, key3 => 3});
2979
+          {$key1 => 1, $key2 => 2, "$table2.$key1" => 1, "$table2.$key3" => 3});
2980
+is_deeply($model2->select->one, {$key1 => 1, $key3 => 3});
2969 2981
 
2970 2982
 $dbi->separator('__');
2971
-$model = $dbi->model('table1');
2983
+$model = $dbi->model($table1);
2972 2984
 $result = $model->select(
2973 2985
     column => [
2974 2986
         $model->mycolumn,
2975
-        {table2 => [qw/key1 key3/]}
2987
+        {$table2 => [qw/$key1 $key3/]}
2976 2988
     ],
2977
-    where => {'table1.key1' => 1}
2989
+    where => {'$table1.$key1' => 1}
2978 2990
 );
2979 2991
 is_deeply($result->one,
2980
-          {key1 => 1, key2 => 2, 'table2__key1' => 1, 'table2__key3' => 3});
2981
-is_deeply($model2->select->one, {key1 => 1, key3 => 3});
2992
+          {$key1 => 1, $key2 => 2, "${table2}__$key1" => 1, "${table2}__$key3" => 3});
2993
+is_deeply($model2->select->one, {$key1 => 1, $key3 => 3});
2982 2994
 
2983 2995
 $dbi->separator('-');
2984
-$model = $dbi->model('table1');
2996
+$model = $dbi->model($table1);
2985 2997
 $result = $model->select(
2986 2998
     column => [
2987 2999
         $model->mycolumn,
2988
-        {table2 => [qw/key1 key3/]}
3000
+        {$table2 => [qw/$key1 $key3/]}
2989 3001
     ],
2990
-    where => {'table1.key1' => 1}
3002
+    where => {'$table1.$key1' => 1}
2991 3003
 );
2992 3004
 is_deeply($result->one,
2993
-          {key1 => 1, key2 => 2, 'table2-key1' => 1, 'table2-key3' => 3});
2994
-is_deeply($model2->select->one, {key1 => 1, key3 => 3});
3005
+          {$key1 => 1, $key2 => 2, "$table2-$key1" => 1, "$table2-$key3" => 3});
3006
+is_deeply($model2->select->one, {$key1 => 1, $key3 => 3});
2995 3007
 
2996 3008
 
2997 3009
 test 'filter_off';
2998 3010
 $dbi = DBIx::Custom->connect;
2999
-eval { $dbi->execute('drop table table1') };
3000
-eval { $dbi->execute('drop table table2') };
3011
+eval { $dbi->execute('drop table $table1') };
3012
+eval { $dbi->execute('drop table $table2') };
3001 3013
 $dbi->execute($create_table1);
3002 3014
 $dbi->execute($create_table2);
3003 3015
 
3004 3016
 $dbi->create_model(
3005
-    table => 'table1',
3017
+    table => $table1,
3006 3018
     join => [
3007
-       'left outer join table2 on table1.key1 = table2.key1'
3019
+       "left outer join $table2 on $table1.$key1 = $table2.$key1"
3008 3020
     ],
3009
-    primary_key => ['key1'],
3021
+    primary_key => [$key1],
3010 3022
 );
3011 3023
 $dbi->setup_model;
3012
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3013
-$model = $dbi->model('table1');
3014
-$result = $model->select(column => 'key1');
3015
-$result->filter(key1 => sub { $_[0] * 2 });
3016
-is_deeply($result->one, {key1 => 2});
3024
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3025
+$model = $dbi->model($table1);
3026
+$result = $model->select(column => $key1);
3027
+$result->filter($key1 => sub { $_[0] * 2 });
3028
+is_deeply($result->one, {$key1 => 2});
3017 3029
 
3018 3030
 test 'available_datetype';
3019 3031
 $dbi = DBIx::Custom->connect;
... ...
@@ -3022,230 +3034,230 @@ ok($dbi->can('available_datatype'));
3022 3034
 
3023 3035
 test 'select prefix option';
3024 3036
 $dbi = DBIx::Custom->connect;
3025
-eval { $dbi->execute('drop table table1') };
3037
+eval { $dbi->execute('drop table $table1') };
3026 3038
 $dbi->execute($create_table1);
3027
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3028
-$rows = $dbi->select(prefix => 'key1,', column => 'key2', table => 'table1')->all;
3029
-is_deeply($rows, [{key1 => 1, key2 => 2}], "table");
3039
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3040
+$rows = $dbi->select(prefix => '$key1,', column => $key2, table => $table1)->all;
3041
+is_deeply($rows, [{$key1 => 1, $key2 => 2}], "table");
3030 3042
 
3031 3043
 test 'map_param';
3032 3044
 $dbi = DBIx::Custom->connect;
3033 3045
 $param = $dbi->map_param(
3034 3046
     {id => 1, author => 'Ken', price => 1900},
3035
-    id => 'table1.id',
3036
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
3037
-    price => ['table1.price', {if => sub { $_[0] eq 1900 }}]
3047
+    id => '$table1.id',
3048
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
3049
+    price => ['$table1.price', {if => sub { $_[0] eq 1900 }}]
3038 3050
 );
3039
-is_deeply($param, {'table1.id' => 1, 'table1.author' => '%Ken%',
3040
-  'table1.price' => 1900});
3051
+is_deeply($param, {"$table1.id" => 1, "$table1.author" => '%Ken%',
3052
+  '$table1.price' => 1900});
3041 3053
 
3042 3054
 $param = $dbi->map_param(
3043 3055
     {id => 0, author => 0, price => 0},
3044
-    id => 'table1.id',
3045
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
3046
-    price => ['table1.price', sub { '%' . $_[0] . '%' },
3056
+    id => '$table1.id',
3057
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
3058
+    price => ['$table1.price', sub { '%' . $_[0] . '%' },
3047 3059
       {if => sub { $_[0] eq 0 }}]
3048 3060
 );
3049
-is_deeply($param, {'table1.id' => 0, 'table1.author' => '%0%', 'table1.price' => '%0%'});
3061
+is_deeply($param, {"$table1.id" => 0, "$table1.author" => '%0%', "$table1.price" => '%0%'});
3050 3062
 
3051 3063
 $param = $dbi->map_param(
3052 3064
     {id => '', author => '', price => ''},
3053
-    id => 'table1.id',
3054
-    author => ['table1.author', sub { '%' . $_[0] . '%' }],
3055
-    price => ['table1.price', sub { '%' . $_[0] . '%' },
3065
+    id => '$table1.id',
3066
+    author => ['$table1.author', sub { '%' . $_[0] . '%' }],
3067
+    price => ['$table1.price', sub { '%' . $_[0] . '%' },
3056 3068
       {if => sub { $_[0] eq 1 }}]
3057 3069
 );
3058 3070
 is_deeply($param, {});
3059 3071
 
3060 3072
 $param = $dbi->map_param(
3061 3073
     {id => undef, author => undef, price => undef},
3062
-    id => 'table1.id',
3063
-    price => ['table1.price', {if => 'exists'}]
3074
+    id => '$table1.id',
3075
+    price => ['$table1.price', {if => 'exists'}]
3064 3076
 );
3065
-is_deeply($param, {'table1.price' => undef});
3077
+is_deeply($param, {'$table1.price' => undef});
3066 3078
 
3067 3079
 $param = $dbi->map_param(
3068 3080
     {price => 'a'},
3069
-    id => ['table1.id', {if => 'exists'}],
3070
-    price => ['table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
3081
+    id => ['$table1.id', {if => 'exists'}],
3082
+    price => ['$table1.price', sub { '%' . $_[0] }, {if => 'exists'}]
3071 3083
 );
3072
-is_deeply($param, {'table1.price' => '%a'});
3084
+is_deeply($param, {'$table1.price' => '%a'});
3073 3085
 
3074 3086
 test 'order';
3075 3087
 $dbi = DBIx::Custom->connect;
3076
-eval { $dbi->execute('drop table table1') };
3088
+eval { $dbi->execute('drop table $table1') };
3077 3089
 $dbi->execute($create_table1);
3078
-$dbi->insert({key1 => 1, key2 => 1}, table => 'table1');
3079
-$dbi->insert({key1 => 1, key2 => 3}, table => 'table1');
3080
-$dbi->insert({key1 => 2, key2 => 2}, table => 'table1');
3081
-$dbi->insert({key1 => 2, key2 => 4}, table => 'table1');
3090
+$dbi->insert({$key1 => 1, $key2 => 1}, table => $table1);
3091
+$dbi->insert({$key1 => 1, $key2 => 3}, table => $table1);
3092
+$dbi->insert({$key1 => 2, $key2 => 2}, table => $table1);
3093
+$dbi->insert({$key1 => 2, $key2 => 4}, table => $table1);
3082 3094
 my $order = $dbi->order;
3083
-$order->prepend('key1', 'key2 desc');
3084
-$result = $dbi->select(table => 'table1', append => "$order");
3085
-is_deeply($result->all, [{key1 => 1, key2 => 3}, {key1 => 1, key2 => 1},
3086
-  {key1 => 2, key2 => 4}, {key1 => 2, key2 => 2}]);
3087
-$order->prepend('key1 desc');
3088
-$result = $dbi->select(table => 'table1', append => "$order");
3089
-is_deeply($result->all, [{key1 => 2, key2 => 4}, {key1 => 2, key2 => 2},
3090
-  {key1 => 1, key2 => 3}, {key1 => 1, key2 => 1}]);
3095
+$order->prepend($key1, '$key2 desc');
3096
+$result = $dbi->select(table => $table1, append => "$order");
3097
+is_deeply($result->all, [{$key1 => 1, $key2 => 3}, {$key1 => 1, $key2 => 1},
3098
+  {$key1 => 2, $key2 => 4}, {$key1 => 2, $key2 => 2}]);
3099
+$order->prepend('$key1 desc');
3100
+$result = $dbi->select(table => $table1, append => "$order");
3101
+is_deeply($result->all, [{$key1 => 2, $key2 => 4}, {$key1 => 2, $key2 => 2},
3102
+  {$key1 => 1, $key2 => 3}, {$key1 => 1, $key2 => 1}]);
3091 3103
 
3092 3104
 $order = $dbi->order;
3093
-$order->prepend(['table1-key1'], [qw/table1-key2 desc/]);
3094
-$result = $dbi->select(table => 'table1',
3095
-  column => [[key1 => 'table1-key1'], [key2 => 'table1-key2']],
3105
+$order->prepend(['$table1-$key1'], [qw/$table1-$key2 desc/]);
3106
+$result = $dbi->select(table => $table1,
3107
+  column => [[$key1 => "$table1-$key1"], [$key2 => "$table1-$key2"]],
3096 3108
   append => "$order");
3097
-is_deeply($result->all, [{'table1-key1' => 1, 'table1-key2' => 3},
3098
-  {'table1-key1' => 1, 'table1-key2' => 1},
3099
-  {'table1-key1' => 2, 'table1-key2' => 4},
3100
-  {'table1-key1' => 2, 'table1-key2' => 2}]);
3109
+is_deeply($result->all, [{"$table1-$key1" => 1, "$table1-$key2" => 3},
3110
+  {"$table1-$key1" => 1, "$table1-$key2" => 1},
3111
+  {"$table1-$key1" => 2, "$table1-$key2" => 4},
3112
+  {"$table1-$key1" => 2, "$table1-$key2" => 2}]);
3101 3113
 
3102 3114
 test 'tag_parse';
3103 3115
 $dbi = DBIx::Custom->connect;
3104 3116
 $dbi->tag_parse(0);
3105
-eval { $dbi->execute('drop table table1') };
3117
+eval { $dbi->execute('drop table $table1') };
3106 3118
 $dbi->execute($create_table1);
3107
-$dbi->insert({key1 => 1, key2 => 1}, table => 'table1');
3108
-eval {$dbi->execute("select * from table1 where {= key1}", {key1 => 1})};
3119
+$dbi->insert({$key1 => 1, $key2 => 1}, table => $table1);
3120
+eval {$dbi->execute("select * from $table1 where {= $key1}", {$key1 => 1})};
3109 3121
 ok($@);
3110 3122
 
3111 3123
 test 'last_sql';
3112 3124
 $dbi = DBIx::Custom->connect;
3113
-eval { $dbi->execute('drop table table1') };
3125
+eval { $dbi->execute('drop table $table1') };
3114 3126
 $dbi->execute($create_table1);
3115
-$dbi->execute('select * from table1');
3116
-is($dbi->last_sql, 'select * from table1;');
3127
+$dbi->execute('select * from $table1');
3128
+is($dbi->last_sql, "select * from $table1;");
3117 3129
 
3118 3130
 eval{$dbi->execute("aaa")};
3119 3131
 is($dbi->last_sql, 'aaa;');
3120 3132
 
3121 3133
 test 'DBIx::Custom header';
3122 3134
 $dbi = DBIx::Custom->connect;
3123
-eval { $dbi->execute('drop table table1') };
3135
+eval { $dbi->execute('drop table $table1') };
3124 3136
 $dbi->execute($create_table1);
3125
-$result = $dbi->execute('select key1 as h1, key2 as h2 from table1');
3137
+$result = $dbi->execute("select $key1 as h1, $key2 as h2 from $table1");
3126 3138
 is_deeply($result->header, [qw/h1 h2/]);
3127 3139
 
3128 3140
 test 'Named placeholder :name(operater) syntax';
3129
-$dbi->execute('drop table table1');
3141
+$dbi->execute('drop table $table1');
3130 3142
 $dbi->execute($create_table1_2);
3131
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
3132
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
3143
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
3144
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
3133 3145
 
3134
-$source = "select * from table1 where :key1{=} and :key2{=}";
3135
-$result = $dbi->execute($source, param => {key1 => 1, key2 => 2});
3146
+$source = "select * from $table1 where :${key1}{=} and :${key2}{=}";
3147
+$result = $dbi->execute($source, param => {$key1 => 1, $key2 => 2});
3136 3148
 $rows = $result->all;
3137
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
3149
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
3138 3150
 
3139
-$source = "select * from table1 where :key1{ = } and :key2{=}";
3140
-$result = $dbi->execute($source, param => {key1 => 1, key2 => 2});
3151
+$source = "select * from $table1 where :${key1}{ = } and :${key2}{=}";
3152
+$result = $dbi->execute($source, param => {$key1 => 1, $key2 => 2});
3141 3153
 $rows = $result->all;
3142
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
3154
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
3143 3155
 
3144
-$source = "select * from table1 where :key1{<} and :key2{=}";
3145
-$result = $dbi->execute($source, param => {key1 => 5, key2 => 2});
3156
+$source = "select * from $table1 where :${key1}{<} and :${key2}{=}";
3157
+$result = $dbi->execute($source, param => {$key1 => 5, $key2 => 2});
3146 3158
 $rows = $result->all;
3147
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
3159
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
3148 3160
 
3149
-$source = "select * from table1 where :table1.key1{=} and :table1.key2{=}";
3161
+$source = "select * from $table1 where :$table1.${key1}{=} and :$table1.${key2}{=}";
3150 3162
 $result = $dbi->execute(
3151 3163
     $source,
3152
-    param => {'table1.key1' => 1, 'table1.key2' => 1},
3153
-    filter => {'table1.key2' => sub { $_[0] * 2 }}
3164
+    param => {"$table1.$key1" => 1, "$table1.$key2" => 1},
3165
+    filter => {'$table1.$key2' => sub { $_[0] * 2 }}
3154 3166
 );
3155 3167
 $rows = $result->all;
3156
-is_deeply($rows, [{key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5}]);
3168
+is_deeply($rows, [{$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5}]);
3157 3169
 
3158 3170
 test 'high perfomance way';
3159
-$dbi->execute('drop table table1');
3171
+$dbi->execute('drop table $table1');
3160 3172
 $dbi->execute($create_table1_highperformance);
3161 3173
 $rows = [
3162
-    {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 7},
3163
-    {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 8},
3174
+    {$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 7},
3175
+    {$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 8},
3164 3176
 ];
3165 3177
 {
3166 3178
     my $query;
3167 3179
     foreach my $row (@$rows) {
3168
-      $query ||= $dbi->insert($row, table => 'table1', query => 1);
3169
-      $dbi->execute($query, $row, filter => {ab => sub { $_[0] * 2 }});
3180
+      $query ||= $dbi->insert($row, table => $table1, query => 1);
3181
+      $dbi->execute($query, $row, filter => {$key7 => sub { $_[0] * 2 }});
3170 3182
     }
3171
-    is_deeply($dbi->select(table => 'table1')->all,
3183
+    is_deeply($dbi->select(table => $table1)->all,
3172 3184
       [
3173
-          {ab => 2, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 7},
3174
-          {ab => 2, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 8},
3185
+          {$key7 => 2, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 7},
3186
+          {$key7 => 2, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 8},
3175 3187
       ]
3176 3188
     );
3177 3189
 }
3178 3190
 
3179
-$dbi->execute('drop table table1');
3191
+$dbi->execute('drop table $table1');
3180 3192
 $dbi->execute($create_table1_highperformance);
3181 3193
 $rows = [
3182
-    {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 7},
3183
-    {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 8},
3194
+    {$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 7},
3195
+    {$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 8},
3184 3196
 ];
3185 3197
 {
3186 3198
     my $query;
3187 3199
     my $sth;
3188 3200
     foreach my $row (@$rows) {
3189
-      $query ||= $dbi->insert($row, table => 'table1', query => 1);
3201
+      $query ||= $dbi->insert($row, table => $table1, query => 1);
3190 3202
       $sth ||= $query->sth;
3191 3203
       $sth->execute(map { $row->{$_} } sort keys %$row);
3192 3204
     }
3193
-    is_deeply($dbi->select(table => 'table1')->all,
3205
+    is_deeply($dbi->select(table => $table1)->all,
3194 3206
       [
3195
-          {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 7},
3196
-          {ab => 1, bc => 2, ik => 3, hi => 4, ui => 5, pq => 6, dc => 8},
3207
+          {$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 7},
3208
+          {$key7 => 1, $key6 => 2, $key5 => 3, $key4 => 4, $key3 => 5, $key2 => 6, $key1 => 8},
3197 3209
       ]
3198 3210
     );
3199 3211
 }
3200 3212
 
3201 3213
 test 'result';
3202 3214
 $dbi = DBIx::Custom->connect;
3203
-eval { $dbi->execute('drop table table1') };
3215
+eval { $dbi->execute('drop table $table1') };
3204 3216
 $dbi->execute($create_table1);
3205
-$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
3206
-$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
3217
+$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
3218
+$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1);
3207 3219
 
3208
-$result = $dbi->select(table => 'table1');
3220
+$result = $dbi->select(table => $table1);
3209 3221
 @rows = ();
3210 3222
 while (my $row = $result->fetch) {
3211 3223
     push @rows, [@$row];
3212 3224
 }
3213 3225
 is_deeply(\@rows, [[1, 2], [3, 4]]);
3214 3226
 
3215
-$result = $dbi->select(table => 'table1');
3227
+$result = $dbi->select(table => $table1);
3216 3228
 @rows = ();
3217 3229
 while (my $row = $result->fetch_hash) {
3218 3230
     push @rows, {%$row};
3219 3231
 }
3220
-is_deeply(\@rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
3232
+is_deeply(\@rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
3221 3233
 
3222 3234
 $dbi = DBIx::Custom->connect;
3223
-eval { $dbi->execute('drop table table1') };
3235
+eval { $dbi->execute('drop table $table1') };
3224 3236
 $dbi->execute($create_table1);
3225
-$dbi->insert({key1 => 1, key2 => 2}, table => 'table1');
3226
-$dbi->insert({key1 => 3, key2 => 4}, table => 'table1');
3237
+$dbi->insert({$key1 => 1, $key2 => 2}, table => $table1);
3238
+$dbi->insert({$key1 => 3, $key2 => 4}, table => $table1);
3227 3239
 
3228 3240
 test 'fetch_all';
3229
-$result = $dbi->select(table => 'table1');
3241
+$result = $dbi->select(table => $table1);
3230 3242
 $rows = $result->fetch_all;
3231 3243
 is_deeply($rows, [[1, 2], [3, 4]]);
3232 3244
 
3233
-$result = $dbi->select(table => 'table1');
3245
+$result = $dbi->select(table => $table1);
3234 3246
 $rows = $result->fetch_hash_all;
3235
-is_deeply($rows, [{key1 => 1, key2 => 2}, {key1 => 3, key2 => 4}]);
3247
+is_deeply($rows, [{$key1 => 1, $key2 => 2}, {$key1 => 3, $key2 => 4}]);
3236 3248
 
3237
-$result = $dbi->select(table => 'table1');
3249
+$result = $dbi->select(table => $table1);
3238 3250
 $result->dbi->filters({three_times => sub { $_[0] * 3}});
3239
-$result->filter({key1 => 'three_times'});
3251
+$result->filter({$key1 => 'three_times'});
3240 3252
 
3241 3253
 $rows = $result->fetch_all;
3242 3254
 is_deeply($rows, [[3, 2], [9, 4]], "array");
3243 3255
 
3244
-$result = $dbi->select(table => 'table1');
3256
+$result = $dbi->select(table => $table1);
3245 3257
 $result->dbi->filters({three_times => sub { $_[0] * 3}});
3246
-$result->filter({key1 => 'three_times'});
3258
+$result->filter({$key1 => 'three_times'});
3247 3259
 $rows = $result->fetch_hash_all;
3248
-is_deeply($rows, [{key1 => 3, key2 => 2}, {key1 => 9, key2 => 4}], "hash");
3260
+is_deeply($rows, [{$key1 => 3, $key2 => 2}, {$key1 => 9, $key2 => 4}], "hash");
3249 3261
 
3250 3262
 test "query_builder";
3251 3263
 $datas = [
... ...
@@ -3391,21 +3403,21 @@ like($@, qr/unexpected "{"/, "error : 2");
3391 3403
 
3392 3404
 test 'select() wrap option';
3393 3405
 $dbi = DBIx::Custom->connect;
3394
-eval { $dbi->execute('drop table table1') };
3406
+eval { $dbi->execute('drop table $table1') };
3395 3407
 $dbi->execute($create_table1);
3396
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3397
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
3408
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3409
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
3398 3410
 $rows = $dbi->select(
3399
-    table => 'table1',
3400
-    column => 'key1',
3401
-    wrap => ['select * from (', ') as t where key1 = 1']
3411
+    table => $table1,
3412
+    column => $key1,
3413
+    wrap => ["select * from (', ') as t where $key1 = 1"]
3402 3414
 )->all;
3403
-is_deeply($rows, [{key1 => 1}]);
3415
+is_deeply($rows, [{$key1 => 1}]);
3404 3416
 
3405 3417
 eval {
3406 3418
 $dbi->select(
3407
-    table => 'table1',
3408
-    column => 'key1',
3419
+    table => $table1,
3420
+    column => $key1,
3409 3421
     wrap => 'select * from ('
3410 3422
 )
3411 3423
 };
... ...
@@ -3413,172 +3425,172 @@ like($@, qr/array/);
3413 3425
 
3414 3426
 test 'select() sqlfilter option';
3415 3427
 $dbi = DBIx::Custom->connect;
3416
-eval { $dbi->execute('drop table table1') };
3428
+eval { $dbi->execute('drop table $table1') };
3417 3429
 $dbi->execute($create_table1);
3418
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3419
-$dbi->insert(table => 'table1', param => {key1 => 2, key2 => 3});
3430
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3431
+$dbi->insert(table => $table1, param => {$key1 => 2, $key2 => 3});
3420 3432
 $rows = $dbi->select(
3421
-    table => 'table1',
3422
-    column => 'key1',
3433
+    table => $table1,
3434
+    column => $key1,
3423 3435
     sqlfilter => sub {
3424 3436
         my $sql = shift;
3425
-        $sql = "select * from ( $sql ) as t where key1 = 1";
3437
+        $sql = "select * from ( $sql ) as t where $key1 = 1";
3426 3438
         return $sql;
3427 3439
     }
3428 3440
 )->all;
3429
-is_deeply($rows, [{key1 => 1}]);
3441
+is_deeply($rows, [{$key1 => 1}]);
3430 3442
 
3431 3443
 test 'dbi method from model';
3432 3444
 $dbi = MyDBI9->connect;
3433
-eval { $dbi->execute('drop table table1') };
3445
+eval { $dbi->execute('drop table $table1') };
3434 3446
 $dbi->execute($create_table1);
3435 3447
 $dbi->setup_model;
3436
-$model = $dbi->model('table1');
3437
-eval{$model->execute('select * from table1')};
3448
+$model = $dbi->model($table1);
3449
+eval{$model->execute('select * from $table1')};
3438 3450
 ok(!$@);
3439 3451
 
3440 3452
 test 'column table option';
3441 3453
 $dbi = MyDBI9->connect;
3442
-eval { $dbi->execute('drop table table1') };
3454
+eval { $dbi->execute('drop table $table1') };
3443 3455
 $dbi->execute($create_table1);
3444
-eval { $dbi->execute('drop table table2') };
3456
+eval { $dbi->execute('drop table $table2') };
3445 3457
 $dbi->execute($create_table2);
3446 3458
 $dbi->setup_model;
3447
-$dbi->execute('insert into table1 (key1, key2) values (1, 2);');
3448
-$dbi->execute('insert into table2 (key1, key3) values (1, 4);');
3449
-$model = $dbi->model('table1');
3459
+$dbi->execute("insert into $table1 ($key1, $key2) values (1, 2);");
3460
+$dbi->execute("insert into $table2 ($key1, $key3) values (1, 4);");
3461
+$model = $dbi->model($table1);
3450 3462
 $result = $model->select(
3451 3463
     column => [
3452
-        $model->column('table2', {alias => 'table2_alias'})
3464
+        $model->column($table2, {alias => $table2_alias})
3453 3465
     ],
3454
-    where => {'table2_alias.key3' => 4}
3466
+    where => {"$table2_alias.$key3" => 4}
3455 3467
 );
3456 3468
 is_deeply($result->one, 
3457
-          {'table2_alias.key1' => 1, 'table2_alias.key3' => 4});
3469
+          {"$table2_alias.$key1" => 1, "$table2_alias.$key3" => 4});
3458 3470
 
3459 3471
 $dbi->separator('__');
3460 3472
 $result = $model->select(
3461 3473
     column => [
3462
-        $model->column('table2', {alias => 'table2_alias'})
3474
+        $model->column($table2, {alias => $table2_alias})
3463 3475
     ],
3464
-    where => {'table2_alias.key3' => 4}
3476
+    where => {"$table2_alias.$key3" => 4}
3465 3477
 );
3466 3478
 is_deeply($result->one, 
3467
-          {'table2_alias__key1' => 1, 'table2_alias__key3' => 4});
3479
+          {"${table2_alias}__$key1" => 1, "{$table2_alias}__$key3" => 4});
3468 3480
 
3469 3481
 $dbi->separator('-');
3470 3482
 $result = $model->select(
3471 3483
     column => [
3472
-        $model->column('table2', {alias => 'table2_alias'})
3484
+        $model->column($table2, {alias => $table2_alias})
3473 3485
     ],
3474
-    where => {'table2_alias.key3' => 4}
3486
+    where => {"$table2_alias.$key3" => 4}
3475 3487
 );
3476 3488
 is_deeply($result->one, 
3477
-          {'table2_alias-key1' => 1, 'table2_alias-key3' => 4});
3489
+          {"$table2_alias-$key1" => 1, "$table2_alias-$key3" => 4});
3478 3490
 
3479 3491
 test 'create_model';
3480 3492
 $dbi = DBIx::Custom->connect;
3481
-eval { $dbi->execute('drop table table1') };
3482
-eval { $dbi->execute('drop table table2') };
3493
+eval { $dbi->execute('drop table $table1') };
3494
+eval { $dbi->execute('drop table $table2') };
3483 3495
 $dbi->execute($create_table1);
3484 3496
 $dbi->execute($create_table2);
3485 3497
 
3486 3498
 $dbi->create_model(
3487
-    table => 'table1',
3499
+    table => $table1,
3488 3500
     join => [
3489
-       'left outer join table2 on table1.key1 = table2.key1'
3501
+       "left outer join $table2 on $table1.$key1 = $table2.$key1"
3490 3502
     ],
3491
-    primary_key => ['key1']
3503
+    primary_key => [$key1]
3492 3504
 );
3493 3505
 $model2 = $dbi->create_model(
3494
-    table => 'table2'
3506
+    table => $table2
3495 3507
 );
3496 3508
 $dbi->create_model(
3497
-    table => 'table3',
3509
+    table => $table3,
3498 3510
     filter => [
3499
-        key1 => {in => sub { uc $_[0] }}
3511
+        $key1 => {in => sub { uc $_[0] }}
3500 3512
     ]
3501 3513
 );
3502 3514
 $dbi->setup_model;
3503
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3504
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
3505
-$model = $dbi->model('table1');
3515
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3516
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
3517
+$model = $dbi->model($table1);
3506 3518
 $result = $model->select(
3507
-    column => [$model->mycolumn, $model->column('table2')],
3508
-    where => {'table1.key1' => 1}
3519
+    column => [$model->mycolumn, $model->column($table2)],
3520
+    where => {'$table1.$key1' => 1}
3509 3521
 );
3510 3522
 is_deeply($result->one,
3511
-          {key1 => 1, key2 => 2, 'table2.key1' => 1, 'table2.key3' => 3});
3512
-is_deeply($model2->select->one, {key1 => 1, key3 => 3});
3523
+          {$key1 => 1, $key2 => 2, "$table2.$key1" => 1, "$table2.$key3" => 3});
3524
+is_deeply($model2->select->one, {$key1 => 1, $key3 => 3});
3513 3525
 
3514 3526
 test 'model method';
3515 3527
 $dbi = DBIx::Custom->connect;
3516
-eval { $dbi->execute('drop table table2') };
3528
+eval { $dbi->execute('drop table $table2') };
3517 3529
 $dbi->execute($create_table2);
3518
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 3});
3530
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 3});
3519 3531
 $model = $dbi->create_model(
3520
-    table => 'table2'
3532
+    table => $table2
3521 3533
 );
3522 3534
 $model->method(foo => sub { shift->select(@_) });
3523
-is_deeply($model->foo->one, {key1 => 1, key3 => 3});
3535
+is_deeply($model->foo->one, {$key1 => 1, $key3 => 3});
3524 3536
 
3525 3537
 test 'update_param';
3526 3538
 $dbi = DBIx::Custom->connect;
3527
-eval { $dbi->execute('drop table table1') };
3539
+eval { $dbi->execute('drop table $table1') };
3528 3540
 $dbi->execute($create_table1_2);
3529
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
3530
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
3541
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
3542
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
3531 3543
 
3532
-$param = {key2 => 11};
3544
+$param = {$key2 => 11};
3533 3545
 $update_param = $dbi->update_param($param);
3534 3546
 $sql = <<"EOS";
3535
-update table1 $update_param
3536
-where key1 = 1
3547
+update $table1 $update_param
3548
+where $key1 = 1
3537 3549
 EOS
3538 3550
 $dbi->execute($sql, param => $param);
3539
-$result = $dbi->execute('select * from table1 order by key1;', table => 'table1');
3551
+$result = $dbi->execute("select * from $table1 order by $key1;", table => $table1);
3540 3552
 $rows   = $result->all;
3541
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
3542
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
3553
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
3554
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
3543 3555
                   "basic");
3544 3556
 
3545 3557
 
3546 3558
 $dbi = DBIx::Custom->connect;
3547
-eval { $dbi->execute('drop table table1') };
3559
+eval { $dbi->execute('drop table $table1') };
3548 3560
 $dbi->execute($create_table1_2);
3549
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
3550
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
3561
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
3562
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
3551 3563
 
3552
-$param = {key2 => 11, key3 => 33};
3564
+$param = {$key2 => 11, $key3 => 33};
3553 3565
 $update_param = $dbi->update_param($param);
3554 3566
 $sql = <<"EOS";
3555
-update table1 $update_param
3556
-where key1 = 1
3567
+update $table1 $update_param
3568
+where $key1 = 1
3557 3569
 EOS
3558 3570
 $dbi->execute($sql, param => $param);
3559
-$result = $dbi->execute('select * from table1 order by key1;', table => 'table1');
3571
+$result = $dbi->execute("select * from $table1 order by $key1;", table => $table1);
3560 3572
 $rows   = $result->all;
3561
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
3562
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
3573
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 33, $key4 => 4, $key5 => 5},
3574
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
3563 3575
                   "basic");
3564 3576
 
3565 3577
 $dbi = DBIx::Custom->connect;
3566
-eval { $dbi->execute('drop table table1') };
3578
+eval { $dbi->execute('drop table $table1') };
3567 3579
 $dbi->execute($create_table1_2);
3568
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
3569
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
3580
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
3581
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
3570 3582
 
3571
-$param = {key2 => 11, key3 => 33};
3583
+$param = {$key2 => 11, $key3 => 33};
3572 3584
 $update_param = $dbi->update_param($param, {no_set => 1});
3573 3585
 $sql = <<"EOS";
3574
-update table1 set $update_param
3575
-where key1 = 1
3586
+update $table1 set $update_param
3587
+where $key1 = 1
3576 3588
 EOS
3577 3589
 $dbi->execute($sql, param => $param);
3578
-$result = $dbi->execute('select * from table1 order by key1;', table => 'table1');
3590
+$result = $dbi->execute("select * from $table1 order by $key1;", table => $table1);
3579 3591
 $rows   = $result->all;
3580
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 33, key4 => 4, key5 => 5},
3581
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
3592
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 33, $key4 => 4, $key5 => 5},
3593
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
3582 3594
                   "update param no_set");
3583 3595
 
3584 3596
             
... ...
@@ -3588,242 +3600,242 @@ like($@, qr/not safety/);
3588 3600
 
3589 3601
 test 'update_param';
3590 3602
 $dbi = DBIx::Custom->connect;
3591
-eval { $dbi->execute('drop table table1') };
3603
+eval { $dbi->execute('drop table $table1') };
3592 3604
 $dbi->execute($create_table1_2);
3593
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2, key3 => 3, key4 => 4, key5 => 5});
3594
-$dbi->insert(table => 'table1', param => {key1 => 6, key2 => 7, key3 => 8, key4 => 9, key5 => 10});
3605
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2, $key3 => 3, $key4 => 4, $key5 => 5});
3606
+$dbi->insert(table => $table1, param => {$key1 => 6, $key2 => 7, $key3 => 8, $key4 => 9, $key5 => 10});
3595 3607
 
3596
-$param = {key2 => 11};
3608
+$param = {$key2 => 11};
3597 3609
 $update_param = $dbi->assign_param($param);
3598 3610
 $sql = <<"EOS";
3599
-update table1 set $update_param
3600
-where key1 = 1
3611
+update $table1 set $update_param
3612
+where $key1 = 1
3601 3613
 EOS
3602
-$dbi->execute($sql, param => $param, table => 'table1');
3603
-$result = $dbi->execute('select * from table1 order by key1;');
3614
+$dbi->execute($sql, param => $param, table => $table1);
3615
+$result = $dbi->execute("select * from $table1 order by $key1;");
3604 3616
 $rows   = $result->all;
3605
-is_deeply($rows, [{key1 => 1, key2 => 11, key3 => 3, key4 => 4, key5 => 5},
3606
-                  {key1 => 6, key2 => 7,  key3 => 8, key4 => 9, key5 => 10}],
3617
+is_deeply($rows, [{$key1 => 1, $key2 => 11, $key3 => 3, $key4 => 4, $key5 => 5},
3618
+                  {$key1 => 6, $key2 => 7,  $key3 => 8, $key4 => 9, $key5 => 10}],
3607 3619
                   "basic");
3608 3620
 
3609 3621
 test 'join';
3610 3622
 $dbi = DBIx::Custom->connect;
3611
-eval { $dbi->execute('drop table table1') };
3623
+eval { $dbi->execute('drop table $table1') };
3612 3624
 $dbi->execute($create_table1);
3613
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3614
-$dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
3615
-eval { $dbi->execute('drop table table2') };
3625
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3626
+$dbi->insert(table => $table1, param => {$key1 => 3, $key2 => 4});
3627
+eval { $dbi->execute('drop table $table2') };
3616 3628
 $dbi->execute($create_table2);
3617
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
3618
-eval { $dbi->execute('drop table table3') };
3619
-$dbi->execute('create table table3 (key3 int, key4 int);');
3620
-$dbi->insert(table => 'table3', param => {key3 => 5, key4 => 4});
3629
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
3630
+eval { $dbi->execute('drop table $table3') };
3631
+$dbi->execute("create table $table3 ($key3 int, $key4 int);");
3632
+$dbi->insert(table => $table3, param => {$key3 => 5, $key4 => 4});
3621 3633
 $rows = $dbi->select(
3622
-    table => 'table1',
3623
-    column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3',
3624
-    where   => {'table1.key2' => 2},
3625
-    join  => ['left outer join table2 on table1.key1 = table2.key1']
3634
+    table => $table1,
3635
+    column => "$table1.$key1 as ${table1}_$key1, $table2.$key1 as ${table2}_$key1, $key2, $key3",
3636
+    where   => {"$table1.$key2" => 2},
3637
+    join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1"]
3626 3638
 )->all;
3627
-is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}]);
3639
+is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}]);
3628 3640
 
3629 3641
 $rows = $dbi->select(
3630
-    table => 'table1',
3631
-    where   => {'key1' => 1},
3632
-    join  => ['left outer join table2 on table1.key1 = table2.key1']
3642
+    table => $table1,
3643
+    where   => {$key1 => 1},
3644
+    join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1"]
3633 3645
 )->all;
3634
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
3646
+is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
3635 3647
 
3636 3648
 eval {
3637 3649
     $rows = $dbi->select(
3638
-        table => 'table1',
3639
-        column => 'table1.key1 as table1_key1, table2.key1 as table2_key1, key2, key3',
3640
-        where   => {'table1.key2' => 2},
3641
-        join  => {'table1.key1' => 'table2.key1'}
3650
+        table => $table1,
3651
+        column => "$table1.$key1 as ${table1}_$key1, $table2.$key1 as ${table2}_$key1, $key2, $key3",
3652
+        where   => {'$table1.$key2' => 2},
3653
+        join  => {"$table1.$key1" => "$table2.$key1"}
3642 3654
     );
3643 3655
 };
3644 3656
 like ($@, qr/array/);
3645 3657
 
3646 3658
 $rows = $dbi->select(
3647
-    table => 'table1',
3648
-    where   => {'key1' => 1},
3649
-    join  => ['left outer join table2 on table1.key1 = table2.key1',
3650
-              'left outer join table3 on table2.key3 = table3.key3']
3659
+    table => $table1,
3660
+    where   => {$key1 => 1},
3661
+    join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
3662
+              "left outer join $table3 on $table2.$key3 = $table3.$key3"]
3651 3663
 )->all;
3652
-is_deeply($rows, [{key1 => 1, key2 => 2}]);
3664
+is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
3653 3665
 
3654 3666
 $rows = $dbi->select(
3655
-    column => 'table3.key4 as table3__key4',
3656
-    table => 'table1',
3657
-    where   => {'table1.key1' => 1},
3658
-    join  => ['left outer join table2 on table1.key1 = table2.key1',
3659
-              'left outer join table3 on table2.key3 = table3.key3']
3667
+    column => "$table3.$key4 as ${table3}__$key4",
3668
+    table => $table1,
3669
+    where   => {'$table1.$key1' => 1},
3670
+    join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
3671
+              "left outer join $table3 on $table2.$key3 = $table3.$key3"]
3660 3672
 )->all;
3661
-is_deeply($rows, [{table3__key4 => 4}]);
3673
+is_deeply($rows, [{"${table3}__$key4" => 4}]);
3662 3674
 
3663 3675
 $rows = $dbi->select(
3664
-    column => 'table1.key1 as table1__key1',
3665
-    table => 'table1',
3666
-    where   => {'table3.key4' => 4},
3667
-    join  => ['left outer join table2 on table1.key1 = table2.key1',
3668
-              'left outer join table3 on table2.key3 = table3.key3']
3676
+    column => "$table1.$key1 as ${table1}__$key1",
3677
+    table => $table1,
3678
+    where   => {'$table3.$key4' => 4},
3679
+    join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
3680
+              "left outer join $table3 on $table2.$key3 = $table3.$key3"]
3669 3681
 )->all;
3670
-is_deeply($rows, [{table1__key1 => 1}]);
3682
+is_deeply($rows, [{"${table1}__$key1" => 1}]);
3671 3683
 
3672 3684
 $dbi = DBIx::Custom->connect;
3673
-eval { $dbi->execute('drop table table1') };
3685
+eval { $dbi->execute('drop table $table1') };
3674 3686
 $dbi->execute($create_table1);
3675
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3676
-eval { $dbi->execute('drop table table2') };
3687
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3688
+eval { $dbi->execute('drop table $table2') };
3677 3689
 $dbi->execute($create_table2);
3678
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
3690
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
3679 3691
 $rows = $dbi->select(
3680
-    table => 'table1',
3681
-    column => "${q}table1$p.${q}key1$p as ${q}table1_key1$p, ${q}table2$p.${q}key1$p as ${q}table2_key1$p, ${q}key2$p, ${q}key3$p",
3682
-    where   => {'table1.key2' => 2},
3683
-    join  => ["left outer join ${q}table2$p on ${q}table1$p.${q}key1$p = ${q}table2$p.${q}key1$p"],
3692
+    table => $table1,
3693
+    column => "${q}$table1$p.${q}$key1$p as ${q}${table1}_$key1$p, ${q}$table2$p.${q}$key1$p as ${q}${table2}_$key1$p, ${q}$key2$p, ${q}$key3$p",
3694
+    where   => {"$table1.$key2" => 2},
3695
+    join  => ["left outer join ${q}$table2$p on ${q}$table1$p.${q}$key1$p = ${q}$table2$p.${q}$key1$p"],
3684 3696
 )->all;
3685
-is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
3697
+is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}],
3686 3698
           'quote');
3687 3699
 
3688 3700
 
3689 3701
 $dbi = DBIx::Custom->connect;
3690
-eval { $dbi->execute('drop table table1') };
3702
+eval { $dbi->execute('drop table $table1') };
3691 3703
 $dbi->execute($create_table1);
3692
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3704
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3693 3705
 $sql = <<"EOS";
3694 3706
 left outer join (
3695
-  select * from table1 as t1
3696
-  where t1.key2 = (
3697
-    select max(t2.key2) from table1 as t2
3698
-    where t1.key1 = t2.key1
3707
+  select * from $table1 as t1
3708
+  where t1.$key2 = (
3709
+    select max(t2.$key2) from $table1 as t2
3710
+    where t1.$key1 = t2.$key1
3699 3711
   )
3700
-) as latest_table1 on table1.key1 = latest_table1.key1
3712
+) as latest_$table1 on $table1.$key1 = latest_$table1.$key1
3701 3713
 EOS
3702 3714
 $join = [$sql];
3703 3715
 $rows = $dbi->select(
3704
-    table => 'table1',
3705
-    column => 'latest_table1.key1 as latest_table1__key1',
3716
+    table => $table1,
3717
+    column => "latest_$table1.$key1 as latest_${table1}__$key1",
3706 3718
     join  => $join
3707 3719
 )->all;
3708
-is_deeply($rows, [{latest_table1__key1 => 1}]);
3720
+is_deeply($rows, [{"latest_${table1}__$key1" => 1}]);
3709 3721
 
3710 3722
 $dbi = DBIx::Custom->connect;
3711
-eval { $dbi->execute('drop table table1') };
3712
-eval { $dbi->execute('drop table table2') };
3723
+eval { $dbi->execute('drop table $table1') };
3724
+eval { $dbi->execute('drop table $table2') };
3713 3725
 $dbi->execute($create_table1);
3714 3726
 $dbi->execute($create_table2);
3715
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3716
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
3717
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
3727
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3728
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 4});
3729
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
3718 3730
 $result = $dbi->select(
3719
-    table => 'table1',
3731
+    table => $table1,
3720 3732
     join => [
3721
-        "left outer join table2 on table2.key2 = '4' and table1.key1 = table2.key1"
3733
+        "left outer join $table2 on $table2.$key2 = '4' and $table1.$key1 = $table2.$key1"
3722 3734
     ]
3723 3735
 );
3724
-is_deeply($result->all, [{key1 => 1, key2 => 2}]);
3736
+is_deeply($result->all, [{$key1 => 1, $key2 => 2}]);
3725 3737
 $result = $dbi->select(
3726
-    table => 'table1',
3727
-    column => [{table2 => ['key3']}],
3738
+    table => $table1,
3739
+    column => [{$table2 => [$key3]}],
3728 3740
     join => [
3729
-        "left outer join table2 on table2.key3 = '4' and table1.key1 = table2.key1"
3741
+        "left outer join $table2 on $table2.$key3 = '4' and $table1.$key1 = $table2.$key1"
3730 3742
     ]
3731 3743
 );
3732
-is_deeply($result->all, [{'table2.key3' => 4}]);
3744
+is_deeply($result->all, [{'$table2.$key3' => 4}]);
3733 3745
 $result = $dbi->select(
3734
-    table => 'table1',
3735
-    column => [{table2 => ['key3']}],
3746
+    table => $table1,
3747
+    column => [{$table2 => [$key3]}],
3736 3748
     join => [
3737
-        "left outer join table2 on table1.key1 = table2.key1 and table2.key3 = '4'"
3749
+        "left outer join $table2 on $table1.$key1 = $table2.$key1 and $table2.$key3 = '4'"
3738 3750
     ]
3739 3751
 );
3740
-is_deeply($result->all, [{'table2.key3' => 4}]);
3752
+is_deeply($result->all, [{'$table2.$key3' => 4}]);
3741 3753
 
3742 3754
 $dbi = DBIx::Custom->connect;
3743
-eval { $dbi->execute('drop table table1') };
3744
-eval { $dbi->execute('drop table table2') };
3755
+eval { $dbi->execute('drop table $table1') };
3756
+eval { $dbi->execute('drop table $table2') };
3745 3757
 $dbi->execute($create_table1);
3746 3758
 $dbi->execute($create_table2);
3747
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
3748
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 4});
3749
-$dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
3759
+$dbi->insert(table => $table1, param => {$key1 => 1, $key2 => 2});
3760
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 4});
3761
+$dbi->insert(table => $table2, param => {$key1 => 1, $key3 => 5});
3750 3762
 $result = $dbi->select(
3751
-    table => 'table1',
3752
-    column => [{table2 => ['key3']}],
3763
+    table => $table1,
3764
+    column => [{$table2 => [$key3]}],
3753 3765
     join => [
3754 3766
         {
3755
-            clause => "left outer join table2 on table2.key3 = '4' and table1.key1 = table2.key1",
3756
-            table => ['table1', 'table2']
3767
+            clause => "left outer join $table2 on $table2.$key3 = '4' and $table1.$key1 = $table2.$key1",
3768
+            table => [$table1, $table2]
3757 3769
         }
3758 3770
     ]
3759 3771
 );
3760
-is_deeply($result->all, [{'table2.key3' => 4}]);
3772
+is_deeply($result->all, [{"$table2.$key3" => 4}]);
3761 3773
 
3762 3774
 test 'Model class';
3763 3775
 use MyDBI1;
3764 3776
 $dbi = MyDBI1->connect;
3765
-eval { $dbi->execute('drop table table1') };
3777
+eval { $dbi->execute('drop table $table1') };
3766 3778
 $dbi->execute($create_table1);
3767
-$model = $dbi->model('table1');
3768
-$model->insert({key1 => 'a', key2 => 'b'});
3769
-is_deeply($model->list->all, [{key1 => 'a', key2 => 'b'}], 'basic');
3770
-eval { $dbi->execute('drop table table2') };
3779
+$model = $dbi->model($table1);
3780
+$model->insert({$key1 => 'a', $key2 => 'b'});
3781
+is_deeply($model->list->all, [{$key1 => 'a', $key2 => 'b'}], 'basic');
3782
+eval { $dbi->execute('drop table $table2') };
3771 3783
 $dbi->execute($create_table2);
3772
-$model = $dbi->model('table2');
3773
-$model->insert({key1 => 'a'});
3774
-is_deeply($model->list->all, [{key1 => 'a', key3 => undef}], 'basic');
3775
-is($dbi->models->{'table1'}, $dbi->model('table1'));
3776
-is($dbi->models->{'table2'}, $dbi->model('table2'));
3784
+$model = $dbi->model($table2);
3785
+$model->insert({$key1 => 'a'});
3786
+is_deeply($model->list->all, [{$key1 => 'a', $key3 => undef}], 'basic');
3787
+is($dbi->models->{$table1}, $dbi->model($table1));
3788
+is($dbi->models->{$table2}, $dbi->model($table2));
3777 3789
 
3778 3790
 $dbi = MyDBI4->connect;
3779
-eval { $dbi->execute('drop table table1') };
3791
+eval { $dbi->execute('drop table $table1') };
3780 3792
 $dbi->execute($create_table1);
3781
-$model = $dbi->model('table1');
3782
-$model->insert({key1 => 'a', key2 => 'b'});
3783
-is_deeply($model->list->all, [{key1 => 'a', key2 => 'b'}], 'basic');
3784
-eval { $dbi->execute('drop table table2') };
3793
+$model = $dbi->model($table1);
3794
+$model->insert({$key1 => 'a', $key2 => 'b'});
3795
+is_deeply($model->list->all, [{$key1 => 'a', $key2 => 'b'}], 'basic');
3796
+eval { $dbi->execute('drop table $table2') };
3785 3797
 $dbi->execute($create_table2);
3786
-$model = $dbi->model('table2');
3787
-$model->insert({key1 => 'a'});
3788
-is_deeply($model->list->all, [{key1 => 'a', key3 => undef}], 'basic');
3798
+$model = $dbi->model($table2);
3799
+$model->insert({$key1 => 'a'});
3800
+is_deeply($model->list->all, [{$key1 => 'a', $key3 => undef}], 'basic');
3789 3801
 
3790 3802
 $dbi = MyDBI5->connect;
3791
-eval { $dbi->execute('drop table table1') };
3792
-eval { $dbi->execute('drop table table2') };
3803
+eval { $dbi->execute('drop table $table1') };
3804
+eval { $dbi->execute('drop table $table2') };
3793 3805
 $dbi->execute($create_table1);
3794 3806
 $dbi->execute($create_table2);
3795
-$model = $dbi->model('table2');
3796
-$model->insert({key1 => 'a'});
3797
-is_deeply($model->list->all, [{key1 => 'a', key3 => undef}], 'include all model');
3798
-$dbi->insert(table => 'table1', param => {key1 => 1});
3799
-$model = $dbi->model('table1');
3800
-is_deeply($model->list->all, [{key1 => 1, key2 => undef}], 'include all model');
3807
+$model = $dbi->model($table2);
3808
+$model->insert({$key1 => 'a'});
3809
+is_deeply($model->list->all, [{$key1 => 'a', $key3 => undef}], 'include all model');
3810
+$dbi->insert(table => $table1, param => {$key1 => 1});
3811
+$model = $dbi->model($table1);
3812
+is_deeply($model->list->all, [{$key1 => 1, $key2 => undef}], 'include all model');
3801 3813
 
3802 3814
 test 'primary_key';
3803 3815
 use MyDBI1;
3804 3816
 $dbi = MyDBI1->connect;
3805
-$model = $dbi->model('table1');
3806
-$model->primary_key(['key1', 'key2']);
3807
-is_deeply($model->primary_key, ['key1', 'key2']);
3817
+$model = $dbi->model($table1);
3818
+$model->primary_key([$key1, $key2]);
3819
+is_deeply($model->primary_key, [$key1, $key2]);
3808 3820
 
3809 3821
 test 'columns';
3810 3822
 use MyDBI1;
3811 3823
 $dbi = MyDBI1->connect;
3812
-$model = $dbi->model('table1');
3813
-$model->columns(['key1', 'key2']);
3814
-is_deeply($model->columns, ['key1', 'key2']);
3824
+$model = $dbi->model($table1);
3825
+$model->columns([$key1, $key2]);
3826
+is_deeply($model->columns, [$key1, $key2]);
3815 3827
 
3816 3828
 test 'setup_model';
3817 3829
 use MyDBI1;
3818 3830
 $dbi = MyDBI1->connect;
3819
-eval { $dbi->execute('drop table table1') };
3820
-eval { $dbi->execute('drop table table2') };
3831
+eval { $dbi->execute('drop table $table1') };
3832
+eval { $dbi->execute('drop table $table2') };
3821 3833
 
3822 3834
 $dbi->execute($create_table1);
3823 3835
 $dbi->execute($create_table2);
3824 3836
 $dbi->setup_model;
3825
-is_deeply([sort @{$dbi->model('table1')->columns}], ['key1', 'key2']);
3826
-is_deeply([sort @{$dbi->model('table2')->columns}], ['key1', 'key3']);
3837
+is_deeply([sort @{$dbi->model($table1)->columns}], [$key1, $key2]);
3838
+is_deeply([sort @{$dbi->model($table2)->columns}], [$key1, $key3]);
3827 3839
 
3828 3840
 
3829 3841