Showing 2 changed files with 26 additions and 17 deletions
+3
lib/DBIx/Custom.pm
... ...
@@ -1212,8 +1212,11 @@ sub type_rule {
1212 1212
             $filter = $self->filters->{$fname};
1213 1213
           }
1214 1214
 
1215
+          my $database = $column_info->{TABLE_SCHEM};
1215 1216
           $self->{"_$into"}{key}{$table}{$column} = $filter;
1216 1217
           $self->{"_$into"}{dot}{"$table.$column"} = $filter;
1218
+          $self->{"_$into"}{key}{"$database.$table"}{$column} = $filter;
1219
+          $self->{"_$into"}{dot}{"$database.$table.$column"} = $filter;
1217 1220
         }
1218 1221
       });
1219 1222
     }
+23 -17
t/common.t
... ...
@@ -41,6 +41,12 @@ sub colon2 {
41 41
   return $value;
42 42
 }
43 43
 
44
+sub table_only {
45
+  my $value = shift;
46
+  $value =~ s/^.+\.//;
47
+  return $value;
48
+}
49
+
44 50
 # Constant
45 51
 my $table1 = $dbi->table1;
46 52
 my $table2 = $dbi->table2;
... ...
@@ -4187,10 +4193,10 @@ $dbi->each_column(sub {
4187 4193
 $infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos];
4188 4194
 is_deeply($infos, 
4189 4195
   [
4190
-    [$table1, $key1, $key1],
4191
-    [$table1, $key2, $key2],
4192
-    [$table2, $key1, $key1],
4193
-    [$table2, $key3, $key3]
4196
+    [table_only($table1), $key1, $key1],
4197
+    [table_only($table1), $key2, $key2],
4198
+    [table_only($table2), $key1, $key1],
4199
+    [table_only($table2), $key3, $key3]
4194 4200
   ]
4195 4201
   
4196 4202
 );
... ...
@@ -4214,8 +4220,8 @@ $dbi->each_table(sub {
4214 4220
 $infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos];
4215 4221
 is_deeply($infos, 
4216 4222
   [
4217
-    [$table1, $table1],
4218
-    [$table2, $table2],
4223
+    [table_only($table1), table_only($table1)],
4224
+    [table_only($table2), table_only($table2)],
4219 4225
   ]
4220 4226
 );
4221 4227
 
... ...
@@ -4238,9 +4244,9 @@ $dbi->each_table(sub {
4238 4244
 $infos = [sort { $a->[0] cmp $b->[0] || $a->[1] cmp $b->[1] } @$infos];
4239 4245
 is_deeply($infos, 
4240 4246
   [
4241
-    [$table1, $table1],
4242
-    [$table2, $table2],
4243
-    [$table3, $table3],
4247
+    [table_only($table1), table_only($table1)],
4248
+    [table_only($table2), table_only($table2)],
4249
+    [table_only($table3), table_only($table3)],
4244 4250
   ]
4245 4251
 );
4246 4252
 
... ...
@@ -4709,11 +4715,11 @@ $dbi->execute("create table $table3 ($key3 int, $key4 int)");
4709 4715
 $dbi->insert({$key3 => 5, $key4 => 4}, table => $table3);
4710 4716
 $rows = $dbi->select(
4711 4717
   table => $table1,
4712
-  column => "$table1.$key1 as ${table1}_$key1, $table2.$key1 as ${table2}_$key1, $key2, $key3",
4718
+  column => "$table1.$key1 as " . u("${table1}_$key1") . ", $table2.$key1 as " . u("${table2}_$key1") . ", $key2, $key3",
4713 4719
   where   => {"$table1.$key2" => 2},
4714 4720
   join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1"]
4715 4721
 )->all;
4716
-is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}]);
4722
+is_deeply($rows, [{u"${table1}_$key1" => 1, u"${table2}_$key1" => 1, $key2 => 2, $key3 => 5}]);
4717 4723
 
4718 4724
 $dbi = DBIx::Custom->connect;
4719 4725
 eval { $dbi->execute("drop table $table1") };
... ...
@@ -4728,14 +4734,14 @@ $dbi->execute("create table $table3 ($key3 int, $key4 int)");
4728 4734
 $dbi->insert({$key3 => 5, $key4 => 4}, table => $table3);
4729 4735
 $rows = $dbi->select(
4730 4736
   table => $table1,
4731
-  column => "$table1.$key1 as ${table1}_$key1, $table2.$key1 as ${table2}_$key1, $key2, $key3",
4737
+  column => "$table1.$key1 as " . u("${table1}_$key1") . ", $table2.$key1 as " . u("${table2}_$key1") . ", $key2, $key3",
4732 4738
   where   => {"$table1.$key2" => 2},
4733 4739
   join  => {
4734 4740
     clause => "left outer join $table2 on $table1.$key1 = $table2.$key1",
4735 4741
     table => [$table1, $table2]
4736 4742
   }
4737 4743
 )->all;
4738
-is_deeply($rows, [{"${table1}_$key1" => 1, "${table2}_$key1" => 1, $key2 => 2, $key3 => 5}]);
4744
+is_deeply($rows, [{u"${table1}_$key1" => 1, u"${table2}_$key1" => 1, $key2 => 2, $key3 => 5}]);
4739 4745
 
4740 4746
 $rows = $dbi->select(
4741 4747
   table => $table1,
... ...
@@ -4753,22 +4759,22 @@ $rows = $dbi->select(
4753 4759
 is_deeply($rows, [{$key1 => 1, $key2 => 2}]);
4754 4760
 
4755 4761
 $rows = $dbi->select(
4756
-  column => "$table3.$key4 as ${table3}__$key4",
4762
+  column => "$table3.$key4 as " . u2("${table3}__$key4"),
4757 4763
   table => $table1,
4758 4764
   where   => {"$table1.$key1" => 1},
4759 4765
   join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
4760 4766
             "left outer join $table3 on $table2.$key3 = $table3.$key3"]
4761 4767
 )->all;
4762
-is_deeply($rows, [{"${table3}__$key4" => 4}]);
4768
+is_deeply($rows, [{u2"${table3}__$key4" => 4}]);
4763 4769
 
4764 4770
 $rows = $dbi->select(
4765
-  column => "$table1.$key1 as ${table1}__$key1",
4771
+  column => "$table1.$key1 as " . u2("${table1}__$key1"),
4766 4772
   table => $table1,
4767 4773
   where   => {"$table3.$key4" => 4},
4768 4774
   join  => ["left outer join $table2 on $table1.$key1 = $table2.$key1",
4769 4775
             "left outer join $table3 on $table2.$key3 = $table3.$key3"]
4770 4776
 )->all;
4771
-is_deeply($rows, [{"${table1}__$key1" => 1}]);
4777
+is_deeply($rows, [{u2"${table1}__$key1" => 1}]);
4772 4778
 
4773 4779
 $dbi = DBIx::Custom->connect;
4774 4780
 eval { $dbi->execute("drop table $table1") };