use strict;
use warnings;
-
-use vars qw($VERSION @ISA);
+use base qw/DBIx::Class::Schema/;
+use base qw/Class::Data::Accessor/;
+use Carp;
use UNIVERSAL::require;
# Always remember to do all digits for the version even if they're 0
# i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
# brain damage and presumably various other packaging systems too
+our $VERSION = '0.01003';
-$VERSION = '0.01000';
+__PACKAGE__->mk_classaccessor('loader');
=head1 NAME
dsn => "dbi:mysql:dbname",
user => "root",
password => "",
- namespace => "My",
additional_classes => [qw/DBIx::Class::Foo/],
additional_base_classes => [qw/My::Stuff/],
left_base_classes => [qw/DBIx::Class::Bar/],
my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs);
# -or-
- my $schema1 = My::Schema->connect();
+ my $schema1 = "My::Schema";
# ^^ defaults to dsn/user/pass from load_from_connection()
+ # Get a list of the original (database) names of the tables that
+ # were loaded
+ my @tables = $schema1->loader->tables;
+
+ # Get a hashref of table_name => 'TableName' table-to-moniker
+ # mappings.
+ my $monikers = $schema1->loader->monikers;
+
+ # Get a hashref of table_name => 'My::Schema::TableName'
+ # table-to-classname mappings.
+ my $classes = $schema1->loader->classes;
+
+ # Use the schema as per normal for DBIx::Class::Schema
+ my $rs = $schema1->resultset($monikers->{table_table})->search(...);
+
=head1 DESCRIPTION
-DBIx::Class::Schema::Loader automate the definition of a
+THIS IS A DEVELOPMENT RELEASE. This is 0.01xxx, the first public
+releases. Expect things to be broken in various ways. Expect the
+entire design to be fatally flawed. Expect the interfaces to change if
+it becomes neccessary. It's mostly here for people to poke at it and
+find the flaws in it. 0.02 will hopefully have some sanity when we get
+there.
+
+DBIx::Class::Schema::Loader automates the definition of a
DBIx::Class::Schema by scanning table schemas and setting up
columns and primary keys.
L<DBIx::Class::Schema::Loader::Writing> for notes on writing your own
db-specific subclass for an unsupported db.
-L<Class::DBI::Loader>, L<Class::DBI>, and L<DBIx::Class::Loader> are now
-obsolete, use L<DBIx::Class> and this module instead. ;)
-
-=cut
+This module requires L<DBIx::Class> 0.05 or later, and obsoletes
+L<DBIx::Class::Loader> for L<DBIx::Class> version 0.05 and later.
=head1 METHODS
-=head2 new
+=head2 load_from_connection
Example in Synopsis above demonstrates the available arguments. For
detailed information on the arguments, see the
sub load_from_connection {
my ( $class, %args ) = @_;
- foreach (qw/namespace dsn/) {
- die qq/Argument $_ is required/ if ! $args{$_};
- }
-
- $args{namespace} =~ s/(.*)::$/$1/;
-
+ croak 'dsn argument is required' if ! $args{dsn};
my $dsn = $args{dsn};
my ($driver) = $dsn =~ m/^dbi:(\w*?)(?:\((.*?)\))?:/i;
$driver = 'SQLite' if $driver eq 'SQLite2';
my $impl = "DBIx::Class::Schema::Loader::" . $driver;
$impl->require or
- die qq/Couldn't require loader class "$impl", "$UNIVERSAL::require::ERROR"/;
+ croak qq/Couldn't require loader class "$impl",/ .
+ qq/"$UNIVERSAL::require::ERROR"/;
+
+ $args{schema} = $class;
- push(@ISA, $impl);
- $class->_load_from_connection(%args);
+ $class->loader($impl->new(%args));
+ $class->loader->load;
}
+=head2 loader
+
+This is an accessor in the generated Schema class for accessing
+the L<DBIx::Class::Schema::Loader::Generic> -based loader object
+that was used during construction. See the
+L<DBIx::Class::Schema::Loader::Generic> docs for more information
+on the available loader methods there.
+
=head1 AUTHOR
-Sebastian Riedel, C<sri@oook.de>
+Brandon Black, C<blblack@gmail.com>
+
+Based on L<DBIx::Class::Loader> by Sebastian Riedel
Based upon the work of IKEBE Tomohiro