From: Matt S Trout Date: Sun, 27 Nov 2005 03:50:33 +0000 (+0000) Subject: Merge 'DBIx-Class-C3' into 'DBIx-Class-resultset' X-Git-Tag: v0.05005~119^2~37 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=7fcaa6a76764758db15e4bcc5c59433e555999d2;hp=9a720616d9467c684af10632009ef50d0797bd96;p=dbsrgits%2FDBIx-Class.git Merge 'DBIx-Class-C3' into 'DBIx-Class-resultset' r3593@obrien (orig r290): paulm | 2005-11-08 17:02:49 +0000 Minor whitespace tweaks to make each file more distinct. Add note for CDBI folks to watch out. r3594@obrien (orig r291): matthewt | 2005-11-08 17:25:02 +0000 - Added fix to avoid undef warnings in CDBICompat stringify r3746@obrien (orig r292): paulm | 2005-11-10 14:05:55 +0000 Added some examples and explanations for search() r3747@obrien (orig r293): paulm | 2005-11-10 15:15:33 +0000 Change /record ?set/ to resultset incl. ResultSet in POD; typo. r3749@obrien (orig r295): andyg | 2005-11-14 17:57:49 +0000 Fixed typo in Build.PL r3751@obrien (orig r297): matthewt | 2005-11-15 03:55:24 +0000 - Bugfixes, optimisations r3752@obrien (orig r298): matthewt | 2005-11-15 06:21:38 +0000 - Added has_column and column_info methods r3757@obrien (orig r303): paulm | 2005-11-15 15:26:22 +0000 Add Class::Trigger and DBIx::ContextualFetch to build requirements (needed for CDBICompat only) r3760@obrien (orig r306): ningu | 2005-11-18 17:26:52 +0000 - fix PK::Auto bug where it wouldn't recognize a defined but false PK r3761@obrien (orig r307): ningu | 2005-11-18 17:35:41 +0000 - update fix in last rev to use has_column r3940@obrien (orig r311): ningu | 2005-11-20 21:56:49 +0000 - docs patch from dopplecoder with cleanups to Cookbook example r3941@obrien (orig r312): ningu | 2005-11-20 22:00:25 +0000 - small cleanup to last patch r3989@obrien (orig r316): matthewt | 2005-11-24 23:56:06 +0000 - Applied Brandon Black's patch to PK::Auto::Pg r4014@obrien (orig r319): matthewt | 2005-11-26 23:10:13 +0000 r3754@obrien (orig r300): matthewt | 2005-11-15 09:05:09 +0000 - Broke everything (C3 branch) r4015@obrien (orig r320): matthewt | 2005-11-26 23:10:30 +0000 r3755@obrien (orig r301): matthewt | 2005-11-15 09:32:16 +0000 - Schema now loads r4016@obrien (orig r321): matthewt | 2005-11-26 23:10:36 +0000 r3756@obrien (orig r302): matthewt | 2005-11-15 10:00:36 +0000 - Getting there ... r4017@obrien (orig r322): matthewt | 2005-11-26 23:10:42 +0000 r4018@obrien (orig r323): matthewt | 2005-11-26 23:10:48 +0000 r3759@obrien (orig r305): matthewt | 2005-11-15 20:48:44 +0000 - Shoved Class::Data::Inheritable into DBIx::Class, more stuff works now r4019@obrien (orig r324): matthewt | 2005-11-26 23:11:03 +0000 r3763@obrien (orig r309): matthewt | 2005-11-20 02:29:04 +0000 - Dumped anti-NEXT-breakage hack in CDBICompat stringify r4020@obrien (orig r325): matthewt | 2005-11-26 23:11:10 +0000 r3764@obrien (orig r310): matthewt | 2005-11-20 17:02:23 +0000 - 0.3999_01 changes r4021@obrien (orig r326): matthewt | 2005-11-26 23:11:20 +0000 r3987@obrien (orig r314): matthewt | 2005-11-24 05:27:49 +0000 - With the addition of Class::C3 0.07 and a few tweaks, C3 branch works! r4022@obrien (orig r327): matthewt | 2005-11-26 23:13:03 +0000 r3988@obrien (orig r315): matthewt | 2005-11-24 06:23:39 +0000 - Updated version and POD r4023@obrien (orig r328): matthewt | 2005-11-26 23:13:10 +0000 r3990@obrien (orig r317): matthewt | 2005-11-25 01:15:47 +0000 - Version bumped to 0.03999_03, fix for Auto::PK issues in MySQL tests r4024@obrien (orig r329): matthewt | 2005-11-26 23:13:19 +0000 r4026@obrien (orig r331): matthewt | 2005-11-27 03:50:14 +0000 - Committed version bump to DBIx::Class --- diff --git a/Build.PL b/Build.PL index 0c22671..8ecb489 100644 --- a/Build.PL +++ b/Build.PL @@ -9,16 +9,20 @@ my %arguments = ( 'Data::Page' => 0, 'DBI' => 0, 'UNIVERSAL::require' => 0, - 'NEXT' => 0, 'Scalar::Util' => 0, 'SQL::Abstract' => 1.20, 'SQL::Abstract::Limit' => 0.101, 'DBD::SQLite' => 1.08, + 'Class::C3' => 0.07, 'Tie::IxHash' => 0, - 'Storable' => 0, 'Module::Find' => 0, + 'Storable' => 0, + # Following for CDBICompat only + 'Class::Trigger' => 0, + 'DBIx::ContextualFetch' => 0, + 'Class::C3' => 0.05, }, - reommends => { + recommends => { 'Data::UUID' => 0, }, create_makefile_pl => 'passthrough', diff --git a/Changes b/Changes index 1d31a74..fdc7452 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,12 @@ Revision history for DBIx::Class + - Moved get_simple and set_simple into AccessorGroup + - Made 'new' die if given invalid columns + - Added has_column and column_info to Table.pm + - Refactored away from direct use of _columns and _primaries + +0.03004 + - Added an || '' to the CDBICompat stringify to avoid null warnings - Updated name section for manual pods 0.03003 2005-11-03 17:00:00 diff --git a/MANIFEST b/MANIFEST index f9561a3..2ff9869 100644 --- a/MANIFEST +++ b/MANIFEST @@ -65,7 +65,6 @@ Makefile.PL MANIFEST This list of files META.yml README -script/nextalyzer.pl t/02pod.t t/03podcoverage.t t/19quotes.t diff --git a/META.yml b/META.yml deleted file mode 100644 index 8521557..0000000 --- a/META.yml +++ /dev/null @@ -1,142 +0,0 @@ ---- -name: DBIx-Class -version: 0.03003 -author: - - Matt S. Trout -abstract: Extensible and flexible object <-> relational mapper. -license: perl -requires: - DBD::SQLite: 1.08 - DBI: 0 - Data::Page: 0 - Module::Find: 0 - NEXT: 0 - SQL::Abstract: 1.2 - SQL::Abstract::Limit: 0.101 - Scalar::Util: 0 - Storable: 0 - Tie::IxHash: 0 - UNIVERSAL::require: 0 -provides: - DBIC::SQL::Abstract: - file: lib/DBIx/Class/Storage/DBI.pm - DBIx::Class: - file: lib/DBIx/Class.pm - version: 0.03003 - DBIx::Class::AccessorGroup: - file: lib/DBIx/Class/AccessorGroup.pm - DBIx::Class::CDBICompat: - file: lib/DBIx/Class/CDBICompat.pm - DBIx::Class::CDBICompat::AccessorMapping: - file: lib/DBIx/Class/CDBICompat/AccessorMapping.pm - DBIx::Class::CDBICompat::AttributeAPI: - file: lib/DBIx/Class/CDBICompat/AttributeAPI.pm - DBIx::Class::CDBICompat::AutoUpdate: - file: lib/DBIx/Class/CDBICompat/AutoUpdate.pm - DBIx::Class::CDBICompat::ColumnCase: - file: lib/DBIx/Class/CDBICompat/ColumnCase.pm - DBIx::Class::CDBICompat::ColumnGroups: - file: lib/DBIx/Class/CDBICompat/ColumnGroups.pm - DBIx::Class::CDBICompat::ColumnGroups::GrouperShim: - file: lib/DBIx/Class/CDBICompat/ColumnGroups.pm - DBIx::Class::CDBICompat::Constraints: - file: lib/DBIx/Class/CDBICompat/Constraints.pm - DBIx::Class::CDBICompat::Constructor: - file: lib/DBIx/Class/CDBICompat/Constructor.pm - DBIx::Class::CDBICompat::DestroyWarning: - file: lib/DBIx/Class/CDBICompat/DestroyWarning.pm - DBIx::Class::CDBICompat::GetSet: - file: lib/DBIx/Class/CDBICompat/GetSet.pm - DBIx::Class::CDBICompat::HasA: - file: lib/DBIx/Class/CDBICompat/HasA.pm - DBIx::Class::CDBICompat::HasMany: - file: lib/DBIx/Class/CDBICompat/HasMany.pm - DBIx::Class::CDBICompat::ImaDBI: - file: lib/DBIx/Class/CDBICompat/ImaDBI.pm - DBIx::Class::CDBICompat::LazyLoading: - file: lib/DBIx/Class/CDBICompat/LazyLoading.pm - DBIx::Class::CDBICompat::LiveObjectIndex: - file: lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm - DBIx::Class::CDBICompat::MightHave: - file: lib/DBIx/Class/CDBICompat/MightHave.pm - DBIx::Class::CDBICompat::ObjIndexStubs: - file: lib/DBIx/Class/CDBICompat/ObjIndexStubs.pm - DBIx::Class::CDBICompat::Pager: - file: lib/DBIx/Class/CDBICompat/Pager.pm - DBIx::Class::CDBICompat::ReadOnly: - file: lib/DBIx/Class/CDBICompat/ReadOnly.pm - DBIx::Class::CDBICompat::Retrieve: - file: lib/DBIx/Class/CDBICompat/Retrieve.pm - DBIx::Class::CDBICompat::Stringify: - file: lib/DBIx/Class/CDBICompat/Stringify.pm - DBIx::Class::CDBICompat::TempColumns: - file: lib/DBIx/Class/CDBICompat/TempColumns.pm - DBIx::Class::CDBICompat::Triggers: - file: lib/DBIx/Class/CDBICompat/Triggers.pm - DBIx::Class::ClassResolver::PassThrough: - file: lib/DBIx/Class/ClassResolver/PassThrough.pm - DBIx::Class::Componentised: - file: lib/DBIx/Class/Componentised.pm - DBIx::Class::Core: - file: lib/DBIx/Class/Core.pm - DBIx::Class::Cursor: - file: lib/DBIx/Class/Cursor.pm - DBIx::Class::DB: - file: lib/DBIx/Class/DB.pm - DBIx::Class::Exception: - file: lib/DBIx/Class/Exception.pm - DBIx::Class::Exception::Base: - file: lib/DBIx/Class/Exception.pm - DBIx::Class::InflateColumn: - file: lib/DBIx/Class/InflateColumn.pm - DBIx::Class::ObjectCache: - file: lib/DBIx/Class/ObjectCache.pm - DBIx::Class::PK: - file: lib/DBIx/Class/PK.pm - DBIx::Class::PK::Auto: - file: lib/DBIx/Class/PK/Auto.pm - DBIx::Class::PK::Auto::MSSQL: - file: lib/DBIx/Class/PK/Auto/MSSQL.pm - DBIx::Class::PK::Auto::MySQL: - file: lib/DBIx/Class/PK/Auto/MySQL.pm - DBIx::Class::PK::Auto::Oracle: - file: lib/DBIx/Class/PK/Auto/Oracle.pm - DBIx::Class::PK::Auto::Pg: - file: lib/DBIx/Class/PK/Auto/Pg.pm - DBIx::Class::PK::Auto::SQLite: - file: lib/DBIx/Class/PK/Auto/SQLite.pm - DBIx::Class::Relationship: - file: lib/DBIx/Class/Relationship.pm - DBIx::Class::Relationship::Accessor: - file: lib/DBIx/Class/Relationship/Accessor.pm - DBIx::Class::Relationship::Base: - file: lib/DBIx/Class/Relationship/Base.pm - DBIx::Class::Relationship::BelongsTo: - file: lib/DBIx/Class/Relationship/BelongsTo.pm - DBIx::Class::Relationship::CascadeActions: - file: lib/DBIx/Class/Relationship/CascadeActions.pm - DBIx::Class::Relationship::HasMany: - file: lib/DBIx/Class/Relationship/HasMany.pm - DBIx::Class::Relationship::HasOne: - file: lib/DBIx/Class/Relationship/HasOne.pm - DBIx::Class::Relationship::ProxyMethods: - file: lib/DBIx/Class/Relationship/ProxyMethods.pm - DBIx::Class::ResultSet: - file: lib/DBIx/Class/ResultSet.pm - DBIx::Class::Row: - file: lib/DBIx/Class/Row.pm - DBIx::Class::Schema: - file: lib/DBIx/Class/Schema.pm - DBIx::Class::Storage::DBI: - file: lib/DBIx/Class/Storage/DBI.pm - DBIx::Class::Storage::DBI::Cursor: - file: lib/DBIx/Class/Storage/DBI/Cursor.pm - DBIx::Class::Table: - file: lib/DBIx/Class/Table.pm - DBIx::Class::Test::SQLite: - file: lib/DBIx/Class/Test/SQLite.pm - DBIx::Class::UUIDColumns: - file: lib/DBIx/Class/UUIDColumns.pm - DBIx::ContextualFetch::st: - file: lib/DBIx/Class/CDBICompat/ImaDBI.pm -generated_by: Module::Build version 0.2611 diff --git a/README b/README index ea0c835..4dcaf62 100644 --- a/README +++ b/README @@ -8,10 +8,12 @@ DESCRIPTION and making it possible to support some new features like self-joins, distinct, group bys and more. - It's currently considered EXPERIMENTAL - bring this near a production - database at your own risk! The API is *not* fixed yet, although most of - the primitives should be good for the future and any API changes will be - posted to the mailing list before they're committed. + This project is still at an early stage so the maintainers don't make + any absolute promise that full backwards-compatibility will be + supported; however if we can without compromising the improvements we're + trying to make, we will, and any non-compatible changes will merit a + full justification on the mailing list and a CPAN developer release for + people to test against. The community can be found via - diff --git a/lib/DBIx/Class.pm b/lib/DBIx/Class.pm index 0d2f400..8966c98 100644 --- a/lib/DBIx/Class.pm +++ b/lib/DBIx/Class.pm @@ -4,9 +4,9 @@ use strict; use warnings; use vars qw($VERSION); -use base qw/DBIx::Class::Componentised/; +use base qw/DBIx::Class::Componentised Class::Data::Inheritable/; -$VERSION = '0.03003'; +$VERSION = '0.04'; 1; @@ -24,10 +24,11 @@ and meant to support compability with it, while restructuring the insides, and making it possible to support some new features like self-joins, distinct, group bys and more. -It's currently considered EXPERIMENTAL - bring this near a production -database at your own risk! The API is *not* fixed yet, although most of -the primitives should be good for the future and any API changes will be -posted to the mailing list before they're committed. +This project is still at an early stage so the maintainers don't make +any absolute promise that full backwards-compatibility will be supported; +however if we can without compromising the improvements we're trying to +make, we will, and any non-compatible changes will merit a full justification +on the mailing list and a CPAN developer release for people to test against. The community can be found via - diff --git a/lib/DBIx/Class/AccessorGroup.pm b/lib/DBIx/Class/AccessorGroup.pm index 1fcd2e0..03ec899 100644 --- a/lib/DBIx/Class/AccessorGroup.pm +++ b/lib/DBIx/Class/AccessorGroup.pm @@ -3,8 +3,6 @@ package DBIx::Class::AccessorGroup; use strict; use warnings; -use NEXT; - =head1 NAME DBIx::Class::AccessorGroup - Lets you build groups of accessors @@ -136,6 +134,16 @@ sub make_group_wo_accessor { }; } +sub get_simple { + my ($self, $get) = @_; + return $self->{$get}; +} + +sub set_simple { + my ($self, $set, $val) = @_; + return $self->{$set} = $val; +} + 1; =back diff --git a/lib/DBIx/Class/CDBICompat.pm b/lib/DBIx/Class/CDBICompat.pm index 88c0818..5fb1af4 100644 --- a/lib/DBIx/Class/CDBICompat.pm +++ b/lib/DBIx/Class/CDBICompat.pm @@ -2,7 +2,7 @@ package DBIx::Class::CDBICompat; use strict; use warnings; -use base qw/DBIx::Class/; +use base qw/DBIx::Class::Core DBIx::Class::DB/; __PACKAGE__->load_own_components(qw/ Constraints @@ -16,8 +16,8 @@ __PACKAGE__->load_own_components(qw/ Constructor AccessorMapping ColumnCase - HasMany HasA + HasMany MightHave LazyLoading AutoUpdate diff --git a/lib/DBIx/Class/CDBICompat/AccessorMapping.pm b/lib/DBIx/Class/CDBICompat/AccessorMapping.pm index 6d5e4b0..aec1653 100644 --- a/lib/DBIx/Class/CDBICompat/AccessorMapping.pm +++ b/lib/DBIx/Class/CDBICompat/AccessorMapping.pm @@ -3,12 +3,10 @@ package DBIx::Class::CDBICompat::AccessorMapping; use strict; use warnings; -use NEXT; - sub mk_group_accessors { my ($class, $group, @cols) = @_; unless ($class->can('accessor_name') || $class->can('mutator_name')) { - return $class->NEXT::ACTUAL::mk_group_accessors($group => @cols); + return $class->next::method($group => @cols); } foreach my $col (@cols) { my $ro_meth = ($class->can('accessor_name') @@ -19,7 +17,7 @@ sub mk_group_accessors { : $col); #warn "$col $ro_meth $wo_meth"; if ($ro_meth eq $wo_meth) { - $class->NEXT::ACTUAL::mk_group_accessors($group => [ $ro_meth => $col ]); + $class->next::method($group => [ $ro_meth => $col ]); } else { $class->mk_group_ro_accessors($group => [ $ro_meth => $col ]); $class->mk_group_wo_accessors($group => [ $wo_meth => $col ]); @@ -27,23 +25,20 @@ sub mk_group_accessors { } } -sub create { +sub new { my ($class, $attrs, @rest) = @_; $class->throw( "create needs a hashref" ) unless ref $attrs eq 'HASH'; - $attrs = { %$attrs }; - my %att; - foreach my $col (keys %{ $class->_columns }) { + foreach my $col ($class->columns) { if ($class->can('accessor_name')) { my $acc = $class->accessor_name($col); -#warn "$col $acc"; - $att{$col} = delete $attrs->{$acc} if exists $attrs->{$acc}; + $attrs->{$col} = delete $attrs->{$acc} if exists $attrs->{$acc}; } if ($class->can('mutator_name')) { my $mut = $class->mutator_name($col); - $att{$col} = delete $attrs->{$mut} if exists $attrs->{$mut}; + $attrs->{$col} = delete $attrs->{$mut} if exists $attrs->{$mut}; } } - return $class->NEXT::ACTUAL::create({ %$attrs, %att }, @rest); + return $class->next::method($attrs, @rest); } 1; diff --git a/lib/DBIx/Class/CDBICompat/AutoUpdate.pm b/lib/DBIx/Class/CDBICompat/AutoUpdate.pm index fb33a0a..10076c6 100644 --- a/lib/DBIx/Class/CDBICompat/AutoUpdate.pm +++ b/lib/DBIx/Class/CDBICompat/AutoUpdate.pm @@ -9,7 +9,7 @@ __PACKAGE__->mk_classdata('__AutoCommit'); sub set_column { my $self = shift; - my $ret = $self->NEXT::set_column(@_); + my $ret = $self->next::method(@_); $self->update if ($self->autoupdate && $self->{_in_storage}); return $ret; } diff --git a/lib/DBIx/Class/CDBICompat/ColumnCase.pm b/lib/DBIx/Class/CDBICompat/ColumnCase.pm index 4e65117..8ef8080 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnCase.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnCase.pm @@ -2,65 +2,66 @@ package DBIx::Class::CDBICompat::ColumnCase; use strict; use warnings; -use NEXT; + +use base qw/DBIx::Class/; sub _register_column_group { my ($class, $group, @cols) = @_; - return $class->NEXT::ACTUAL::_register_column_group($group => map lc, @cols); + return $class->next::method($group => map lc, @cols); } sub _register_columns { my ($class, @cols) = @_; - return $class->NEXT::ACTUAL::_register_columns(map lc, @cols); + return $class->next::method(map lc, @cols); } sub has_a { my ($class, $col, @rest) = @_; - $class->NEXT::ACTUAL::has_a(lc($col), @rest); + $class->next::method(lc($col), @rest); $class->mk_group_accessors('inflated_column' => $col); return 1; } sub has_many { my ($class, $rel, $f_class, $f_key, @rest) = @_; - return $class->NEXT::ACTUAL::has_many($rel, $f_class, ( ref($f_key) ? + return $class->next::method($rel, $f_class, ( ref($f_key) ? $f_key : lc($f_key) ), @rest); } sub get_inflated_column { my ($class, $get, @rest) = @_; - return $class->NEXT::ACTUAL::get_inflated_column(lc($get), @rest); + return $class->next::method(lc($get), @rest); } sub store_inflated_column { my ($class, $set, @rest) = @_; - return $class->NEXT::ACTUAL::store_inflated_column(lc($set), @rest); + return $class->next::method(lc($set), @rest); } sub set_inflated_column { my ($class, $set, @rest) = @_; - return $class->NEXT::ACTUAL::set_inflated_column(lc($set), @rest); + return $class->next::method(lc($set), @rest); } sub get_column { my ($class, $get, @rest) = @_; - return $class->NEXT::ACTUAL::get_column(lc($get), @rest); + return $class->next::method(lc($get), @rest); } sub set_column { my ($class, $set, @rest) = @_; - return $class->NEXT::ACTUAL::set_column(lc($set), @rest); + return $class->next::method(lc($set), @rest); } sub store_column { my ($class, $set, @rest) = @_; - return $class->NEXT::ACTUAL::store_column(lc($set), @rest); + return $class->next::method(lc($set), @rest); } sub find_column { my ($class, $col) = @_; - return $class->NEXT::ACTUAL::find_column(lc($col)); + return $class->next::method(lc($col)); } sub _mk_group_accessors { @@ -73,25 +74,25 @@ sub _mk_group_accessors { next if defined &{"${class}::${acc}"}; push(@extra, [ lc $acc => $field ]); } - return $class->NEXT::ACTUAL::_mk_group_accessors($type, $group, + return $class->next::method($type, $group, @fields, @extra); } sub _cond_key { my ($class, $attrs, $key, @rest) = @_; - return $class->NEXT::ACTUAL::_cond_key($attrs, lc($key), @rest); + return $class->next::method($attrs, lc($key), @rest); } sub _cond_value { my ($class, $attrs, $key, @rest) = @_; - return $class->NEXT::ACTUAL::_cond_value($attrs, lc($key), @rest); + return $class->next::method($attrs, lc($key), @rest); } sub new { my ($class, $attrs, @rest) = @_; my %att; $att{lc $_} = $attrs->{$_} for keys %$attrs; - return $class->NEXT::ACTUAL::new(\%att, @rest); + return $class->next::method(\%att, @rest); } 1; diff --git a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm index 4c0b148..d87e6a4 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm @@ -2,9 +2,8 @@ package DBIx::Class::CDBICompat::ColumnGroups; use strict; use warnings; -use NEXT; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class::Row/; __PACKAGE__->mk_classdata('_column_groups' => { }); @@ -58,13 +57,13 @@ sub all_columns { return keys %{$_[0]->_columns}; } sub primary_column { my ($class) = @_; - my @pri = keys %{$class->_primaries}; + my @pri = $class->primary_columns; return wantarray ? @pri : $pri[0]; } sub find_column { my ($class, $col) = @_; - return $col if $class->_columns->{$col}; + return $col if $class->has_column($col); } sub __grouper { diff --git a/lib/DBIx/Class/CDBICompat/HasA.pm b/lib/DBIx/Class/CDBICompat/HasA.pm index e35c221..4547ab5 100644 --- a/lib/DBIx/Class/CDBICompat/HasA.pm +++ b/lib/DBIx/Class/CDBICompat/HasA.pm @@ -5,7 +5,7 @@ use warnings; sub has_a { my ($self, $col, $f_class, %args) = @_; - $self->throw( "No such column ${col}" ) unless $self->_columns->{$col}; + $self->throw( "No such column ${col}" ) unless $self->has_column($col); eval "require $f_class"; if ($args{'inflate'} || $args{'deflate'}) { # Non-database has_a if (!ref $args{'inflate'}) { diff --git a/lib/DBIx/Class/CDBICompat/HasMany.pm b/lib/DBIx/Class/CDBICompat/HasMany.pm index 3f745f6..3d402b1 100644 --- a/lib/DBIx/Class/CDBICompat/HasMany.pm +++ b/lib/DBIx/Class/CDBICompat/HasMany.pm @@ -19,7 +19,7 @@ sub has_many { $args->{cascade_delete} = 0; } - $class->NEXT::has_many($rel, $f_class, $f_key, $args); + $class->next::method($rel, $f_class, $f_key, $args); if (@f_method) { no strict 'refs'; diff --git a/lib/DBIx/Class/CDBICompat/ImaDBI.pm b/lib/DBIx/Class/CDBICompat/ImaDBI.pm index b77ba18..4d6e3d5 100644 --- a/lib/DBIx/Class/CDBICompat/ImaDBI.pm +++ b/lib/DBIx/Class/CDBICompat/ImaDBI.pm @@ -4,8 +4,7 @@ use strict; use warnings; use DBIx::ContextualFetch; -use NEXT; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; __PACKAGE__->mk_classdata('_transform_sql_handler_order' => [ qw/TABLE ESSENTIAL JOIN/ ] ); @@ -62,7 +61,7 @@ sub connection { my ($class, @info) = @_; $info[3] = { %{ $info[3] || {}} }; $info[3]->{RootClass} = 'DBIx::ContextualFetch'; - return $class->NEXT::connection(@info); + return $class->next::method(@info); } sub __driver { diff --git a/lib/DBIx/Class/CDBICompat/LazyLoading.pm b/lib/DBIx/Class/CDBICompat/LazyLoading.pm index 6a33eff..44c5b3a 100644 --- a/lib/DBIx/Class/CDBICompat/LazyLoading.pm +++ b/lib/DBIx/Class/CDBICompat/LazyLoading.pm @@ -15,7 +15,7 @@ sub get_column { && $_ ne 'All' } keys %{ $self->_column_groups || {} }); } - $self->NEXT::get_column(@_[1..$#_]); + $self->next::method(@_[1..$#_]); } sub _flesh { diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index 8ebdf12..7d04710 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -33,7 +33,7 @@ sub clear_object_index { sub insert { my ($self, @rest) = @_; - $self->NEXT::ACTUAL::insert(@rest); + $self->next::method(@rest); # Because the insert will die() if it can't insert into the db (or should) # we can be sure the object *was* inserted if we got this far. In which # case, given primary keys are unique and ID only returns a @@ -53,7 +53,7 @@ sub insert { sub _row_to_object { my ($class, @rest) = @_; - my $new = $class->NEXT::ACTUAL::_row_to_object(@rest); + my $new = $class->next::method(@rest); if (my $key = $new->ID) { #warn "Key $key"; my $live = $class->live_object_index; @@ -70,11 +70,11 @@ sub discard_changes { my ($self) = @_; if (my $key = $self->ID) { $self->remove_from_object_index; - my $ret = $self->NEXT::ACTUAL::discard_changes; + my $ret = $self->next::method; $self->live_object_index->{$key} = $self if $self->in_storage; return $ret; } else { - return $self->NEXT::ACTUAL::discard_changes; + return $self->next::method; } } diff --git a/lib/DBIx/Class/CDBICompat/MightHave.pm b/lib/DBIx/Class/CDBICompat/MightHave.pm index e661f6b..55e97e9 100644 --- a/lib/DBIx/Class/CDBICompat/MightHave.pm +++ b/lib/DBIx/Class/CDBICompat/MightHave.pm @@ -6,9 +6,9 @@ use warnings; sub might_have { my ($class, $rel, $f_class, @columns) = @_; if (ref $columns[0] || !defined $columns[0]) { - return $class->NEXT::might_have($rel, $f_class, @columns); + return $class->next::method($rel, $f_class, @columns); } else { - return $class->NEXT::might_have($rel, $f_class, undef, + return $class->next::method($rel, $f_class, undef, { proxy => \@columns }); } } diff --git a/lib/DBIx/Class/CDBICompat/Stringify.pm b/lib/DBIx/Class/CDBICompat/Stringify.pm index 7a7ea7b..743e150 100644 --- a/lib/DBIx/Class/CDBICompat/Stringify.pm +++ b/lib/DBIx/Class/CDBICompat/Stringify.pm @@ -6,16 +6,14 @@ use warnings; use Scalar::Util; use overload - '""' => sub { - return Scalar::Util::refaddr($_[0]) if (caller)[0] eq 'NEXT'; - return shift->stringify_self; }, + '""' => sub { return shift->stringify_self; }, fallback => 1; sub stringify_self { my $self = shift; my @cols = $self->columns('Stringify'); @cols = $self->primary_column unless @cols; - my $ret = join "/", map { $self->get_column($_) } @cols; + my $ret = join "/", map { $self->get_column($_) || '' } @cols; return $ret || ref $self; } diff --git a/lib/DBIx/Class/CDBICompat/TempColumns.pm b/lib/DBIx/Class/CDBICompat/TempColumns.pm index 64d6d20..1bd5c93 100644 --- a/lib/DBIx/Class/CDBICompat/TempColumns.pm +++ b/lib/DBIx/Class/CDBICompat/TempColumns.pm @@ -2,7 +2,7 @@ package DBIx::Class::CDBICompat::TempColumns; use strict; use warnings; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; __PACKAGE__->mk_classdata('_temp_columns' => { }); @@ -15,7 +15,7 @@ sub _add_column_group { $tmp{$_} = 1 for @cols; $class->_temp_columns(\%tmp); } else { - return $class->NEXT::ACTUAL::_add_column_group($group, @cols); + return $class->next::method($group, @cols); } } @@ -25,7 +25,7 @@ sub new { foreach my $key (keys %$attrs) { $temp{$key} = delete $attrs->{$key} if $class->_temp_columns->{$key}; } - my $new = $class->NEXT::ACTUAL::new($attrs, @rest); + my $new = $class->next::method($attrs, @rest); foreach my $key (keys %temp) { $new->set_temp($key, $temp{$key}); } @@ -36,7 +36,7 @@ sub new { sub find_column { my ($class, $col, @rest) = @_; return $col if $class->_temp_columns->{$col}; - return $class->NEXT::ACTUAL::find_column($col, @rest); + return $class->next::method($col, @rest); } sub get_temp { @@ -58,7 +58,7 @@ sub set_temp { } sub has_real_column { - return 1 if shift->_columns->{shift}; + return 1 if shift->has_column(shift); } 1; diff --git a/lib/DBIx/Class/CDBICompat/Triggers.pm b/lib/DBIx/Class/CDBICompat/Triggers.pm index 3bf8070..0c06950 100644 --- a/lib/DBIx/Class/CDBICompat/Triggers.pm +++ b/lib/DBIx/Class/CDBICompat/Triggers.pm @@ -7,7 +7,7 @@ use Class::Trigger; sub insert { my $self = shift; $self->call_trigger('before_create'); - $self->NEXT::ACTUAL::insert(@_); + $self->next::method(@_); $self->call_trigger('after_create'); return $self; } @@ -17,7 +17,7 @@ sub update { $self->call_trigger('before_update'); my @to_update = keys %{$self->{_dirty_columns} || {}}; return -1 unless @to_update; - $self->NEXT::ACTUAL::update(@_); + $self->next::method(@_); $self->call_trigger('after_update'); return $self; } @@ -25,7 +25,7 @@ sub update { sub delete { my $self = shift; $self->call_trigger('before_delete') if ref $self; - $self->NEXT::ACTUAL::delete(@_); + $self->next::method(@_); $self->call_trigger('after_delete') if ref $self; return $self; } @@ -34,7 +34,7 @@ sub store_column { my ($self, $column, $value, @rest) = @_; my $vals = { $column => $value }; $self->call_trigger("before_set_${column}", $value, $vals); - return $self->NEXT::ACTUAL::store_column($column, $vals->{$column}); + return $self->next::method($column, $vals->{$column}); } 1; diff --git a/lib/DBIx/Class/Componentised.pm b/lib/DBIx/Class/Componentised.pm index 72dd6f2..a89f0e8 100644 --- a/lib/DBIx/Class/Componentised.pm +++ b/lib/DBIx/Class/Componentised.pm @@ -1,11 +1,16 @@ package DBIx::Class::Componentised; +use Class::C3; + sub inject_base { my ($class, $target, @to_inject) = @_; { no strict 'refs'; unshift(@{"${target}::ISA"}, grep { $target ne $_ } @to_inject); } + my $table = { Class::C3::_dump_MRO_table }; + eval "package $target; import Class::C3;" unless exists $table->{$target}; + Class::C3::reinitialize() if defined $table->{$target}; } sub load_components { diff --git a/lib/DBIx/Class/DB.pm b/lib/DBIx/Class/DB.pm index 7d1b5ca..03c0985 100644 --- a/lib/DBIx/Class/DB.pm +++ b/lib/DBIx/Class/DB.pm @@ -1,6 +1,6 @@ package DBIx::Class::DB; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; use DBIx::Class::Storage::DBI; use DBIx::Class::ClassResolver::PassThrough; use DBI; diff --git a/lib/DBIx/Class/InflateColumn.pm b/lib/DBIx/Class/InflateColumn.pm index 5c7f914..c612832 100644 --- a/lib/DBIx/Class/InflateColumn.pm +++ b/lib/DBIx/Class/InflateColumn.pm @@ -2,12 +2,13 @@ package DBIx::Class::InflateColumn; use strict; use warnings; +use base qw/DBIx::Class::Row/; sub inflate_column { my ($self, $col, $attrs) = @_; - die "No such column $col to inflate" unless exists $self->_columns->{$col}; + die "No such column $col to inflate" unless $self->has_column($col); die "inflate_column needs attr hashref" unless ref $attrs eq 'HASH'; - $self->_columns->{$col}{_inflate_info} = $attrs; + $self->column_info($col)->{_inflate_info} = $attrs; $self->mk_group_accessors('inflated_column' => $col); return 1; } @@ -15,25 +16,27 @@ sub inflate_column { sub _inflated_column { my ($self, $col, $value) = @_; return $value unless defined $value; # NULL is NULL is NULL - return $value unless exists $self->_columns->{$col}{_inflate_info}; - return $value unless exists $self->_columns->{$col}{_inflate_info}{inflate}; - my $inflate = $self->_columns->{$col}{_inflate_info}{inflate}; + my $info = $self->column_info($col) || die "No column info for $col"; + return $value unless exists $info->{_inflate_info}; + my $inflate = $info->{_inflate_info}{inflate}; + die "No inflator for $col" unless defined $inflate; return $inflate->($value, $self); } sub _deflated_column { my ($self, $col, $value) = @_; return $value unless ref $value; # If it's not an object, don't touch it - return $value unless exists $self->_columns->{$col}{_inflate_info}; - return $value unless exists $self->_columns->{$col}{_inflate_info}{deflate}; - my $deflate = $self->_columns->{$col}{_inflate_info}{deflate}; + my $info = $self->column_info($col) || die "No column info for $col"; + return $value unless exists $info->{_inflate_info}; + my $deflate = $info->{_inflate_info}{deflate}; + die "No deflator for $col" unless defined $deflate; return $deflate->($value, $self); } sub get_inflated_column { my ($self, $col) = @_; $self->throw("$col is not an inflated column") unless - exists $self->_columns->{$col}{_inflate_info}; + exists $self->column_info($col)->{_inflate_info}; return $self->{_inflated_column}{$col} if exists $self->{_inflated_column}{$col}; @@ -67,23 +70,13 @@ sub store_inflated_column { sub new { my ($class, $attrs, @rest) = @_; $attrs ||= {}; - my %deflated; foreach my $key (keys %$attrs) { - if (exists $class->_columns->{$key}{_inflate_info}) { - $deflated{$key} = $class->_deflated_column($key, - delete $attrs->{$key}); + if (ref $attrs->{$key} + && exists $class->column_info($key)->{_inflate_info}) { + $attrs->{$key} = $class->_deflated_column($key, $attrs->{$key}); } } - return $class->NEXT::ACTUAL::new({ %$attrs, %deflated }, @rest); + return $class->next::method($attrs, @rest); } -# **** B0RKEN. DOESN'T GET CALLED! -#sub _cond_value { -# my ($self, $attrs, $key, $value) = @_; -# if (exists $self->_columns->{$key}) { -# $value = $self->_deflated_column($key, $value); -# } -# return $self->NEXT::ACTUAL::_cond_value($attrs, $key, $value); -#} - 1; diff --git a/lib/DBIx/Class/Manual/Cookbook.pod b/lib/DBIx/Class/Manual/Cookbook.pod index ee5ea22..1d2b4c6 100644 --- a/lib/DBIx/Class/Manual/Cookbook.pod +++ b/lib/DBIx/Class/Manual/Cookbook.pod @@ -13,55 +13,66 @@ DBIx::Class::Manual::Cookbook - Misc receipes This is not as easy as it could be, but it's possible. Here's an example to illustrate: - package Base; - - use base qw/DBIx::Class/; - - __PACKAGE__->load_components(qw/Core DB/); - __PACKAGE__->connection(...); - - package Left; - - use base qw/Base/; - - __PACKAGE__->table('left'); - __PACKAGE__->add_columns(qw/id left_stuff/); - __PACKAGE__->set_primary_key(qw/id/); - __PACKAGE__->has_many('mid' => 'Mid'); - - sub right { - my ($self) = @_; - return Right->search( - { 'left.id' => $self->id }, - { join => { 'mid' => 'left' }}); - } - - package Mid; - - use base qw/Base/; - - __PACKAGE__->table('mid'); - __PACKAGE__->add_columns(qw/left right/); - __PACKAGE__->set_primary_key(qw/left right/); - - __PACKAGE__->belongs_to('left' => 'Left'); - __PACKAGE__->belongs_to('right' => 'Right'); - - package Right; - - use base qw/Base/; - - __PACKAGE__->table('right'); - __PACKAGE__->add_columns(qw/id right_stuff/); - __PACKAGE__->set_primary_key(qw/id/); - __PACKAGE__->has_many('mid' => 'Mid'); - - sub left { - my ($self) = @_; - return Left->search( - { 'right.id' => $self->id }, - { join => { 'mid' => 'right' }); - } + # Set up inherited connection information + package MyApp::DBIC; + use base qw/DBIx::Class/; + + __PACKAGE__->load_components(qw/PK::Auto::SQLite Core DB/); + __PACKAGE__->connection(...); + + # Set up a class for the 'authors' table + package MyApp::DBIC::Author; + use base qw/MyApp::DBIC/; + + __PACKAGE__->table('authors'); + __PACKAGE__->add_columns(qw/authID first_name last_name/); + __PACKAGE__->set_primary_key(qw/authID/); + + # Define relationship to the link table + __PACKAGE__->has_many('b2a' => 'MyApp::DBIC::Book2Author', 'authID'); + + # Create the accessor for books from the ::Author class + sub books { + my ($self) = @_; + return MyApp::DBIC::Book->search( + { 'b2a.authID' => $self->authID }, # WHERE clause + { join => 'b2a' } # join condition (part of search attrs) + # 'b2a' refers to the relationship named earlier in the Author class. + # 'b2a.authID' refers to the authID column of the b2a relationship, + # which becomes accessible in the search by being joined. + ); + } + + # define the link table class + package MyApp::DBIC::Book2Author; + use base qw/MyApp::DBIC/; + + __PACKAGE__->table('book2author'); + __PACKAGE__->add_columns(qw/bookID authID/); + __PACKAGE__->set_primary_key(qw/bookID authID/); + + __PACKAGE__->belongs_to('authID' => 'MyApp::DBIC::Author'); + __PACKAGE__->belongs_to('bookID' => 'MyApp::DBIC::Book'); + + package MyApp::DBIC::Book; + use base qw/MyApp::DBIC/; + + __PACKAGE__->table('books'); + __PACKAGE__->add_columns(qw/bookID title edition isbn publisher year/); + __PACKAGE__->set_primary_key(qw/bookID/); + + __PACKAGE__->has_many('b2a' => 'MyApp::DBIC::Book2Author', 'bookID'); + + sub authors { + my ($self) = @_; + return MyApp::DBIC::Author->search( + { 'b2a.bookID' => $self->bookID }, # WHERE clause + { join => 'b2a' }); # join condition (part of search attrs) + } + + # So the above search returns an author record where the bookID field of the + # book2author table equals the bookID of the books (using the bookID + # relationship table =item Advanced Exception handling diff --git a/lib/DBIx/Class/Manual/Intro.pod b/lib/DBIx/Class/Manual/Intro.pod index cdb8144..556c552 100644 --- a/lib/DBIx/Class/Manual/Intro.pod +++ b/lib/DBIx/Class/Manual/Intro.pod @@ -30,7 +30,9 @@ mostly useful if you want to use multiple database connections. __PACKAGE__->load_components(qw/Core DB/); If you want serial/auto-incremental primary keys, you'll need to add -the apropriate component for your db as well, for example +the apropriate component for your db as well, for example. The +PK::Auto::* modules help L keep up with newly generated +keys in auto increment database fields. __PACKAGE__->load_components(qw/PK::Auto::SQLite Core DB/); @@ -43,24 +45,24 @@ attribute hash as well as the dsn. With that out of the way, we can define our first table class: - package MyApp::DB::Frob + package MyApp::DB::Album; use base qw/MyApp::DB/; Then we specify which table it uses, - __PACKAGE__->table('frob'); + __PACKAGE__->table('album'); and specify which columns it has. - __PACKAGE__->add_columns(qw/id foo bar/); + __PACKAGE__->add_columns(qw/albumID artist title label year/); This will automatically create accessors for each of the columns, so that you can read/update the values in rows you've retrieved. Also, you need to tell it which column is the primary key: - __PACKAGE__->set_primary_key('id'); + __PACKAGE__->set_primary_key('albumID'); If you have multiple primary keys, just pass a list instead. @@ -78,9 +80,9 @@ creates classes for all the tables in your database. Here's a simple setup: use DBIx::Class::Loader; - my $loader=DBIx::Class::Loader->new( - dsn => 'dbi:SQLite:/home/me/myapp/my.db', - namespace => 'MyApp::DB'); + my $loader = DBIx::Class::Loader->new( + dsn => 'dbi:SQLite:/home/me/myapp/my.db', + namespace => 'MyApp::DB'); 1; This should be equivalent to the manual in the section above. @@ -92,14 +94,15 @@ consult the reference documentation. Once you've defined the basic classes, you can start interacting with your database. The simplest way to get a column is by primary key: - my $frob=MyApp::DB::Frob->find(14); + $albumID = 14; + $album = MyApp::DB::Album->find($albumID); -This will run a select with id=14 in the WHERE clause, and return an instance -of MyApp::DB::Frob that represents this row. Once you have that row, you can +This will run a select with albumID=14 in the WHERE clause, and return an instance +of MyApp::DB::Artist that represents this row. Once you have that row, you can access and update columns - my $val=$frob->bar; - $frob->bar(14); + $album->title('Physical Graffiti'); + $title = $album->title; # $title holds 'Physical Graffiti' or if you prefer, you can use the set_column/get_column accessors instead of the autogenerated accessors based on your column names. @@ -107,64 +110,73 @@ of the autogenerated accessors based on your column names. Just like with L, you do an 'update' to commit your changes to the database: - $frob->update; + $album->update; If needed, you can drop your local changes instead like this: - $frob->discard_changes if $frob->is_changed; + $album->discard_changes if $album->is_changed; As you can see, is_changed allows you to check if there are local changes to your object. =head2 Adding and removing rows. -To make a new row, and put it into the database, you can use the 'create' -method from L +To create a new record in the database, you can use the 'create' +method from L. It returns a L +object that can be used to access the data in the new record. - my $new_thingie=MyApp::DB::Frob->create({ - foo=>'homer', - bar=>'bart' }); + $new_album = MyApp::DB::Album->create({ + title => 'Wish You Were Here', + artist => 'Pink Floyd' + }); + +Now you can add data to the new record: + + $new_album->label('Capitol'); + $new_album->year('1975'); likewise, you can remove if from the database like this: - $new_thingie->delete(); + $new_album->delete(); or even without retrieving first. This operation takes the same kind of arguments as a search. - MyApp::DB::Frob->delete({foo=>'bart'}); + MyApp::DB::Album->delete({ artist => 'Falco' }); =head2 Finding your objects. DBIx::Class provides a few different ways to retrieve data from your database. The simplest looks something like this: - $rs=MyApp::DB::Frob->search(foo=>'bart'); + $album = MyApp::DB::Album->search( artist => 'Santana' ); -note that all the search methods return a recordset in scalar context or -a list containing all the elements in list context. +note that all the search methods return a L object +in scalar context or a list containing all the records in list context. -We also provide a handy shortcut for doing a like search: +We also provide a handy shortcut for doing a "like" search: - $rs=MyApp::DB::Frob->search_like(foo=>'bar%'); + $album = MyApp::DB::Album->search_like( artist => 'Jimi%'); Or you can provide your own handmade WHERE clause, like - $rs=MyApp::DB::Frob->search_literal('foo=?','bart'); + $album = MyApp::DB::Album->search_literal('artist=?','Peter Frampton'); The other way to provide more complex queries, is to provide a L construct to search: - $rs=MyApp::DB::Frob->search({ - bar=>{'>' => 10 }, - foo=>{'!=','bart'}, - id => [1,14,15,65,43] + $album = MyApp::DB::Album->search({ + artist => { '!=', 'Janis Joplin' }, + year => { '<' => 1980 }, + id => [ 1, 14, 15, 65, 43 ] }); The search can also be modifyed by passing another hash with attributes: - $rs=MyApp::DB::Frob->search( {foo=>'bart'}, - { page=>1, rows=>2, order_by=>'bar' } ); + $album = MyApp::DB::Album->search( + { artist => 'Bob Marley' }, + { page => 1, rows => 2, order_by => 'year' } + ); For a complete overview over the available attributes, see L diff --git a/lib/DBIx/Class/ObjectCache.pm b/lib/DBIx/Class/ObjectCache.pm index 7827a57..f37d439 100644 --- a/lib/DBIx/Class/ObjectCache.pm +++ b/lib/DBIx/Class/ObjectCache.pm @@ -3,7 +3,7 @@ package DBIx::Class::ObjectCache; use strict; use warnings; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; __PACKAGE__->mk_classdata('cache'); @@ -33,20 +33,20 @@ implements the required C, C, and C methods. sub insert { my $self = shift; - $self->NEXT::ACTUAL::insert(@_); + $self->next::method(@_); $self->_insert_into_cache if $self->cache; return $self; } sub find { my ($self,@vals) = @_; - return $self->NEXT::ACTUAL::find(@vals) unless $self->cache; + return $self->next::method(@vals) unless $self->cache; # this is a terrible hack here. I know it can be improved. # but, it's a start anyway. probably find in PK.pm needs to # call a hook, or some such thing. -Dave/ningu my ($object,$key); - my @pk = keys %{$self->_primaries}; + my @pk = $self->primary_columns; if (ref $vals[0] eq 'HASH') { my $cond = $vals[0]->{'-and'}; $key = $self->_create_ID(%{$cond->[0]}) if ref $cond eq 'ARRAY'; @@ -62,14 +62,14 @@ sub find { return $object; } - $object = $self->NEXT::ACTUAL::find(@vals); + $object = $self->next::method(@vals); $object->_insert_into_cache if $object; return $object; } sub update { my $self = shift; - my $new = $self->NEXT::ACTUAL::update(@_); + my $new = $self->next::method(@_); $self->_insert_into_cache if $self->cache; return; } @@ -77,12 +77,12 @@ sub update { sub delete { my $self = shift; $self->cache->remove($self->ID) if $self->cache; - return $self->NEXT::ACTUAL::delete(@_); + return $self->next::method(@_); } sub _row_to_object { my $self = shift; - my $new = $self->NEXT::ACTUAL::_row_to_object(@_); + my $new = $self->next::method(@_); $new->_insert_into_cache if $self->cache; return $new; } diff --git a/lib/DBIx/Class/PK.pm b/lib/DBIx/Class/PK.pm index 3bb0740..ddd37b9 100644 --- a/lib/DBIx/Class/PK.pm +++ b/lib/DBIx/Class/PK.pm @@ -4,7 +4,7 @@ use strict; use warnings; use Tie::IxHash; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class::Row/; __PACKAGE__->mk_classdata('_primaries' => {}); @@ -98,8 +98,6 @@ sub discard_changes { } delete @{$self}{keys %$self}; @{$self}{keys %$reload} = values %$reload; - #$self->store_column($_ => $reload->get_column($_)) - # foreach keys %{$self->_columns}; return $self; } @@ -141,6 +139,13 @@ sub _create_ID { return join '|', $class, map { $_ . '=' . $vals{$_} } sort keys %vals; } +sub ident_condition { + my ($self) = @_; + my %cond; + $cond{$_} = $self->get_column($_) for $self->primary_columns; + return \%cond; +} + 1; =back diff --git a/lib/DBIx/Class/PK/Auto.pm b/lib/DBIx/Class/PK/Auto.pm index 84e679a..6928ba7 100644 --- a/lib/DBIx/Class/PK/Auto.pm +++ b/lib/DBIx/Class/PK/Auto.pm @@ -1,6 +1,7 @@ package DBIx::Class::PK::Auto; -use base qw/Class::Data::Inheritable/; +#use base qw/DBIx::Class::PK/; +use base qw/DBIx::Class/; use strict; use warnings; @@ -31,17 +32,17 @@ primary keys. sub insert { my ($self, @rest) = @_; - my $ret = $self->NEXT::ACTUAL::insert(@rest); + my $ret = $self->next::method(@rest); # if all primaries are already populated, skip auto-inc my $populated = 0; - map { $populated++ if $self->$_ } keys %{ $self->_primaries }; - return $ret if ( $populated == scalar keys %{ $self->_primaries } ); + map { $populated++ if defined $self->get_column($_) } $self->primary_columns; + return $ret if ( $populated == scalar $self->primary_columns ); my ($pri, $too_many) = - (grep { $self->_primaries->{$_}{'auto_increment'} } - keys %{ $self->_primaries }) - || (keys %{ $self->_primaries }); + (grep { $self->column_info($_)->{'auto_increment'} } + $self->primary_columns) + || $self->primary_columns; $self->throw( "More than one possible key found for auto-inc on ".ref $self ) if $too_many; unless (defined $self->get_column($pri)) { diff --git a/lib/DBIx/Class/PK/Auto/Pg.pm b/lib/DBIx/Class/PK/Auto/Pg.pm index 52185e5..ab401f8 100644 --- a/lib/DBIx/Class/PK/Auto/Pg.pm +++ b/lib/DBIx/Class/PK/Auto/Pg.pm @@ -27,7 +27,7 @@ sub get_autoinc_seq { while (my $foo = $sth->fetchrow_arrayref){ if(defined $foo->[12] && $foo->[12] =~ /^nextval/) { ($self->{_autoinc_seq}) = $foo->[12] =~ - m!^nextval\('"?([^"']+)"?'::text\)!; + m!^nextval\('"?([^"']+)"?'::(?:text|regclass)\)!; } } } diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index dce0036..fd9152f 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -3,7 +3,7 @@ package DBIx::Class::Relationship; use strict; use warnings; -use base qw/DBIx::Class Class::Data::Inheritable/; +use base qw/DBIx::Class/; __PACKAGE__->load_own_components(qw/ HasMany diff --git a/lib/DBIx/Class/Relationship/Accessor.pm b/lib/DBIx/Class/Relationship/Accessor.pm index 7e215d4..f641351 100644 --- a/lib/DBIx/Class/Relationship/Accessor.pm +++ b/lib/DBIx/Class/Relationship/Accessor.pm @@ -5,7 +5,7 @@ use warnings; sub add_relationship { my ($class, $rel, @rest) = @_; - my $ret = $class->NEXT::ACTUAL::add_relationship($rel => @rest); + my $ret = $class->next::method($rel => @rest); my $rel_obj = $class->_relationships->{$rel}; if (my $acc_type = $rel_obj->{attrs}{accessor}) { $class->add_relationship_accessor($rel => $acc_type); @@ -32,7 +32,7 @@ sub add_relationship_accessor { }; } elsif ($acc_type eq 'filter') { $class->throw("No such column $rel to filter") - unless exists $class->_columns->{$rel}; + unless $class->has_column($rel); my $f_class = $class->_relationships->{$rel}{class}; $class->inflate_column($rel, { inflate => sub { diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 2747995..b1ca7fb 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -3,7 +3,7 @@ package DBIx::Class::Relationship::Base; use strict; use warnings; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; __PACKAGE__->mk_classdata('_relationships', { } ); @@ -48,9 +48,8 @@ sub add_relationship { cond => $cond, attrs => $attrs }; $class->_relationships(\%rels); - #warn %{$f_class->_columns}; - return unless eval { %{$f_class->_columns}; }; # Foreign class not loaded + return unless eval { $f_class->can('columns'); }; # Foreign class not loaded eval { $class->_resolve_join($rel, 'me') }; if ($@) { # If the resolve failed, back out and re-throw the error @@ -117,14 +116,14 @@ sub _cond_key { if (my $alias = $attrs->{_aliases}{$type}) { my $class = $attrs->{_classes}{$alias}; $self->throw("Unknown column $field on $class as $alias") - unless exists $class->_columns->{$field}; + unless $class->has_column($field); return join('.', $alias, $field); } else { $self->throw( "Unable to resolve type ${type}: only have aliases for ". join(', ', keys %{$attrs->{_aliases} || {}}) ); } } - return $self->NEXT::ACTUAL::_cond_key($attrs, $key); + return $self->next::method($attrs, $key); } sub _cond_value { @@ -134,7 +133,7 @@ sub _cond_value { unless ($value =~ s/^self\.//) { $self->throw( "Unable to convert relationship to WHERE clause: invalid value ${value}" ); } - unless ($self->_columns->{$value}) { + unless ($self->has_column($value)) { $self->throw( "Unable to convert relationship to WHERE clause: no such accessor ${value}" ); } return $self->get_column($value); @@ -144,7 +143,7 @@ sub _cond_value { if (my $alias = $attrs->{_aliases}{$type}) { my $class = $attrs->{_classes}{$alias}; $self->throw("Unknown column $field on $class as $alias") - unless exists $class->_columns->{$field}; + unless $class->has_column($field); return join('.', $alias, $field); } else { $self->throw( "Unable to resolve type ${type}: only have aliases for ". @@ -152,7 +151,7 @@ sub _cond_value { } } - return $self->NEXT::ACTUAL::_cond_value($attrs, $key, $value) + return $self->next::method($attrs, $key, $value) } =item search_related diff --git a/lib/DBIx/Class/Relationship/BelongsTo.pm b/lib/DBIx/Class/Relationship/BelongsTo.pm index 0cc441e..aca69aa 100644 --- a/lib/DBIx/Class/Relationship/BelongsTo.pm +++ b/lib/DBIx/Class/Relationship/BelongsTo.pm @@ -6,14 +6,15 @@ use warnings; sub belongs_to { my ($class, $rel, $f_class, $cond, $attrs) = @_; eval "require $f_class"; - my %f_primaries = eval { %{ $f_class->_primaries } }; + my %f_primaries; + $f_primaries{$_} = 1 for eval { $f_class->primary_columns }; my $f_loaded = !$@; # single key relationship if (not defined $cond) { $class->throw("Can't infer join condition for ${rel} on ${class}; unable to load ${f_class}") unless $f_loaded; my ($pri, $too_many) = keys %f_primaries; $class->throw("Can't infer join condition for ${rel} on ${class}; ${f_class} has multiple primary key") if $too_many; - my $acc_type = ($class->_columns->{$rel}) ? 'filter' : 'single'; + my $acc_type = ($class->has_column($rel)) ? 'filter' : 'single'; $class->add_relationship($rel, $f_class, { "foreign.${pri}" => "self.${rel}" }, { accessor => $acc_type, %{$attrs || {}} } diff --git a/lib/DBIx/Class/Relationship/CascadeActions.pm b/lib/DBIx/Class/Relationship/CascadeActions.pm index b26345b..0da3993 100644 --- a/lib/DBIx/Class/Relationship/CascadeActions.pm +++ b/lib/DBIx/Class/Relationship/CascadeActions.pm @@ -2,12 +2,12 @@ package DBIx::Class::Relationship::CascadeActions; sub delete { my ($self, @rest) = @_; - return $self->NEXT::ACTUAL::delete(@rest) unless ref $self; + return $self->next::method(@rest) unless ref $self; # I'm just ignoring this for class deletes because hell, the db should # be handling this anyway. Assuming we have joins we probably actually # *could* do them, but I'd rather not. - my $ret = $self->NEXT::ACTUAL::delete(@rest); + my $ret = $self->next::method(@rest); my %rels = %{ $self->_relationships }; my @cascade = grep { $rels{$_}{attrs}{cascade_delete} } keys %rels; @@ -19,10 +19,10 @@ sub delete { sub update { my ($self, @rest) = @_; - return $self->NEXT::ACTUAL::update(@rest) unless ref $self; + return $self->next::method(@rest) unless ref $self; # Because update cascades on a class *really* don't make sense! - my $ret = $self->NEXT::ACTUAL::update(@rest); + my $ret = $self->next::method(@rest); my %rels = %{ $self->_relationships }; my @cascade = grep { $rels{$_}{attrs}{cascade_update} } keys %rels; diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index 00dd986..f30ff50 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -9,11 +9,11 @@ sub has_many { eval "require $f_class"; unless (ref $cond) { - my ($pri, $too_many) = keys %{ $class->_primaries }; + my ($pri, $too_many) = $class->primary_columns; $class->throw( "has_many can only infer join for a single primary key; ${class} has more" ) if $too_many; my $f_key; - my $f_class_loaded = eval { $f_class->_columns }; + my $f_class_loaded = eval { $f_class->columns }; my $guess; if (defined $cond && length $cond) { $f_key = $cond; @@ -24,7 +24,7 @@ sub has_many { $guess = "using our class name '$class' as foreign key"; } $class->throw("No such column ${f_key} on foreign class ${f_class} ($guess)") - if $f_class_loaded && !exists $f_class->_columns->{$f_key}; + if $f_class_loaded && !$f_class->has_column($f_key); $cond = { "foreign.${f_key}" => "self.${pri}" }, } diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index b9ab33d..d114a39 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -15,26 +15,26 @@ sub _has_one { my ($class, $join_type, $rel, $f_class, $cond, $attrs) = @_; eval "require $f_class"; unless (ref $cond) { - my ($pri, $too_many) = keys %{ $class->_primaries }; + my ($pri, $too_many) = $class->primary_columns; $class->throw( "might_have/has_one can only infer join for a single primary key; ${class} has more" ) if $too_many; my $f_key; - my $f_class_loaded = eval { $f_class->_columns }; + my $f_class_loaded = eval { $f_class->columns }; my $guess; if (defined $cond && length $cond) { $f_key = $cond; $guess = "caller specified foreign key '$f_key'"; - } elsif ($f_class_loaded && $f_class->_columns->{$rel}) { + } elsif ($f_class_loaded && $f_class->has_column($rel)) { $f_key = $rel; $guess = "using given relationship '$rel' for foreign key"; } else { - ($f_key, $too_many) = keys %{ $f_class->_primaries }; + ($f_key, $too_many) = $f_class->primary_columns; $class->throw( "might_have/has_one can only infer join for a single primary key; ${f_class} has more" ) if $too_many; $guess = "using primary key of foreign class for foreign key"; } $class->throw("No such column ${f_key} on foreign class ${f_class} ($guess)") - if $f_class_loaded && !exists $f_class->_columns->{$f_key}; + if $f_class_loaded && !$f_class->has_column($f_key); $cond = { "foreign.${f_key}" => "self.${pri}" }; } $class->add_relationship($rel, $f_class, diff --git a/lib/DBIx/Class/Relationship/ProxyMethods.pm b/lib/DBIx/Class/Relationship/ProxyMethods.pm index 11a4e28..0524288 100644 --- a/lib/DBIx/Class/Relationship/ProxyMethods.pm +++ b/lib/DBIx/Class/Relationship/ProxyMethods.pm @@ -3,11 +3,11 @@ package DBIx::Class::Relationship::ProxyMethods; use strict; use warnings; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; sub add_relationship { my ($class, $rel, @rest) = @_; - my $ret = $class->NEXT::ACTUAL::add_relationship($rel => @rest); + my $ret = $class->next::method($rel => @rest); if (my $proxy_list = $class->_relationships->{$rel}->{attrs}{proxy}) { $class->proxy_to_related($rel, (ref $proxy_list ? @$proxy_list : $proxy_list)); diff --git a/lib/DBIx/Class/ResultSet.pm b/lib/DBIx/Class/ResultSet.pm index 9faf8ba..f6ebb56 100644 --- a/lib/DBIx/Class/ResultSet.pm +++ b/lib/DBIx/Class/ResultSet.pm @@ -9,7 +9,7 @@ use Data::Page; =head1 NAME -DBIX::Class::Recordset - Responsible for fetching and creating recordsets. +DBIX::Class::ResultSet - Responsible for fetching and creating resultset. =head1 SYNOPSIS; @@ -17,7 +17,7 @@ $rs=MyApp::DB::Class->search(registered=>1); =head1 DESCRIPTION -The recordset is also know as an iterator. +The resultset is also known as an iterator. =head1 METHODS @@ -25,7 +25,7 @@ The recordset is also know as an iterator. =item new -The recordset constructor. Takes a db class and an +The resultset constructor. Takes a db class and an attribute hash (see below for more info on attributes) =cut @@ -71,7 +71,7 @@ sub new { =item cursor -Return a storage driven cursor to the given record set. +Return a storage driven cursor to the given resultset. =cut @@ -89,7 +89,7 @@ sub cursor { =item slice -return a number of elements from the given record set. +return a number of elements from the given resultset. =cut @@ -105,7 +105,7 @@ sub slice { =item next -Returns the next element in this record set. +Returns the next element in this resultset. =cut @@ -184,7 +184,7 @@ sub count { =item all -Returns all elements in the recordset. Is called implictly if the search +Returns all elements in the resultset. Is called implictly if the search method is used in list context. =cut @@ -197,7 +197,7 @@ sub all { =item reset -Reset this recordset's cursor, so you can iterate through the elements again. +Reset this resultset's cursor, so you can iterate through the elements again. =cut @@ -209,7 +209,7 @@ sub reset { =item first -resets the recordset and returns the first element. +resets the resultset and returns the first element. =cut @@ -219,7 +219,7 @@ sub first { =item delete -Deletes all elements in the recordset. +Deletes all elements in the resultset. =cut @@ -251,7 +251,7 @@ sub pager { =item page -Returns a new recordset representing a given page. +Returns a new resultset representing a given page. =cut @@ -266,7 +266,7 @@ sub page { =head1 Attributes -The recordset is responsible for handling the various attributes that +The resultset is responsible for handling the various attributes that can be passed in with the search functions. Here's an overview of them: =over 4 diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index cb4203f..061184d 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -3,6 +3,8 @@ package DBIx::Class::Row; use strict; use warnings; +use base qw/DBIx::Class/; + =head1 NAME DBIx::Class::Row - Basic row methods @@ -33,7 +35,8 @@ sub new { if ($attrs) { $new->throw("attrs must be a hashref" ) unless ref($attrs) eq 'HASH'; while (my ($k, $v) = each %{$attrs}) { - $new->store_column($k => $v) if exists $class->_columns->{$k}; + die "No such column $k on $class" unless $class->has_column($k); + $new->store_column($k => $v); } } return $new; @@ -121,13 +124,6 @@ sub update { return $self; } -sub ident_condition { - my ($self) = @_; - my %cond; - $cond{$_} = $self->get_column($_) for keys %{$self->_primaries}; - return \%cond; -} - =item delete $obj->delete @@ -170,7 +166,7 @@ Fetches a column value sub get_column { my ($self, $column) = @_; $self->throw( "Can't fetch data as class method" ) unless ref $self; - $self->throw( "No such column '${column}'" ) unless $self->_columns->{$column}; + $self->throw( "No such column '${column}'" ) unless $self->has_column($column); return $self->{_column_data}{$column} if exists $self->{_column_data}{$column}; return undef; @@ -241,7 +237,7 @@ Sets a column value without marking it as dirty sub store_column { my ($self, $column, $value) = @_; $self->throw( "No such column '${column}'" ) - unless $self->_columns->{$column}; + unless $self->has_column($column); $self->throw( "set_column called for ${column} without value" ) if @_ < 3; return $self->{_column_data}{$column} = $value; @@ -251,7 +247,7 @@ sub _row_to_object { my ($class, $cols, $row) = @_; my %vals; $vals{$cols->[$_]} = $row->[$_] for 0 .. $#$cols; - my $new = $class->new(\%vals); + my $new = bless({ _column_data => \%vals }, ref $class || $class); $new->in_storage(1); return $new; } diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 116ac2e..1c864ea 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -2,11 +2,11 @@ package DBIx::Class::Schema; use strict; use warnings; +use DBIx::Class::DB; -use base qw/Class::Data::Inheritable/; use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/Exception Componentised/); +__PACKAGE__->load_components(qw/Exception/); __PACKAGE__->mk_classdata('class_registrations' => {}); =head1 NAME @@ -15,7 +15,7 @@ DBIx::Class::Schema - composable schemas =head1 SYNOPSIS - in My/Schema.pm +in My/Schema.pm package My::Schema; @@ -23,22 +23,23 @@ DBIx::Class::Schema - composable schemas __PACKAGE__->load_classes(qw/Foo Bar Baz/); - in My/Schema/Foo.pm +in My/Schema/Foo.pm package My::Schema::Foo; - use base qw/DBIx::Class::Core/; + use base qw/DBIx::Class/; + __PACKAGE__->load_components(qw/Core PK::Auto::Pg/); # for example __PACKAGE__->table('foo'); ... - in My/DB.pm +in My/DB.pm use My::Schema; My::Schema->compose_connection('My::DB', $dsn, $user, $pass, $attrs); - then in app code +then in app code my @obj = My::DB::Foo->search({}); # My::DB::Foo isa My::Schema::Foo My::DB @@ -49,6 +50,10 @@ one concurrent connection using the same database classes, by making subclasses under a new namespace for each connection. If you only need one class, you should probably use L directly instead. +NB: If you're used to L it's worth reading the L +carefully as DBIx::Class does things a little differently. Note in +particular which module inherits off which. + =head1 METHODS =over 4 @@ -132,7 +137,7 @@ sub compose_connection { my %map; while (my ($comp, $comp_class) = each %reg) { my $target_class = "${target}::${comp}"; - $class->inject_base($target_class, $conn_class, $comp_class); + $class->inject_base($target_class, $comp_class, $conn_class); $target_class->table($comp_class->table); @map{$comp, $comp_class} = ($target_class, $target_class); } @@ -157,8 +162,8 @@ and the subclasses the schema creates. sub setup_connection_class { my ($class, $target, @info) = @_; - $class->inject_base($target => 'DBIx::Class'); - $target->load_components('DB'); + $class->inject_base($target => 'DBIx::Class::DB'); + #$target->load_components('DB'); $target->connection(@info); } diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index e08fa7d..aabb975 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -93,16 +93,6 @@ sub new { return $new; } -sub get_simple { - my ($self, $get) = @_; - return $self->{$get}; -} - -sub set_simple { - my ($self, $set, $val) = @_; - return $self->{$set} = $val; -} - =head1 NAME DBIx::Class::Storage::DBI - DBI storage handler diff --git a/lib/DBIx/Class/Table.pm b/lib/DBIx/Class/Table.pm index 42631de..34e926e 100644 --- a/lib/DBIx/Class/Table.pm +++ b/lib/DBIx/Class/Table.pm @@ -6,7 +6,7 @@ use warnings; use DBIx::Class::ResultSet; use Data::Page; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; __PACKAGE__->mk_classdata('_columns' => {}); @@ -100,9 +100,19 @@ sub count { =item search - my @obj = $class->search({ foo => 3 }); + my @obj = $class->search({ foo => 3 }); # "... WHERE foo = 3" my $cursor = $class->search({ foo => 3 }); +To retrieve all rows, simply call C with no condition parameter, + + my @all = $class->search(); # equivalent to search({}) + +If you need to pass in additional attributes (see +L for details) an empty hash indicates +no condition, + + my @all = $class->search({}, { cols => [qw/foo bar/] }); # "SELECT foo, bar FROM $class_table" + =cut sub search { @@ -174,6 +184,39 @@ sub find_or_create { return defined($exists) ? $exists : $class->create($hash); } +=item has_column + + if ($obj->has_column($col)) { ... } + +Returns 1 if the object has a column of this name, 0 otherwise + +=cut + +sub has_column { + my ($self, $column) = @_; + return exists $self->_columns->{$column}; +} + +=item column_info + + my $info = $obj->column_info($col); + +Returns the column metadata hashref for the column + +=cut + +sub column_info { + my ($self, $column) = @_; + die "No such column $column" unless exists $self->_columns->{$column}; + return $self->_columns->{$column}; +} + +=item columns + + my @column_names = $obj->columns; + +=cut + sub columns { return keys %{shift->_columns}; } 1; diff --git a/lib/DBIx/Class/Test/SQLite.pm b/lib/DBIx/Class/Test/SQLite.pm index 7494f41..a324737 100644 --- a/lib/DBIx/Class/Test/SQLite.pm +++ b/lib/DBIx/Class/Test/SQLite.pm @@ -34,7 +34,7 @@ use strict; use base qw/DBIx::Class/; -__PACKAGE__->load_components(qw/CDBICompat PK::Auto::SQLite Core DB/); +__PACKAGE__->load_components(qw/PK::Auto::SQLite CDBICompat Core DB/); use File::Temp qw/tempfile/; my (undef, $DB) = tempfile(); diff --git a/lib/DBIx/Class/UUIDColumns.pm b/lib/DBIx/Class/UUIDColumns.pm index d45eac8..63df67b 100644 --- a/lib/DBIx/Class/UUIDColumns.pm +++ b/lib/DBIx/Class/UUIDColumns.pm @@ -1,5 +1,5 @@ package DBIx::Class::UUIDColumns; -use base qw/Class::Data::Inheritable/; +use base qw/DBIx::Class/; use Data::UUID; @@ -34,7 +34,7 @@ Note that the component needs to be loaded before Core. sub uuid_columns { my $self = shift; for (@_) { - die "column $_ doesn't exist" unless exists $self->_columns->{$_}; + die "column $_ doesn't exist" unless $self->has_column($_); } $self->uuid_auto_columns(\@_); } @@ -42,10 +42,10 @@ sub uuid_columns { sub insert { my ($self) = @_; for my $column (@{$self->uuid_auto_columns}) { - $self->$column( $self->get_uuid ) - unless defined $self->$column; + $self->store_column( $column, $self->get_uuid ) + unless defined $self->get_column( $column ); } - $self->NEXT::ACTUAL::insert; + $self->next::method; } sub get_uuid { diff --git a/script/nextalyzer.pl b/script/nextalyzer.pl deleted file mode 100755 index 4a32db1..0000000 --- a/script/nextalyzer.pl +++ /dev/null @@ -1,72 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; -use Class::ISA; - -my $class = $ARGV[0]; - -die "usage: nextalyzer Some::Class" unless $class; - -eval "use $class;"; - -die "Error using $class: $@" if $@; - -my @path = reverse Class::ISA::super_path($class); - -my %provided; -my %overloaded; - -my @warnings; - -foreach my $super (@path) { - my $file = $super; - $file =~ s/\:\:/\//g; - $file .= '.pm'; - my $file_path = $INC{$file}; - die "Couldn't get INC for $file, super $super" unless $file_path; - #warn "$super $file $file_path"; - open IN, '<', $file_path; - my $in_sub; - my $ws; - my $uses_next; - my @provides; - my @overloads; - while (my $line = ) { - unless ($in_sub) { - ($ws, $in_sub) = ($line =~ /^(\s*)sub (\S+)/); - next unless $in_sub; - } - if ($line =~ /^$ws\}/) { - if ($uses_next) { - push(@overloads, $in_sub); - } else { - push(@provides, $in_sub); - } - undef $in_sub; - undef $uses_next; - undef $ws; - next; - } - $uses_next++ if ($line =~ /\-\>NEXT/); - } - close IN; - foreach (@overloads) { - push(@warnings, "Method $_ overloaded in $class but not yet provided") - unless $provided{$_}; - push(@{$overloaded{$_}}, $super); - } - $provided{$_} = $super for @provides; - print "Class $super:\n"; - print "Provides: @provides\n"; - print "Overloads: @overloads\n"; -} - -print "\n\n"; - -print join("\n", @warnings); - -foreach my $o (keys %overloaded) { - my $pr = $provided{$o} || "**NEVER**"; - print "Method $o: ".join(' ', reverse @{$overloaded{$o}})." ${pr}\n"; -} diff --git a/t/cdbi-t/18-has_a.t b/t/cdbi-t/18-has_a.t index 84ee292..b0f0299 100644 --- a/t/cdbi-t/18-has_a.t +++ b/t/cdbi-t/18-has_a.t @@ -140,7 +140,7 @@ SKIP: { YA::Film->add_relationship_type(has_a => "YA::HasA"); package YA::HasA; - use base 'Class::DBI::Relationship::HasA'; + #use base 'Class::DBI::Relationship::HasA'; sub _inflator { my $self = shift;