From: Brandon Black Date: Tue, 22 May 2007 14:06:29 +0000 (+0000) Subject: convert to M::I, release 0.03999_02 X-Git-Tag: 0.03999_02 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3fe9c5d92b3872c146c93f99b77aa330bffe04ef;p=dbsrgits%2FDBIx-Class-Schema-Loader.git convert to M::I, release 0.03999_02 --- diff --git a/Build.PL b/Build.PL index 19bf3c2..a919ccc 100644 --- a/Build.PL +++ b/Build.PL @@ -1,40 +1,3 @@ -use strict; -use Module::Build; - -my %arguments = ( - license => 'perl', - module_name => 'DBIx::Class::Schema::Loader', - requires => { - 'File::Spec' => 0, - 'Scalar::Util' => 0, - 'Data::Dump' => 1.06, - 'UNIVERSAL::require' => 0.11, - 'Lingua::EN::Inflect::Number' => 1.1, - 'Text::Balanced' => 0, - 'Digest::MD5' => 2.36, - 'Class::Accessor::Fast' => 0.30, - 'Class::Data::Accessor' => 0.03, - 'Class::C3' => 0.14, - 'Carp::Clan' => 0, - 'DBIx::Class' => 0.07005, - }, - recommends => { - 'Class::Inspector' => 0, - 'DBI' => 1.53, - 'DBD::SQLite' => 1.13, - 'DBD::mysql' => 4.004, - 'DBD::Pg' => 1.49, # Soon to be 1.50 - 'DBD::DB2' => 1.0, - 'DBD::Oracle' => 0.19, - }, - build_requires => { - 'Test::More' => 0.32, - 'DBI' => 1.53, - 'DBD::SQLite' => 1.13, - 'File::Path' => 0, - }, - create_makefile_pl => 'passthrough', - create_readme => 1, -); - -Module::Build->new(%arguments)->create_build_script; +# Dear Distribution Packager. This use of require is intentional. +# Module::Install detects Build.PL usage and acts accordingly. +require 'Makefile.PL'; diff --git a/Changes b/Changes index 3d103d8..1cb6660 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for Perl extension DBIx::Class::Schema::Loader +0.03999_02 Tue May 22, 2007 + - Converted to Module::Install + 0.03012 Tue May 22, 2007 - Relationship names for multiple multi-col rels between the same table fixed by ilmari diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..305aba5 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,48 @@ +Changes +inc/Module/AutoInstall.pm +inc/Module/Install.pm +inc/Module/Install/AutoInstall.pm +inc/Module/Install/Base.pm +inc/Module/Install/Build.pm +inc/Module/Install/Can.pm +inc/Module/Install/Fetch.pm +inc/Module/Install/Include.pm +inc/Module/Install/Makefile.pm +inc/Module/Install/Metadata.pm +inc/Module/Install/Win32.pm +inc/Module/Install/WriteAll.pm +lib/DBIx/Class/Schema/Loader.pm +lib/DBIx/Class/Schema/Loader/Base.pm +lib/DBIx/Class/Schema/Loader/DBI.pm +lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm +lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +lib/DBIx/Class/Schema/Loader/DBI/Writing.pm +lib/DBIx/Class/Schema/Loader/RelBuilder.pm +Makefile.PL +MANIFEST This list of files +META.yml +README +t/01use.t +t/02pod.t +t/03podcoverage.t +t/04kwalitee.t +t/10sqlite_common.t +t/11mysql_common.t +t/12pg_common.t +t/13db2_common.t +t/14ora_common.t +t/20invocations.t +t/21misc_fatal.t +t/22dump.t +t/23dumpmore.t +t/lib/DBIx/Class/TestComponent.pm +t/lib/DBIx/Class/TestRSComponent.pm +t/lib/dbixcsl_common_tests.pm +t/lib/DBIXCSL_Test/Schema/LoaderTest1.pm +t/lib/make_dbictest_db.pm +t/lib/TestAdditional.pm +t/lib/TestAdditionalBase.pm +t/lib/TestLeftBase.pm diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 84c323a..880f129 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP @@ -50,3 +50,6 @@ TODO # Don't try to add dist dirs to MANIFEST ^DBIx-Class-Schema-Loader + +# Build.PL for maint only +Build.PL diff --git a/Makefile.PL b/Makefile.PL index 192903a..33e38f1 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,31 +1,58 @@ -# 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(); - - CPAN::Shell->install('Module::Build::Compat'); - CPAN::Shell->expand("Module", "Module::Build::Compat")->uptodate - or die "Couldn't install Module::Build, giving up.\n"; - - chdir $cwd or die "Cannot chdir() back to $cwd: $!"; - } - eval "use Module::Build::Compat 0.02; 1" or die $@; - - Module::Build::Compat->run_build_pl(args => \@ARGV); - require Module::Build; - Module::Build::Compat->write_makefile(build_class => 'Module::Build'); + +use inc::Module::Install; + +name 'DBIx-Class-Schema-Loader'; +all_from 'lib/DBIx/Class/Schema/Loader.pm'; + +test_requires 'Test::More' => '0.47'; +test_requires 'DBI' => '1.56'; +test_requires 'DBD::SQLite' => '1.12'; +test_requires 'File::Path' => 0; + +requires 'File::Spec' => 0; +requires 'Scalar::Util' => 0; +requires 'Data::Dump' => '1.06'; +requires 'UNIVERSAL::require' => '0.11'; +requires 'Lingua::EN::Inflect::Number' => '1.1'; +requires 'Text::Balanced' => 0; +requires 'Digest::MD5' => '2.36'; +requires 'Class::Accessor::Fast' => '0.30'; +requires 'Class::Data::Accessor' => '0.03'; +requires 'Class::C3' => '0.18'; +requires 'Carp::Clan' => 0; +requires 'Class::Inspector' => 0; +requires 'DBIx::Class' => '0.07006'; + +feature 'SQLite Support' => + -default => $ENV{DBIC_FEATURE_SQLITE} || 0, + 'DBI' => '1.56', + 'DBD::SQLite' => '1.12'; + +feature 'MySQL Support' => + -default => $ENV{DBIC_FEATURE_MYSQL} || 0, + 'DBI' => '1.56', + 'DBD::mysql' => '4.004'; + +feature 'PostgreSQL Support' => + -default => $ENV{DBIC_FEATURE_PG} || 0, + 'DBI' => '1.56', + 'DBD::Pg' => '1.49'; # Soon to be 1.50 + +feature 'DB2 Support' => + -default => $ENV{DBIC_FEATURE_DB2} || 0, + 'DBI' => '1.56', + 'DBD::DB2' => '1.0'; + +feature 'Oracle Support (*experimental*)' => + -default => $ENV{DBIC_FEATURE_ORACLE} || 0, + 'DBI' => '1.56', + 'DBD::Oracle' => '0.19'; + +# Rebuild README for maintainers +if(-e 'MANIFEST.SKIP') { + system("pod2text lib/DBIx/Class/Schema/Loader.pm > README"); +} + +auto_provides; +auto_install; +WriteAll; diff --git a/README b/README new file mode 100644 index 0000000..3829062 --- /dev/null +++ b/README @@ -0,0 +1,215 @@ +NAME + DBIx::Class::Schema::Loader - Dynamic definition of a + DBIx::Class::Schema + +SYNOPSIS + package My::Schema; + use base qw/DBIx::Class::Schema::Loader/; + + __PACKAGE__->loader_options( + constraint => '^foo.*', + # debug => 1, + ); + + # in seperate application code ... + + use My::Schema; + + my $schema1 = My::Schema->connect( $dsn, $user, $password, $attrs); + # -or- + my $schema1 = "My::Schema"; $schema1->connection(as above); + +DESCRIPTION + DBIx::Class::Schema::Loader automates the definition of a + DBIx::Class::Schema by scanning database table definitions and setting + up the columns, primary keys, and relationships. + + DBIx::Class::Schema::Loader currently supports only the DBI storage + type. It has explicit support for DBD::Pg, DBD::mysql, DBD::DB2, + DBD::SQLite, and DBD::Oracle. Other DBI drivers may function to a + greater or lesser degree with this loader, depending on how much of the + DBI spec they implement, and how standard their implementation is. + + Patches to make other DBDs work correctly welcome. + + See DBIx::Class::Schema::Loader::DBI::Writing for notes on writing your + own vendor-specific subclass for an unsupported DBD driver. + + This module requires DBIx::Class 0.07006 or later, and obsoletes the + older DBIx::Class::Loader. + + This module is designed more to get you up and running quickly against + an existing database, or to be effective for simple situations, rather + than to be what you use in the long term for a complex database/project. + + That being said, transitioning your code from a Schema generated by this + module to one that doesn't use this module should be straightforward and + painless, so don't shy away from it just for fears of the transition + down the road. + +METHODS + loader_options + Example in Synopsis above demonstrates a few common arguments. For + detailed information on all of the arguments, most of which are only + useful in fairly complex scenarios, see the + DBIx::Class::Schema::Loader::Base documentation. + + If you intend to use "loader_options", you must call "loader_options" + before any connection is made, or embed the "loader_options" in the + connection information itself as shown below. Setting "loader_options" + after the connection has already been made is useless. + + connection + See DBIx::Class::Schema for basic usage. + + If the final argument is a hashref, and it contains a key + "loader_options", that key will be deleted, and its value will be used + for the loader options, just as if set via the "loader_options" method + above. + + The actual auto-loading operation (the heart of this module) will be + invoked as soon as the connection information is defined. + + clone + See DBIx::Class::Schema. + + dump_to_dir + Argument: directory name. + + Calling this as a class method on either DBIx::Class::Schema::Loader or + any derived schema class will cause all affected schemas to dump manual + versions of themselves to the named directory when they are loaded. In + order to be effective, this must be set before defining a connection on + this schema class or any derived object (as the loading happens as soon + as both a connection and loader_options are set, and only once per + class). + + See "dump_directory" in DBIx::Class::Schema::Loader::Base for more + details on the dumping mechanism. + + This can also be set at module import time via the import option + "dump_to_dir:/foo/bar" to DBIx::Class::Schema::Loader, where "/foo/bar" + is the target directory. + + Examples: + + # My::Schema isa DBIx::Class::Schema::Loader, and has connection info + # hardcoded in the class itself: + perl -MDBIx::Class::Schema::Loader=dump_to_dir:/foo/bar -MMy::Schema -e1 + + # Same, but no hard-coded connection, so we must provide one: + perl -MDBIx::Class::Schema::Loader=dump_to_dir:/foo/bar -MMy::Schema -e 'My::Schema->connection("dbi:Pg:dbname=foo", ...)' + + # Or as a class method, as long as you get it done *before* defining a + # connection on this schema class or any derived object: + use My::Schema; + My::Schema->dump_to_dir('/foo/bar'); + My::Schema->connection(........); + + # Or as a class method on the DBIx::Class::Schema::Loader itself, which affects all + # derived schemas + use My::Schema; + use My::OtherSchema; + DBIx::Class::Schema::Loader->dump_to_dir('/foo/bar'); + My::Schema->connection(.......); + My::OtherSchema->connection(.......); + + # Another alternative to the above: + use DBIx::Class::Schema::Loader qw| dump_to_dir:/foo/bar |; + use My::Schema; + use My::OtherSchema; + My::Schema->connection(.......); + My::OtherSchema->connection(.......); + + make_schema_at + This simple function allows one to create a Loader-based schema + in-memory on the fly without any on-disk class files of any kind. When + used with the "dump_directory" option, you can use this to generate a + rough draft manual schema from a dsn without the intermediate step of + creating a physical Loader-based schema class. + + The return value is the input class name. + + This function can be exported/imported by the normal means, as + illustrated in these Examples: + + # Simple example, creates as a new class 'New::Schema::Name' in + # memory in the running perl interpreter. + use DBIx::Class::Schema::Loader qw/ make_schema_at /; + make_schema_at( + 'New::Schema::Name', + { debug => 1 }, + [ 'dbi:Pg:dbname="foo"','postgres' ], + ); + + # Complex: dump loaded schema to disk, all from the commandline: + perl -MDBIx::Class::Schema::Loader=make_schema_at,dump_to_dir:./lib -e 'make_schema_at("New::Schema::Name", { debug => 1 }, [ "dbi:Pg:dbname=foo","postgres" ])' + + # Same, but inside a script, and using a different way to specify the + # dump directory: + use DBIx::Class::Schema::Loader qw/ make_schema_at /; + make_schema_at( + 'New::Schema::Name', + { debug => 1, dump_directory => './lib' }, + [ 'dbi:Pg:dbname="foo"','postgres' ], + ); + + rescan + Re-scans the database for newly added tables since the initial load, and + adds them to the schema at runtime, including relationships, etc. Does + not process drops or changes. + + Returns a list of the new monikers added. + +EXAMPLE + Using the example in DBIx::Class::Manual::ExampleSchema as a basis + replace the DB::Main with the following code: + + package DB::Main; + + use base qw/DBIx::Class::Schema::Loader/; + + __PACKAGE__->loader_options( + debug => 1, + ); + __PACKAGE__->connection('dbi:SQLite:example.db'); + + 1; + + and remove the Main directory tree (optional). Every thing else should + work the same + +KNOWN ISSUES + Multiple Database Schemas + Currently the loader is limited to working within a single schema (using + the database vendors' definition of "schema"). If you have a + multi-schema database with inter-schema relationships (which is easy to + do in PostgreSQL or DB2 for instance), you only get to automatically + load the tables of one schema, and any relationships to tables in other + schemas will be silently ignored. + + At some point in the future, an intelligent way around this might be + devised, probably by allowing the "db_schema" option to be an arrayref + of schemas to load. + + In "normal" DBIx::Class::Schema usage, manually-defined source classes + and relationships have no problems crossing vendor schemas. + +AUTHOR + Brandon Black, "blblack@gmail.com" + + Based on DBIx::Class::Loader by Sebastian Riedel + + Based upon the work of IKEBE Tomohiro + +THANK YOU + Matt S Trout, all of the #dbix-class folks, and everyone who's ever sent + in a bug report or suggestion. + +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, DBIx::Class::Manual::ExampleSchema + diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 2b33b0f..b3a3187 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -11,7 +11,7 @@ use Scalar::Util qw/ weaken /; # 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.03999_01'; +our $VERSION = '0.03999_02'; __PACKAGE__->mk_classaccessor('_loader_args' => {}); __PACKAGE__->mk_classaccessors(qw/dump_to_dir _loader_invoked _loader/); @@ -45,16 +45,17 @@ L by scanning database table definitions and setting up the columns, primary keys, and relationships. DBIx::Class::Schema::Loader currently supports only the DBI storage type. -It has explicit support for L, L, L, and -L. Other DBI drivers may function to a greater or lesser -degree with this loader, depending on how much of the DBI spec they -implement, and how standard their implementation is. Patches to make -other DBDs work correctly welcome. +It has explicit support for L, L, L, +L, and L. Other DBI drivers may function to +a greater or lesser degree with this loader, depending on how much of the +DBI spec they implement, and how standard their implementation is. + +Patches to make other DBDs work correctly welcome. See L for notes on writing your own vendor-specific subclass for an unsupported DBD driver. -This module requires L 0.06 or later, and obsoletes +This module requires L 0.07006 or later, and obsoletes the older L. This module is designed more to get you up and running quickly against @@ -75,9 +76,10 @@ detailed information on all of the arguments, most of which are only useful in fairly complex scenarios, see the L documentation. -One must call C before any connection is made, -or embed the C in the connection information itself -as shown below. Setting C after the connection has +If you intend to use C, you must call +C before any connection is made, or embed the +C in the connection information itself as shown +below. Setting C after the connection has already been made is useless. =cut diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 21ebd51..b617697 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -14,7 +14,7 @@ use Cwd qw//; use Digest::MD5 qw//; require DBIx::Class; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; __PACKAGE__->mk_ro_accessors(qw/ schema diff --git a/lib/DBIx/Class/Schema/Loader/DBI.pm b/lib/DBIx/Class/Schema/Loader/DBI.pm index 39d5942..fa34e1b 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI.pm @@ -7,7 +7,7 @@ use Class::C3; use Carp::Clan qw/^DBIx::Class/; use UNIVERSAL::require; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm index f029457..f3f75bf 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/DB2.pm @@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI'; use Carp::Clan qw/^DBIx::Class/; use Class::C3; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm index 42dec0b..a8e6581 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm @@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI'; use Carp::Clan qw/^DBIx::Class/; use Class::C3; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm index 2020b0a..515e5ce 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Pg.pm @@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI'; use Carp::Clan qw/^DBIx::Class/; use Class::C3; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm index 5e1a8a6..98c467e 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/SQLite.pm @@ -7,7 +7,7 @@ use Carp::Clan qw/^DBIx::Class/; use Text::Balanced qw( extract_bracketed ); use Class::C3; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm b/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm index 23b9ef3..6cb7204 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/Writing.pm @@ -1,7 +1,7 @@ package DBIx::Class::Schema::Loader::DBI::Writing; use strict; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; # Empty. POD only. diff --git a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm index 1091981..62883a9 100644 --- a/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/DBI/mysql.pm @@ -6,7 +6,7 @@ use base 'DBIx::Class::Schema::Loader::DBI'; use Carp::Clan qw/^DBIx::Class/; use Class::C3; -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm index 2b87753..f011484 100644 --- a/lib/DBIx/Class/Schema/Loader/RelBuilder.pm +++ b/lib/DBIx/Class/Schema/Loader/RelBuilder.pm @@ -5,7 +5,7 @@ use warnings; use Carp::Clan qw/^DBIx::Class/; use Lingua::EN::Inflect::Number (); -our $VERSION = '0.03999_01'; +our $VERSION = '0.03999_02'; =head1 NAME