--- /dev/null
+use strict;
+use Module::Build;
+
+my %arguments = (
+ license => 'perl',
+ module_name => 'DBIx::Class::Schema::Loader',
+ requires => {
+ 'DBIx::Class' => 0.04999_07,
+ 'UNIVERSAL::require' => 0.10,
+ 'Lingua::EN::Inflect' => 0,
+ 'Text::Balanced' => 0,
+ 'Class::Accessor::Fast' => 0.22,
+ 'Class::Data::Accessor' => 0.02,
+ },
+ build_requires => {
+ 'Test::More' => 0.32,
+ 'DBI' => 1.40,
+ 'DBD::SQLite' => 1.11,
+ },
+ create_makefile_pl => 'passthrough',
+ create_readme => 1,
+);
+
+Module::Build->new(%arguments)->create_build_script;
--- /dev/null
+Build.PL
+Changes
+lib/DBIx/Class/Schema/Loader.pm
+lib/DBIx/Class/Schema/Loader/DB2.pm
+lib/DBIx/Class/Schema/Loader/Generic.pm
+lib/DBIx/Class/Schema/Loader/mysql.pm
+lib/DBIx/Class/Schema/Loader/Pg.pm
+lib/DBIx/Class/Schema/Loader/SQLite.pm
+lib/DBIx/Class/Schema/Loader/Writing.pm
+Makefile.PL
+MANIFEST This list of files
+t/01use.t
+t/02pod.t
+t/03podcoverage.t
+t/10sqlite_common.t
+t/11mysql_common.t
+t/12pg_common.t
+t/13db2_common.t
+t/dbixcsl_common_tests.pm
+t/TestAdditional.pm
+t/TestAdditionalBase.pm
+t/TestLeftBase.pm
+TODO
+META.yml
+README
--- /dev/null
+# copied over from DBIx::Class
+#
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\b\.#
+
+# avoid OS X finder files
+\.DS_Store$
+
+# Don't ship the test db
+^t/var
+
+# Don't ship the last dist we built :)
+\.tar\.gz$
+
+# Skip maint stuff
+^maint/
--- /dev/null
+---
+name: DBIx-Class-Schema-Loader
+version: 0.01000
+author:
+ - 'Brandon Black, C<bblack@gmail.com>'
+abstract: Dynamic definition of a DBIx::Class::Schema
+license: perl
+requires:
+ Class::Accessor::Fast: 0.22
+ Class::Data::Accessor: 0.02
+ DBIx::Class: 0.0499907
+ Lingua::EN::Inflect: 0
+ Text::Balanced: 0
+ UNIVERSAL::require: 0.1
+build_requires:
+ DBD::SQLite: 1.11
+ DBI: 1.4
+ Test::More: 0.32
+provides:
+ DBIx::Class::Schema::Loader:
+ file: lib/DBIx/Class/Schema/Loader.pm
+ version: 0.01000
+ DBIx::Class::Schema::Loader::DB2:
+ file: lib/DBIx/Class/Schema/Loader/DB2.pm
+ DBIx::Class::Schema::Loader::Generic:
+ file: lib/DBIx/Class/Schema/Loader/Generic.pm
+ DBIx::Class::Schema::Loader::Pg:
+ file: lib/DBIx/Class/Schema/Loader/Pg.pm
+ DBIx::Class::Schema::Loader::SQLite:
+ file: lib/DBIx/Class/Schema/Loader/SQLite.pm
+ DBIx::Class::Schema::Loader::Writing:
+ file: lib/DBIx/Class/Schema/Loader/Writing.pm
+ DBIx::Class::Schema::Loader::mysql:
+ file: lib/DBIx/Class/Schema/Loader/mysql.pm
+generated_by: Module::Build version 0.2611
-use ExtUtils::MakeMaker;
-
-WriteMakefile(
- 'NAME' => 'DBIx::Class::Schema::Loader',
- 'VERSION_FROM' => 'lib/DBIx/Class/Schema/Loader.pm',
- 'PREREQ_PM' => {
- Test::More => 0.32,
- DBIx::Class => 0.05,
- DBI => 1.30,
- Lingua::EN::Inflect => 0,
- Text::Balanced => 0,
- UNIVERSAL::require => 0.10,
- },
-);
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+
+ unless (eval "use Module::Build::Compat 0.02; 1" ) {
+ print "This module requires Module::Build to install itself.\n";
+
+ require ExtUtils::MakeMaker;
+ my $yn = ExtUtils::MakeMaker::prompt
+ (' Install Module::Build now from CPAN?', 'y');
+
+ unless ($yn =~ /^y/i) {
+ die " *** Cannot install without Module::Build. Exiting ...\n";
+ }
+
+ require Cwd;
+ require File::Spec;
+ require CPAN;
+
+ # Save this 'cause CPAN will chdir all over the place.
+ my $cwd = Cwd::cwd();
+ my $makefile = File::Spec->rel2abs($0);
+
+ CPAN::Shell->install('Module::Build::Compat')
+ or die " *** Cannot install without Module::Build. Exiting ...\n";
+
+ chdir $cwd or die "Cannot chdir() back to $cwd: $!";
+ }
+ eval "use Module::Build::Compat 0.02; 1" or die $@;
+ use lib '_build/lib';
+ Module::Build::Compat->run_build_pl(args => \@ARGV);
+ require Module::Build;
+ Module::Build::Compat->write_makefile(build_class => 'Module::Build');
--- /dev/null
+NAME
+ DBIx::Class::Schema::Loader - Dynamic definition of a
+ DBIx::Class::Schema
+
+SYNOPSIS
+ package My::Schema;
+ use base qw/DBIx::Class::Schema::Loader/;
+
+ __PACKAGE__->load_from_connection(
+ dsn => "dbi:mysql:dbname",
+ user => "root",
+ password => "",
+ additional_classes => [qw/DBIx::Class::Foo/],
+ additional_base_classes => [qw/My::Stuff/],
+ left_base_classes => [qw/DBIx::Class::Bar/],
+ constraint => '^foo.*',
+ relationships => 1,
+ options => { AutoCommit => 1 },
+ inflect => { child => 'children' },
+ debug => 1,
+ );
+
+ # in seperate application code ...
+
+ use My::Schema;
+
+ my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs);
+ # -or-
+ 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 L<DBIx::Class::Schema>
+ my $rs = $schema1->resultset($monikers->{table_table})->search(...);
+
+DESCRIPTION
+ DBIx::Class::Schema::Loader automates the definition of a
+ DBIx::Class::Schema by scanning table schemas and setting up columns and
+ primary keys.
+
+ DBIx::Class::Schema::Loader supports MySQL, Postgres, SQLite and DB2.
+ See DBIx::Class::Schema::Loader::Generic for more, and
+ DBIx::Class::Schema::Loader::Writing for notes on writing your own
+ db-specific subclass for an unsupported db.
+
+ This module requires DBIx::Class::Loader 0.5 or later, and obsoletes
+ DBIx::Class::Loader for DBIx::Class version 0.5 and later.
+
+METHODS
+ load_from_connection
+ Example in Synopsis above demonstrates the available arguments. For
+ detailed information on the arguments, see the
+ DBIx::Class::Schema::Loader::Generic documentation.
+
+AUTHOR
+ Brandon Black, "bblack@gmail.com"
+
+ Based on DBIx::Class::Loader by Sebastian Riedel
+
+ Based upon the work of IKEBE Tomohiro
+
+THANK YOU
+ Adam Anderson, Andy Grundman, Autrijus Tang, Dan Kubb, David Naughton,
+ Randal Schwartz, Simon Flack and all the others who've helped.
+
+LICENSE
+ This library is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself.
+
+SEE ALSO
+ DBIx::Class
+
use Carp;
use UNIVERSAL::require;
+use base qw/DBIx::Class::Schema/;
+use base qw/Class::Data::Accessor/;
+
+__PACKAGE__->mk_classaccessor('loader');
+
use vars qw($VERSION);
# Always remember to do all digits for the version even if they're 0
# brain damage and presumably various other packaging systems too
$VERSION = '0.01000';
-use base qw/DBIx::Class::Schema/;
-
-__PACKAGE__->mk_classaccessor('loader');
-
=head1 NAME
DBIx::Class::Schema::Loader - Dynamic definition of a DBIx::Class::Schema
Brandon Black, C<bblack@gmail.com>
-Sebastian Riedel, C<sri@oook.de> (DBIx::Class::Loader, which this module is branched from)
+Based on L<DBIx::Class::Loader> by Sebastian Riedel
Based upon the work of IKEBE Tomohiro
=head3 tables
-Returns a sorted list of tables.
+Returns a sorted list of loaded tables, using the original database table
+names. Actually generated from the keys of the C<monikers> hash below.
- my @tables = $loader->tables;
+ my @tables = $schema->loader->tables;
+
+=head3 monikers
+
+Returns a hashref of loaded table-to-moniker mappings for the original
+database table names.
+
+ my $monikers = $schema->loader->monikers;
+ my $foo_tbl_moniker = $monikers->{foo_tbl};
+ # -or-
+ my $foo_tbl_moniker = $schema->loader->monikers->{foo_tbl};
+ # $foo_tbl_moniker would look like "FooTbl"
+
+=head3 classes
+
+Returns a hashref of table-to-classname mappings for the original database
+table names. You probably shouldn't be using this, as operating on the
+original class names is usually a bad idea. This hook is here for people
+who want to do strange and/or possibly broken things. The usual way to
+get at things is C<$schema->resultset('FooTbl')>, where C<FooTbl> is a
+moniker as returned by C<monikers> above.
+
+ my $classes = $schema->loader->classes;
+ my $foo_tbl_class = $classes->{foo_tbl};
+ # -or-
+ my $foo_tbl_class = $schema->loader->classes->{foo_tbl};
+ # $foo_tbl_class would look like "My::Schema::FooTbl",
+ # assuming the schema class is "My::Schema"
=cut