Showing 1 changed files with 14 additions and 21 deletions
+14 -21
t/basic.t
... ...
@@ -19,12 +19,6 @@ BEGIN {
19 19
 $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /DEPRECATED/};
20 20
 sub test { print "# $_[0]\n" }
21 21
 
22
-# Constant varialbes for test
23
-my $CREATE_TABLE = {
24
-    3 => 'create table table1 (key1 Date, key2 datetime);',
25
-    4 => 'create table table3 (key3 int, key4 int);'
26
-};
27
-
28 22
 # Variables
29 23
 my $dbi;
30 24
 my $sth;
... ...
@@ -52,7 +46,6 @@ my $model2;
52 46
 my $where;
53 47
 my $update_param;
54 48
 my $insert_param;
55
-my $join;
56 49
 
57 50
 # Prepare table
58 51
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
... ...
@@ -2089,7 +2082,7 @@ $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2089 2082
 $dbi->insert(table => 'table1', param => {key1 => 3, key2 => 4});
2090 2083
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');
2091 2084
 $dbi->insert(table => 'table2', param => {key1 => 1, key3 => 5});
2092
-$dbi->execute($CREATE_TABLE->{4});
2085
+$dbi->execute('create table table3 (key3 int, key4 int);');
2093 2086
 $dbi->insert(table => 'table3', param => {key3 => 5, key4 => 4});
2094 2087
 $rows = $dbi->select(
2095 2088
     table => 'table1',
... ...
@@ -2170,11 +2163,11 @@ is_deeply($rows, [{table1_key1 => 1, table2_key1 => 1, key2 => 2, key3 => 5}],
2170 2163
         return $self;
2171 2164
     }
2172 2165
 }
2173
-
2174
-$dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2175
-$dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2176
-$dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2177
-$sql = <<"EOS";
2166
+{
2167
+    $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2168
+    $dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2169
+    $dbi->insert(table => 'table1', param => {key1 => 1, key2 => 2});
2170
+    $sql = <<"EOS";
2178 2171
 left outer join (
2179 2172
   select * from table1 as t1
2180 2173
   where t1.key2 = (
... ...
@@ -2183,14 +2176,14 @@ left outer join (
2183 2176
   )
2184 2177
 ) as latest_table1 on table1.key1 = latest_table1.key1
2185 2178
 EOS
2186
-$join = [$sql];
2187
-$rows = $dbi->select(
2188
-    table => 'table1',
2189
-    column => 'latest_table1.key1 as latest_table1__key1',
2190
-    join  => $join
2191
-)->all;
2192
-is_deeply($rows, [{latest_table1__key1 => 1}]);
2193
-
2179
+    my $join = [$sql];
2180
+    $rows = $dbi->select(
2181
+        table => 'table1',
2182
+        column => 'latest_table1.key1 as latest_table1__key1',
2183
+        join  => $join
2184
+    )->all;
2185
+    is_deeply($rows, [{latest_table1__key1 => 1}]);
2186
+}
2194 2187
 $dbi = DBIx::Custom->connect(dsn => 'dbi:SQLite:dbname=:memory:');
2195 2188
 $dbi->execute('create table table1 (key1 char(255), key2 char(255));');
2196 2189
 $dbi->execute('create table table2 (key1 char(255), key3 char(255));');