=head1 SYNOPSIS
- ### use this module to generate a set of class files
-
- # in a script
- use DBIx::Class::Schema::Loader qw/ make_schema_at /;
- make_schema_at(
- 'My::Schema',
- { debug => 1,
- dump_directory => './lib',
- },
- [ 'dbi:Pg:dbname="foo"', 'myuser', 'mypassword',
- { loader_class => 'MyLoader' } # optionally
- ],
- );
-
- # from the command line or a shell script with dbicdump (distributed
- # with this module). Do `perldoc dbicdump` for usage.
- dbicdump -o dump_directory=./lib \
- -o components='["InflateColumn::DateTime"]' \
- -o debug=1 \
- My::Schema \
- 'dbi:Pg:dbname=foo' \
- myuser \
- mypassword
-
- ### or generate and load classes at runtime
- # note: this technique is not recommended
- # for use in production code
-
- package My::Schema;
- use base qw/DBIx::Class::Schema::Loader/;
-
- __PACKAGE__->loader_options(
- constraint => '^foo.*',
- # debug => 1,
- );
-
- #### in application code elsewhere:
-
- use My::Schema;
-
- my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs);
- # -or-
- my $schema1 = "My::Schema"; $schema1->connection(as above);
+ ### use this module to generate a set of class files
+
+ # in a script
+ use DBIx::Class::Schema::Loader qw/ make_schema_at /;
+ make_schema_at(
+ 'My::Schema',
+ { debug => 1,
+ dump_directory => './lib',
+ },
+ [ 'dbi:Pg:dbname="foo"', 'myuser', 'mypassword',
+ { loader_class => 'MyLoader' } # optionally
+ ],
+ );
+
+ # from the command line or a shell script with dbicdump (distributed
+ # with this module). Do `perldoc dbicdump` for usage.
+ dbicdump -o dump_directory=./lib \
+ -o components='["InflateColumn::DateTime"]' \
+ -o debug=1 \
+ My::Schema \
+ 'dbi:Pg:dbname=foo' \
+ myuser \
+ mypassword
+
+ ### or generate and load classes at runtime
+ # note: this technique is not recommended
+ # for use in production code
+
+ package My::Schema;
+ use base qw/DBIx::Class::Schema::Loader/;
+
+ __PACKAGE__->loader_options(
+ constraint => '^foo.*',
+ # debug => 1,
+ );
+
+ #### in application code elsewhere:
+
+ use My::Schema;
+
+ my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs);
+ # -or-
+ my $schema1 = "My::Schema"; $schema1->connection(as above);
=head1 DESCRIPTION
=cut
sub _rebless {
- my $self = shift;
-
- return if ref $self ne __PACKAGE__;
-
- my $dbh = $self->schema->storage->dbh;
- my $dbtype = eval { $dbh->get_info(17) };
- unless ( $@ ) {
- # Translate the backend name into a perl identifier
- $dbtype =~ s/\W/_/gi;
- my $class = "DBIx::Class::Schema::Loader::DBI::ADO::${dbtype}";
- if ($self->load_optional_class($class) && !$self->isa($class)) {
- bless $self, $class;
- $self->_rebless;
+ my $self = shift;
+
+ return if ref $self ne __PACKAGE__;
+
+ my $dbh = $self->schema->storage->dbh;
+ my $dbtype = eval { $dbh->get_info(17) };
+ unless ( $@ ) {
+ # Translate the backend name into a perl identifier
+ $dbtype =~ s/\W/_/gi;
+ my $class = "DBIx::Class::Schema::Loader::DBI::ADO::${dbtype}";
+ if ($self->load_optional_class($class) && !$self->isa($class)) {
+ bless $self, $class;
+ $self->_rebless;
+ }
}
- }
}
sub _filter_tables {
=cut
sub _rebless {
- my $self = shift;
-
- return if ref $self ne __PACKAGE__;
-
-# stolen from DBIC ODBC storage
- my $dbh = $self->schema->storage->dbh;
- my $dbtype = eval { $dbh->get_info(17) };
- unless ( $@ ) {
- # Translate the backend name into a perl identifier
- $dbtype =~ s/\W/_/gi;
- my $class = "DBIx::Class::Schema::Loader::DBI::ODBC::${dbtype}";
- if ($self->load_optional_class($class) && !$self->isa($class)) {
- bless $self, $class;
- $self->_rebless;
+ my $self = shift;
+
+ return if ref $self ne __PACKAGE__;
+
+ # stolen from DBIC ODBC storage
+ my $dbh = $self->schema->storage->dbh;
+ my $dbtype = eval { $dbh->get_info(17) };
+ unless ( $@ ) {
+ # Translate the backend name into a perl identifier
+ $dbtype =~ s/\W/_/gi;
+ my $class = "DBIx::Class::Schema::Loader::DBI::ODBC::${dbtype}";
+ if ($self->load_optional_class($class) && !$self->isa($class)) {
+ bless $self, $class;
+ $self->_rebless;
+ }
}
- }
}
=head1 SEE ALSO
# copied from DBIx::Class::_Util, import from there once it's released
sub sigwarn_silencer {
- my $pattern = shift;
+ my $pattern = shift;
- croak "Expecting a regexp" if ref $pattern ne 'Regexp';
+ croak "Expecting a regexp" if ref $pattern ne 'Regexp';
- my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) };
+ my $orig_sig_warn = $SIG{__WARN__} || sub { CORE::warn(@_) };
- return sub { &$orig_sig_warn unless $_[0] =~ $pattern };
+ return sub { &$orig_sig_warn unless $_[0] =~ $pattern };
}
sub eval_package_without_redefine_warnings {