From: Peter Rabbitson Date: Sun, 24 May 2009 13:00:50 +0000 (+0000) Subject: eol adjustments X-Git-Tag: v0.08103~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=65c2b042016f9bd215b8159586da02f9457ebf96;p=dbsrgits%2FDBIx-Class.git eol adjustments --- diff --git a/lib/DBIx/Class/CDBICompat/Pager.pm b/lib/DBIx/Class/CDBICompat/Pager.pm index 8d02dc7..36fbce9 100644 --- a/lib/DBIx/Class/CDBICompat/Pager.pm +++ b/lib/DBIx/Class/CDBICompat/Pager.pm @@ -1,19 +1,19 @@ package # hide from PAUSE DBIx::Class::CDBICompat::Pager; - + use strict; use warnings FATAL => 'all'; - + *pager = \&page; - + sub page { my $class = shift; - + my $rs = $class->search(@_); unless ($rs->{attrs}{page}) { $rs = $rs->page(1); } return ( $rs->pager, $rs ); } - + 1; diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm b/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm index 96ff543..c0df4b1 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm @@ -1,127 +1,127 @@ -package DBIx::Class::Storage::DBI::ODBC::ACCESS; -use strict; -use warnings; - -use DBI; -use base qw/DBIx::Class::Storage::DBI/; - -my $ERR_MSG_START = __PACKAGE__ . ' failed: '; - -sub insert { - my $self = shift; - my ( $source, $to_insert ) = @_; - - my $bind_attributes = $self->source_bind_attributes( $source ); - my ( undef, $sth ) = $self->_execute( 'insert' => [], $source, $bind_attributes, $to_insert ); - - #store the identity here since @@IDENTITY is connection global and this prevents - #possibility that another insert to a different table overwrites it for this resultsource - my $identity = 'SELECT @@IDENTITY'; - my $max_sth = $self->{ _dbh }->prepare( $identity ) - or $self->throw_exception( $ERR_MSG_START . $self->{ _dbh }->errstr() ); - $max_sth->execute() or $self->throw_exception( $ERR_MSG_START . $max_sth->errstr ); - - my $row = $max_sth->fetchrow_arrayref() - or $self->throw_exception( $ERR_MSG_START . "$identity did not return any result." ); - - $self->{ last_pk }->{ $source->name() } = $row; - - return $to_insert; -} - -sub last_insert_id { - my $self = shift; - my ( $result_source ) = @_; - - return @{ $self->{ last_pk }->{ $result_source->name() } }; -} - -sub bind_attribute_by_data_type { - my $self = shift; - - my ( $data_type ) = @_; - - return { TYPE => $data_type } if $data_type == DBI::SQL_LONGVARCHAR; - - return; -} - -sub sqlt_type { 'ACCESS' } - -1; - -=head1 NAME - -DBIx::Class::Storage::DBI::ODBC::ACCESS - Support specific to MS Access over ODBC - -=head1 WARNING - -I am not a DBI, DBIx::Class or MS Access guru. Use this module with that in -mind. - -This module is currently considered alpha software and can change without notice. - -=head1 DESCRIPTION - -This class implements support specific to Microsoft Access over ODBC. - -It is loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it -detects a MS Access back-end. - -=head1 SUPPORTED VERSIONS - -This module have currently only been tested on MS Access 2003 using the Jet 4.0 engine. - -As far as my knowledge it should work on MS Access 2000 or later, but that have not been tested. -Information about support for different version of MS Access is welcome. - -=head1 IMPLEMENTATION NOTES - -MS Access supports the @@IDENTITY function for retriving the id of the latest inserted row. -@@IDENTITY is global to the connection, so to support the possibility of getting the last inserted -id for different tables, the insert() function stores the inserted id on a per table basis. -last_insert_id() then just returns the stored value. - -=head1 KNOWN ACCESS PROBLEMS - -=over - -=item Invalid precision value - -This error message is received when trying to store more than 255 characters in a MEMO field. -The problem is (to my knowledge) an error in the MS Access ODBC driver. The problem is fixed -by setting the C of the column to C in C. -C is a constant in the C module. - -=back - -=head1 IMPLEMENTED FUNCTIONS - -=head2 bind_attribute_by_data_type - -This function currently supports the SQL_LONGVARCHAR column type. - -=head2 insert - -=head2 last_insert_id - -=head2 sqlt_type - -=head1 BUGS - -Most likely. Bug reports are welcome. - -=head1 AUTHORS - -Øystein Torget C<< >> - -=head1 COPYRIGHT - -You may distribute this code under the same terms as Perl itself. - -Det Norske Veritas AS (DNV) - -http://www.dnv.com - -=cut - +package DBIx::Class::Storage::DBI::ODBC::ACCESS; +use strict; +use warnings; + +use DBI; +use base qw/DBIx::Class::Storage::DBI/; + +my $ERR_MSG_START = __PACKAGE__ . ' failed: '; + +sub insert { + my $self = shift; + my ( $source, $to_insert ) = @_; + + my $bind_attributes = $self->source_bind_attributes( $source ); + my ( undef, $sth ) = $self->_execute( 'insert' => [], $source, $bind_attributes, $to_insert ); + + #store the identity here since @@IDENTITY is connection global and this prevents + #possibility that another insert to a different table overwrites it for this resultsource + my $identity = 'SELECT @@IDENTITY'; + my $max_sth = $self->{ _dbh }->prepare( $identity ) + or $self->throw_exception( $ERR_MSG_START . $self->{ _dbh }->errstr() ); + $max_sth->execute() or $self->throw_exception( $ERR_MSG_START . $max_sth->errstr ); + + my $row = $max_sth->fetchrow_arrayref() + or $self->throw_exception( $ERR_MSG_START . "$identity did not return any result." ); + + $self->{ last_pk }->{ $source->name() } = $row; + + return $to_insert; +} + +sub last_insert_id { + my $self = shift; + my ( $result_source ) = @_; + + return @{ $self->{ last_pk }->{ $result_source->name() } }; +} + +sub bind_attribute_by_data_type { + my $self = shift; + + my ( $data_type ) = @_; + + return { TYPE => $data_type } if $data_type == DBI::SQL_LONGVARCHAR; + + return; +} + +sub sqlt_type { 'ACCESS' } + +1; + +=head1 NAME + +DBIx::Class::Storage::DBI::ODBC::ACCESS - Support specific to MS Access over ODBC + +=head1 WARNING + +I am not a DBI, DBIx::Class or MS Access guru. Use this module with that in +mind. + +This module is currently considered alpha software and can change without notice. + +=head1 DESCRIPTION + +This class implements support specific to Microsoft Access over ODBC. + +It is loaded automatically by by DBIx::Class::Storage::DBI::ODBC when it +detects a MS Access back-end. + +=head1 SUPPORTED VERSIONS + +This module have currently only been tested on MS Access 2003 using the Jet 4.0 engine. + +As far as my knowledge it should work on MS Access 2000 or later, but that have not been tested. +Information about support for different version of MS Access is welcome. + +=head1 IMPLEMENTATION NOTES + +MS Access supports the @@IDENTITY function for retriving the id of the latest inserted row. +@@IDENTITY is global to the connection, so to support the possibility of getting the last inserted +id for different tables, the insert() function stores the inserted id on a per table basis. +last_insert_id() then just returns the stored value. + +=head1 KNOWN ACCESS PROBLEMS + +=over + +=item Invalid precision value + +This error message is received when trying to store more than 255 characters in a MEMO field. +The problem is (to my knowledge) an error in the MS Access ODBC driver. The problem is fixed +by setting the C of the column to C in C. +C is a constant in the C module. + +=back + +=head1 IMPLEMENTED FUNCTIONS + +=head2 bind_attribute_by_data_type + +This function currently supports the SQL_LONGVARCHAR column type. + +=head2 insert + +=head2 last_insert_id + +=head2 sqlt_type + +=head1 BUGS + +Most likely. Bug reports are welcome. + +=head1 AUTHORS + +Øystein Torget C<< >> + +=head1 COPYRIGHT + +You may distribute this code under the same terms as Perl itself. + +Det Norske Veritas AS (DNV) + +http://www.dnv.com + +=cut + diff --git a/t/42toplimit.t b/t/42toplimit.t index aefbc0c..15df156 100644 --- a/t/42toplimit.t +++ b/t/42toplimit.t @@ -1,45 +1,45 @@ -use strict; -use warnings; - -use Test::More; -use DBIx::Class::Storage::DBI; -use lib qw(t/lib); -use DBICTest; # do not remove even though it is not used -use DBIC::SqlMakerTest; - -plan tests => 8; - -my $sa = new DBIx::Class::SQLAHacks; -$sa->limit_dialect( 'Top' ); - -sub test_order { - my $args = shift; - my $order_by = $args->{order_by}; - my $expected_sql_order = $args->{expected_sql_order}; - - my $query = $sa->select( 'foo', [qw{bar baz}], undef, { - order_by => $order_by, - }, 1, 3 - ); - is_same_sql( - $query, - "SELECT * FROM ( SELECT TOP 1 * FROM ( SELECT TOP 4 bar,baz FROM foo ORDER BY $expected_sql_order->[0] ) AS foo ORDER BY $expected_sql_order->[1] ) AS bar ORDER BY $expected_sql_order->[0]", - ); -} - - test_order({ order_by => \'foo DESC' , expected_sql_order => [ 'foo DESC', 'foo ASC' ] }); - test_order({ order_by => 'foo' , expected_sql_order => [ 'foo ASC', 'foo DESC'] }); - test_order({ order_by => [ qw{ foo bar} ], expected_sql_order => [ 'foo ASC,bar ASC', 'foo DESC, bar DESC']}); - test_order({ order_by => { -asc => 'foo' }, expected_sql_order => [ 'foo ASC', 'foo DESC' ] }); - test_order({ order_by => { -desc => 'foo' }, expected_sql_order => [ 'foo DESC', 'foo ASC' ] }); - - test_order({ order_by => ['foo', { -desc => 'bar' } ], expected_sql_order => [ 'foo ASC, bar DESC', 'foo DESC, bar ASC'] }); - test_order({ order_by => {-asc => [qw{ foo bar }] }, expected_sql_order => ['foo ASC, bar ASC', 'foo DESC, bar DESC' ] }); - test_order({ order_by => - [ - { -asc => 'foo' }, - { -desc => [qw{bar}] }, - { -asc => [qw{baz frew}]}, - ], - expected_sql_order => ['foo ASC, bar DESC, baz ASC, frew ASC', 'foo DESC, bar ASC, baz DESC, frew DESC'] - }); +use strict; +use warnings; + +use Test::More; +use DBIx::Class::Storage::DBI; +use lib qw(t/lib); +use DBICTest; # do not remove even though it is not used +use DBIC::SqlMakerTest; + +plan tests => 8; + +my $sa = new DBIx::Class::SQLAHacks; +$sa->limit_dialect( 'Top' ); + +sub test_order { + my $args = shift; + my $order_by = $args->{order_by}; + my $expected_sql_order = $args->{expected_sql_order}; + + my $query = $sa->select( 'foo', [qw{bar baz}], undef, { + order_by => $order_by, + }, 1, 3 + ); + is_same_sql( + $query, + "SELECT * FROM ( SELECT TOP 1 * FROM ( SELECT TOP 4 bar,baz FROM foo ORDER BY $expected_sql_order->[0] ) AS foo ORDER BY $expected_sql_order->[1] ) AS bar ORDER BY $expected_sql_order->[0]", + ); +} + + test_order({ order_by => \'foo DESC' , expected_sql_order => [ 'foo DESC', 'foo ASC' ] }); + test_order({ order_by => 'foo' , expected_sql_order => [ 'foo ASC', 'foo DESC'] }); + test_order({ order_by => [ qw{ foo bar} ], expected_sql_order => [ 'foo ASC,bar ASC', 'foo DESC, bar DESC']}); + test_order({ order_by => { -asc => 'foo' }, expected_sql_order => [ 'foo ASC', 'foo DESC' ] }); + test_order({ order_by => { -desc => 'foo' }, expected_sql_order => [ 'foo DESC', 'foo ASC' ] }); + + test_order({ order_by => ['foo', { -desc => 'bar' } ], expected_sql_order => [ 'foo ASC, bar DESC', 'foo DESC, bar ASC'] }); + test_order({ order_by => {-asc => [qw{ foo bar }] }, expected_sql_order => ['foo ASC, bar ASC', 'foo DESC, bar DESC' ] }); + test_order({ order_by => + [ + { -asc => 'foo' }, + { -desc => [qw{bar}] }, + { -asc => [qw{baz frew}]}, + ], + expected_sql_order => ['foo ASC, bar DESC, baz ASC, frew ASC', 'foo DESC, bar ASC, baz DESC, frew DESC'] + }); diff --git a/t/46where_attribute.t b/t/46where_attribute.t index e17b518..6ed3125 100644 --- a/t/46where_attribute.t +++ b/t/46where_attribute.t @@ -1,74 +1,74 @@ -use strict; -use warnings; - -use Test::More; -use Data::Dumper; -use lib qw(t/lib); -use DBICTest; -my $schema = DBICTest->init_schema(); - -plan tests => 16; - -# select from a class with resultset_attributes -my $resultset = $schema->resultset('BooksInLibrary'); -is($resultset, 3, "select from a class with resultset_attributes okay"); - -# now test out selects through a resultset -my $owner = $schema->resultset('Owners')->find({name => "Newton"}); -my $programming_perl = $owner->books->find_or_create({ title => "Programming Perl" }); -is($programming_perl->id, 1, 'select from a resultset with find_or_create for existing entry ok'); - -# and inserts? -my $see_spot; -$see_spot = eval { $owner->books->find_or_create({ title => "See Spot Run" }) }; -if ($@) { print $@ } -ok(!$@, 'find_or_create on resultset with attribute for non-existent entry did not throw'); -ok(defined $see_spot, 'successfully did insert on resultset with attribute for non-existent entry'); - -my $see_spot_rs = $owner->books->search({ title => "See Spot Run" }); -eval { $see_spot_rs->delete(); }; -if ($@) { print $@ } -ok(!$@, 'delete on resultset with attribute did not throw'); -is($see_spot_rs->count(), 0, 'delete on resultset with attributes succeeded'); - -# many_to_many tests -my $collection = $schema->resultset('Collection')->search({collectionid => 1}); -my $pointy_objects = $collection->search_related('collection_object')->search_related('object', { type => "pointy"}); -my $pointy_count = $pointy_objects->count(); -is($pointy_count, 2, 'many_to_many explicit query through linking table with query starting from resultset count correct'); - -$collection = $schema->resultset('Collection')->find(1); -$pointy_objects = $collection->search_related('collection_object')->search_related('object', { type => "pointy"}); -$pointy_count = $pointy_objects->count(); -is($pointy_count, 2, 'many_to_many explicit query through linking table with query starting from row count correct'); - -# use where on many_to_many query -$collection = $schema->resultset('Collection')->find(1); -$pointy_objects = $collection->search_related('collection_object')->search_related('object', {}, { where => { 'object.type' => 'pointy' } }); -is($pointy_objects->count(), 2, 'many_to_many explicit query through linking table with where starting from row count correct'); - -$collection = $schema->resultset('Collection')->find(1); -$pointy_objects = $collection->pointy_objects(); -$pointy_count = $pointy_objects->count(); -is($pointy_count, 2, 'many_to_many resultset with where in resultset attrs count correct'); - -# add_to_$rel on many_to_many with where containing a required field -eval {$collection->add_to_pointy_objects({ value => "Nail" }) }; -if ($@) { print $@ } -ok( !$@, 'many_to_many add_to_$rel($hash) with where in relationship attrs did not throw'); -is($pointy_objects->count, $pointy_count+1, 'many_to_many add_to_$rel($hash) with where in relationship attrs count correct'); -$pointy_count = $pointy_objects->count(); - -my $pen = $schema->resultset('TypedObject')->create({ value => "Pen", type => "pointy"}); -eval {$collection->add_to_pointy_objects($pen)}; -if ($@) { print $@ } -ok( !$@, 'many_to_many add_to_$rel($object) with where in relationship attrs did not throw'); -is($pointy_objects->count, $pointy_count+1, 'many_to_many add_to_$rel($object) with where in relationship attrs count correct'); -$pointy_count = $pointy_objects->count(); - -my $round_objects = $collection->round_objects(); -my $round_count = $round_objects->count(); -eval {$collection->add_to_objects({ value => "Wheel", type => "round" })}; -if ($@) { print $@ } -ok( !$@, 'many_to_many add_to_$rel($hash) did not throw'); -is($round_objects->count, $round_count+1, 'many_to_many add_to_$rel($hash) count correct'); +use strict; +use warnings; + +use Test::More; +use Data::Dumper; +use lib qw(t/lib); +use DBICTest; +my $schema = DBICTest->init_schema(); + +plan tests => 16; + +# select from a class with resultset_attributes +my $resultset = $schema->resultset('BooksInLibrary'); +is($resultset, 3, "select from a class with resultset_attributes okay"); + +# now test out selects through a resultset +my $owner = $schema->resultset('Owners')->find({name => "Newton"}); +my $programming_perl = $owner->books->find_or_create({ title => "Programming Perl" }); +is($programming_perl->id, 1, 'select from a resultset with find_or_create for existing entry ok'); + +# and inserts? +my $see_spot; +$see_spot = eval { $owner->books->find_or_create({ title => "See Spot Run" }) }; +if ($@) { print $@ } +ok(!$@, 'find_or_create on resultset with attribute for non-existent entry did not throw'); +ok(defined $see_spot, 'successfully did insert on resultset with attribute for non-existent entry'); + +my $see_spot_rs = $owner->books->search({ title => "See Spot Run" }); +eval { $see_spot_rs->delete(); }; +if ($@) { print $@ } +ok(!$@, 'delete on resultset with attribute did not throw'); +is($see_spot_rs->count(), 0, 'delete on resultset with attributes succeeded'); + +# many_to_many tests +my $collection = $schema->resultset('Collection')->search({collectionid => 1}); +my $pointy_objects = $collection->search_related('collection_object')->search_related('object', { type => "pointy"}); +my $pointy_count = $pointy_objects->count(); +is($pointy_count, 2, 'many_to_many explicit query through linking table with query starting from resultset count correct'); + +$collection = $schema->resultset('Collection')->find(1); +$pointy_objects = $collection->search_related('collection_object')->search_related('object', { type => "pointy"}); +$pointy_count = $pointy_objects->count(); +is($pointy_count, 2, 'many_to_many explicit query through linking table with query starting from row count correct'); + +# use where on many_to_many query +$collection = $schema->resultset('Collection')->find(1); +$pointy_objects = $collection->search_related('collection_object')->search_related('object', {}, { where => { 'object.type' => 'pointy' } }); +is($pointy_objects->count(), 2, 'many_to_many explicit query through linking table with where starting from row count correct'); + +$collection = $schema->resultset('Collection')->find(1); +$pointy_objects = $collection->pointy_objects(); +$pointy_count = $pointy_objects->count(); +is($pointy_count, 2, 'many_to_many resultset with where in resultset attrs count correct'); + +# add_to_$rel on many_to_many with where containing a required field +eval {$collection->add_to_pointy_objects({ value => "Nail" }) }; +if ($@) { print $@ } +ok( !$@, 'many_to_many add_to_$rel($hash) with where in relationship attrs did not throw'); +is($pointy_objects->count, $pointy_count+1, 'many_to_many add_to_$rel($hash) with where in relationship attrs count correct'); +$pointy_count = $pointy_objects->count(); + +my $pen = $schema->resultset('TypedObject')->create({ value => "Pen", type => "pointy"}); +eval {$collection->add_to_pointy_objects($pen)}; +if ($@) { print $@ } +ok( !$@, 'many_to_many add_to_$rel($object) with where in relationship attrs did not throw'); +is($pointy_objects->count, $pointy_count+1, 'many_to_many add_to_$rel($object) with where in relationship attrs count correct'); +$pointy_count = $pointy_objects->count(); + +my $round_objects = $collection->round_objects(); +my $round_count = $round_objects->count(); +eval {$collection->add_to_objects({ value => "Wheel", type => "round" })}; +if ($@) { print $@ } +ok( !$@, 'many_to_many add_to_$rel($hash) did not throw'); +is($round_objects->count, $round_count+1, 'many_to_many add_to_$rel($hash) count correct'); diff --git a/t/lib/DBICTest/Schema/BooksInLibrary.pm b/t/lib/DBICTest/Schema/BooksInLibrary.pm index 1f5d7ea..b239253 100644 --- a/t/lib/DBICTest/Schema/BooksInLibrary.pm +++ b/t/lib/DBICTest/Schema/BooksInLibrary.pm @@ -1,32 +1,32 @@ -package # hide from PAUSE - DBICTest::Schema::BooksInLibrary; - -use base qw/DBICTest::BaseResult/; - -__PACKAGE__->table('books'); -__PACKAGE__->add_columns( - 'id' => { - data_type => 'integer', - is_auto_increment => 1, - }, - 'source' => { - data_type => 'varchar', - size => '100', - }, - 'owner' => { - data_type => 'integer', - }, - 'title' => { - data_type => 'varchar', - size => '100', - }, - 'price' => { - data_type => 'integer', - is_nullable => 1, - }, -); -__PACKAGE__->set_primary_key('id'); - -__PACKAGE__->resultset_attributes({where => { source => "Library" } }); - -1; +package # hide from PAUSE + DBICTest::Schema::BooksInLibrary; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('books'); +__PACKAGE__->add_columns( + 'id' => { + data_type => 'integer', + is_auto_increment => 1, + }, + 'source' => { + data_type => 'varchar', + size => '100', + }, + 'owner' => { + data_type => 'integer', + }, + 'title' => { + data_type => 'varchar', + size => '100', + }, + 'price' => { + data_type => 'integer', + is_nullable => 1, + }, +); +__PACKAGE__->set_primary_key('id'); + +__PACKAGE__->resultset_attributes({where => { source => "Library" } }); + +1; diff --git a/t/lib/DBICTest/Schema/Collection.pm b/t/lib/DBICTest/Schema/Collection.pm index e3df51f..96f6399 100644 --- a/t/lib/DBICTest/Schema/Collection.pm +++ b/t/lib/DBICTest/Schema/Collection.pm @@ -1,30 +1,30 @@ -package # hide from PAUSE - DBICTest::Schema::Collection; - -use base qw/DBICTest::BaseResult/; - -__PACKAGE__->table('collection'); -__PACKAGE__->add_columns( - 'collectionid' => { - data_type => 'integer', - is_auto_increment => 1, - }, - 'name' => { - data_type => 'varchar', - size => 100, - }, -); -__PACKAGE__->set_primary_key('collectionid'); - -__PACKAGE__->has_many( collection_object => "DBICTest::Schema::CollectionObject", - { "foreign.collection" => "self.collectionid" } - ); -__PACKAGE__->many_to_many( objects => collection_object => "object" ); -__PACKAGE__->many_to_many( pointy_objects => collection_object => "object", - { where => { "object.type" => "pointy" } } - ); -__PACKAGE__->many_to_many( round_objects => collection_object => "object", - { where => { "object.type" => "round" } } - ); - -1; +package # hide from PAUSE + DBICTest::Schema::Collection; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('collection'); +__PACKAGE__->add_columns( + 'collectionid' => { + data_type => 'integer', + is_auto_increment => 1, + }, + 'name' => { + data_type => 'varchar', + size => 100, + }, +); +__PACKAGE__->set_primary_key('collectionid'); + +__PACKAGE__->has_many( collection_object => "DBICTest::Schema::CollectionObject", + { "foreign.collection" => "self.collectionid" } + ); +__PACKAGE__->many_to_many( objects => collection_object => "object" ); +__PACKAGE__->many_to_many( pointy_objects => collection_object => "object", + { where => { "object.type" => "pointy" } } + ); +__PACKAGE__->many_to_many( round_objects => collection_object => "object", + { where => { "object.type" => "round" } } + ); + +1; diff --git a/t/lib/DBICTest/Schema/CollectionObject.pm b/t/lib/DBICTest/Schema/CollectionObject.pm index df43c9c..446909c 100644 --- a/t/lib/DBICTest/Schema/CollectionObject.pm +++ b/t/lib/DBICTest/Schema/CollectionObject.pm @@ -1,24 +1,24 @@ -package # hide from PAUSE - DBICTest::Schema::CollectionObject; - -use base qw/DBICTest::BaseResult/; - -__PACKAGE__->table('collection_object'); -__PACKAGE__->add_columns( - 'collection' => { - data_type => 'integer', - }, - 'object' => { - data_type => 'integer', - }, -); -__PACKAGE__->set_primary_key(qw/collection object/); - -__PACKAGE__->belongs_to( collection => "DBICTest::Schema::Collection", - { "foreign.collectionid" => "self.collection" } - ); -__PACKAGE__->belongs_to( object => "DBICTest::Schema::TypedObject", - { "foreign.objectid" => "self.object" } - ); - -1; +package # hide from PAUSE + DBICTest::Schema::CollectionObject; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('collection_object'); +__PACKAGE__->add_columns( + 'collection' => { + data_type => 'integer', + }, + 'object' => { + data_type => 'integer', + }, +); +__PACKAGE__->set_primary_key(qw/collection object/); + +__PACKAGE__->belongs_to( collection => "DBICTest::Schema::Collection", + { "foreign.collectionid" => "self.collection" } + ); +__PACKAGE__->belongs_to( object => "DBICTest::Schema::TypedObject", + { "foreign.objectid" => "self.object" } + ); + +1; diff --git a/t/lib/DBICTest/Schema/Owners.pm b/t/lib/DBICTest/Schema/Owners.pm index 38aa025..0c05b1d 100644 --- a/t/lib/DBICTest/Schema/Owners.pm +++ b/t/lib/DBICTest/Schema/Owners.pm @@ -1,21 +1,21 @@ -package # hide from PAUSE - DBICTest::Schema::Owners; - -use base qw/DBICTest::BaseResult/; - -__PACKAGE__->table('owners'); -__PACKAGE__->add_columns( - 'ownerid' => { - data_type => 'integer', - is_auto_increment => 1, - }, - 'name' => { - data_type => 'varchar', - size => '100', - }, -); -__PACKAGE__->set_primary_key('ownerid'); - -__PACKAGE__->has_many(books => "DBICTest::Schema::BooksInLibrary", "owner"); - -1; +package # hide from PAUSE + DBICTest::Schema::Owners; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('owners'); +__PACKAGE__->add_columns( + 'ownerid' => { + data_type => 'integer', + is_auto_increment => 1, + }, + 'name' => { + data_type => 'varchar', + size => '100', + }, +); +__PACKAGE__->set_primary_key('ownerid'); + +__PACKAGE__->has_many(books => "DBICTest::Schema::BooksInLibrary", "owner"); + +1; diff --git a/t/lib/DBICTest/Schema/SelfRef.pm b/t/lib/DBICTest/Schema/SelfRef.pm index edcfe6c..c0e1476 100644 --- a/t/lib/DBICTest/Schema/SelfRef.pm +++ b/t/lib/DBICTest/Schema/SelfRef.pm @@ -1,21 +1,21 @@ -package # hide from PAUSE - DBICTest::Schema::SelfRef; - -use base qw/DBICTest::BaseResult/; - -__PACKAGE__->table('self_ref'); -__PACKAGE__->add_columns( - 'id' => { - data_type => 'integer', - is_auto_increment => 1, - }, - 'name' => { - data_type => 'varchar', - size => 100, - }, -); -__PACKAGE__->set_primary_key('id'); - -__PACKAGE__->has_many( aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref' ); - -1; +package # hide from PAUSE + DBICTest::Schema::SelfRef; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('self_ref'); +__PACKAGE__->add_columns( + 'id' => { + data_type => 'integer', + is_auto_increment => 1, + }, + 'name' => { + data_type => 'varchar', + size => 100, + }, +); +__PACKAGE__->set_primary_key('id'); + +__PACKAGE__->has_many( aliases => 'DBICTest::Schema::SelfRefAlias' => 'self_ref' ); + +1; diff --git a/t/lib/DBICTest/Schema/SelfRefAlias.pm b/t/lib/DBICTest/Schema/SelfRefAlias.pm index 2f7d105..40e181f 100644 --- a/t/lib/DBICTest/Schema/SelfRefAlias.pm +++ b/t/lib/DBICTest/Schema/SelfRefAlias.pm @@ -1,20 +1,20 @@ -package # hide from PAUSE - DBICTest::Schema::SelfRefAlias; - -use base qw/DBICTest::BaseResult/; - -__PACKAGE__->table('self_ref_alias'); -__PACKAGE__->add_columns( - 'self_ref' => { - data_type => 'integer', - }, - 'alias' => { - data_type => 'integer', - }, -); -__PACKAGE__->set_primary_key(qw/self_ref alias/); - -__PACKAGE__->belongs_to( self_ref => 'DBICTest::Schema::SelfRef' ); -__PACKAGE__->belongs_to( alias => 'DBICTest::Schema::SelfRef' ); - -1; +package # hide from PAUSE + DBICTest::Schema::SelfRefAlias; + +use base qw/DBICTest::BaseResult/; + +__PACKAGE__->table('self_ref_alias'); +__PACKAGE__->add_columns( + 'self_ref' => { + data_type => 'integer', + }, + 'alias' => { + data_type => 'integer', + }, +); +__PACKAGE__->set_primary_key(qw/self_ref alias/); + +__PACKAGE__->belongs_to( self_ref => 'DBICTest::Schema::SelfRef' ); +__PACKAGE__->belongs_to( alias => 'DBICTest::Schema::SelfRef' ); + +1;