From: Brandon Black Date: Tue, 31 Jan 2006 14:46:08 +0000 (+0000) Subject: schema-loader now uses Class::C3, and ::Pg uses that to override ::Generic->new(... X-Git-Tag: 0.03000~27 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a4b826292620a66477a0ccea2c542050bd3477c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git schema-loader now uses Class::C3, and ::Pg uses that to override ::Generic->new() to make the db_schema default to "public" for that vendor --- diff --git a/Build.PL b/Build.PL index 6ff962b..d1ee71c 100644 --- a/Build.PL +++ b/Build.PL @@ -11,6 +11,7 @@ my %arguments = ( 'Text::Balanced' => 0, 'Class::Accessor::Fast' => 0.22, 'Class::Data::Accessor' => 0.02, + 'Class::C3' => 0.09, }, build_requires => { 'Test::More' => 0.32, diff --git a/META.yml b/META.yml index 5f25b3f..6806dd7 100644 --- a/META.yml +++ b/META.yml @@ -7,6 +7,7 @@ abstract: Dynamic definition of a DBIx::Class::Schema license: perl requires: Class::Accessor::Fast: 0.22 + Class::C3: 0.09 Class::Data::Accessor: 0.02 DBIx::Class: 0.0499907 Lingua::EN::Inflect: 0 diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 4e84da0..6bd2ca6 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -106,6 +106,7 @@ sub load_from_connection { $args{schema} = $class; $class->loader($impl->new(%args)); + $class->loader->load; } =head1 AUTHOR diff --git a/lib/DBIx/Class/Schema/Loader/DB2.pm b/lib/DBIx/Class/Schema/Loader/DB2.pm index 428f7a4..fd56322 100644 --- a/lib/DBIx/Class/Schema/Loader/DB2.pm +++ b/lib/DBIx/Class/Schema/Loader/DB2.pm @@ -2,6 +2,7 @@ package DBIx::Class::Schema::Loader::DB2; use strict; use warnings; +use Class::C3; use base 'DBIx::Class::Schema::Loader::Generic'; =head1 NAME diff --git a/lib/DBIx/Class/Schema/Loader/Generic.pm b/lib/DBIx/Class/Schema/Loader/Generic.pm index 95b82d8..d02e5d1 100644 --- a/lib/DBIx/Class/Schema/Loader/Generic.pm +++ b/lib/DBIx/Class/Schema/Loader/Generic.pm @@ -2,6 +2,7 @@ package DBIx::Class::Schema::Loader::Generic; use strict; use warnings; +use Class::C3; use Carp; use Lingua::EN::Inflect; @@ -101,6 +102,11 @@ Username. Constructor for L, used internally by L. +=head3 load + +Does the actual schema-construction work, used internally by +L right after object construction. + =cut # ensure that a peice of object data is a valid arrayref, creating @@ -132,6 +138,12 @@ sub new { $self->{monikers} = {}; $self->{classes} = {}; + $self; +} + +sub load { + my $self = shift; + $self->schema->connection($self->dsn, $self->user, $self->password, $self->options); diff --git a/lib/DBIx/Class/Schema/Loader/Pg.pm b/lib/DBIx/Class/Schema/Loader/Pg.pm index 0d49c95..ec4a221 100644 --- a/lib/DBIx/Class/Schema/Loader/Pg.pm +++ b/lib/DBIx/Class/Schema/Loader/Pg.pm @@ -2,6 +2,8 @@ package DBIx::Class::Schema::Loader::Pg; use strict; use warnings; +use Class::C3; + use base 'DBIx::Class::Schema::Loader::Generic'; =head1 NAME @@ -23,8 +25,24 @@ DBIx::Class::Schema::Loader::Pg - DBIx::Class::Schema::Loader Postgres Implement See L. +=head1 METHODS + +=head3 new + +Overrides L's C to default the postgres +schema to C rather than blank. + =cut +sub new { + my ($class, %args) = @_; + + my $self = $class->next::method(%args); + $self->{db_schema} ||= 'public'; + + $self; +} + sub _db_classes { return qw/DBIx::Class::PK::Auto::Pg/; } diff --git a/lib/DBIx/Class/Schema/Loader/SQLite.pm b/lib/DBIx/Class/Schema/Loader/SQLite.pm index 22d7c0b..7291632 100644 --- a/lib/DBIx/Class/Schema/Loader/SQLite.pm +++ b/lib/DBIx/Class/Schema/Loader/SQLite.pm @@ -2,6 +2,7 @@ package DBIx::Class::Schema::Loader::SQLite; use strict; use warnings; +use Class::C3; use base qw/DBIx::Class::Schema::Loader::Generic/; use Text::Balanced qw( extract_bracketed ); diff --git a/lib/DBIx/Class/Schema/Loader/Writing.pm b/lib/DBIx/Class/Schema/Loader/Writing.pm index 924a1f2..a350a10 100644 --- a/lib/DBIx/Class/Schema/Loader/Writing.pm +++ b/lib/DBIx/Class/Schema/Loader/Writing.pm @@ -16,6 +16,7 @@ DBIx::Class::Schema::Loader::Writing - Loader subclass writing guide use strict; use warnings; + use Class::C3; use base 'DBIx::Class::Schema::Loader::Generic'; sub _db_classes { diff --git a/lib/DBIx/Class/Schema/Loader/mysql.pm b/lib/DBIx/Class/Schema/Loader/mysql.pm index 1017c8f..6072365 100644 --- a/lib/DBIx/Class/Schema/Loader/mysql.pm +++ b/lib/DBIx/Class/Schema/Loader/mysql.pm @@ -2,6 +2,7 @@ package DBIx::Class::Schema::Loader::mysql; use strict; use warnings; +use Class::C3; use base 'DBIx::Class::Schema::Loader::Generic'; =head1 NAME