sub new {
my $self = shift->next::method(@_);
- # rebless to vendor-specific class if it exists and loads
- my $dbh = $self->schema->storage->dbh;
- my $driver = $dbh->{Driver}->{Name};
-
- my $subclass = 'DBIx::Class::Schema::Loader::DBI::' . $driver;
- if ($self->load_optional_class($subclass)) {
- bless $self, $subclass unless $self->isa($subclass);
- $self->_rebless;
+ # rebless to vendor-specific class if it exists and loads and we're not in a
+ # custom class.
+ if (not $self->loader_class) {
+ my $dbh = $self->schema->storage->dbh;
+ my $driver = $dbh->{Driver}->{Name};
+
+ my $subclass = 'DBIx::Class::Schema::Loader::DBI::' . $driver;
+ if ($self->load_optional_class($subclass)) {
+ bless $self, $subclass unless $self->isa($subclass);
+ $self->_rebless;
+ }
}
# Set up the default quoting character and name seperators
# Returns an array of table names
sub _tables_list {
- my $self = shift;
+ my ($self, $opts) = (shift, shift);
my ($table, $type) = @_ ? @_ : ('%', '%');
}
s/$qt//g for @tables;
- return $self->_filter_tables(@tables);
+ return $self->_filter_tables(\@tables, $opts);
}
-# ignore bad tables and views
+# apply constraint/exclude and ignore bad tables and views
sub _filter_tables {
- my ($self, @tables) = @_;
+ my ($self, $tables, $opts) = @_;
+ my @tables = @$tables;
my @filtered_tables;
+ $opts ||= {};
+ my $constraint = $opts->{constraint};
+ my $exclude = $opts->{exclude};
+
+ @tables = grep { /$constraint/ } @$tables if defined $constraint;
+ @tables = grep { ! /$exclude/ } @$tables if defined $exclude;
+
for my $table (@tables) {
eval {
my $sth = $self->_sth_for($table, undef, \'1 = 0');