Showing 2 changed files with 19 additions and 6 deletions
+2 -1
Changes
... ...
@@ -1,5 +1,6 @@
1 1
 0.24
2
-  - support full-qualified table name.
2
+  - support full-qualified table name
3
+  - added EXPERIMENTAL default_schema attribute
3 4
 0.23
4 5
   - DBIx::Custom::Mapper::map method support
5 6
     {value => '%<value>%'} syntax
+17 -5
lib/DBIx/Custom.pm
... ...
@@ -20,7 +20,7 @@ use Encode qw/encode encode_utf8 decode_utf8/;
20 20
 use Scalar::Util qw/weaken/;
21 21
 
22 22
 
23
-has [qw/connector dsn password quote user exclude_table user_table_info
23
+has [qw/connector dsn default_schema password quote user exclude_table user_table_info
24 24
      user_column_info safety_character/],
25 25
   async_conf => sub { {} },
26 26
   cache => 0,
... ...
@@ -304,7 +304,6 @@ sub each_column {
304 304
     $self->each_table(sub {
305 305
       my ($dbi, $table, $table_info) = @_;
306 306
       my $schema = $table_info->{TABLE_SCHEM};
307
-      
308 307
       $tables->{$schema}{$table}++;
309 308
     });
310 309
 
... ...
@@ -317,7 +316,6 @@ sub each_column {
317 316
         eval {$sth_columns = $self->dbh->column_info(undef, $schema, $table, '%')};
318 317
         next if $@;
319 318
         while (my $column_info = $sth_columns->fetchrow_hashref) {
320
-          $DB::single = 1;
321 319
           my $column = $column_info->{COLUMN_NAME};
322 320
           $self->$cb($table, $column, $column_info);
323 321
         }
... ...
@@ -1219,8 +1217,12 @@ sub type_rule {
1219 1217
           }
1220 1218
           
1221 1219
           my $schema = $column_info->{TABLE_SCHEM};
1222
-          $self->{"_$into"}{key}{$table}{$column} = $filter;
1223
-          $self->{"_$into"}{dot}{"$table.$column"} = $filter;
1220
+          my $default_schema = $self->default_schema;
1221
+          if (!defined $default_schema || (defined $default_schema && $default_schema eq $schema)) {
1222
+            $self->{"_$into"}{key}{$table}{$column} = $filter;
1223
+            $self->{"_$into"}{dot}{"$table.$column"} = $filter;
1224
+          }
1225
+          
1224 1226
           $self->{"_$into"}{key}{"$schema.$table"}{$column} = $filter;
1225 1227
           $self->{"_$into"}{dot}{"$schema.$table.$column"} = $filter;
1226 1228
         }
... ...
@@ -2311,6 +2313,16 @@ L<DBIx::Connector> is automatically set to C<connector>
2311 2313
 
2312 2314
 Note that L<DBIx::Connector> must be installed.
2313 2315
 
2316
+=head2 C<default_schema> EXPERIMETNAL
2317
+
2318
+  my $default_schema = $self->default_schema;
2319
+  $dbi = $self->default_schema('public');
2320
+
2321
+schema name. if database has multiple schema,
2322
+type_rule->{into} filter don't work well.
2323
+
2324
+If you set C<default_schema>, type_rule->{into} filter work well.
2325
+
2314 2326
 =head2 C<dsn>
2315 2327
 
2316 2328
   my $dsn = $dbi->dsn;