X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Flib%2FDBICTest%2FSchema%2FArtist.pm;h=62bd9468b4a1c361002655e544de96166e59702e;hb=84f7e8a1c6303091d753572648e37d3bd7270181;hp=ae92606aff99f15b5608d15e319f208bd32db681;hpb=c193d1d2d7138948d5b5d8b2b7ae19e12edb2cb0;p=dbsrgits%2FDBIx-Class.git diff --git a/t/lib/DBICTest/Schema/Artist.pm b/t/lib/DBICTest/Schema/Artist.pm index ae92606..62bd946 100644 --- a/t/lib/DBICTest/Schema/Artist.pm +++ b/t/lib/DBICTest/Schema/Artist.pm @@ -1,7 +1,7 @@ package # hide from PAUSE DBICTest::Schema::Artist; -use base 'DBIx::Class::Core'; +use base qw/DBICTest::BaseResult/; __PACKAGE__->table('artist'); __PACKAGE__->source_info({ @@ -19,8 +19,20 @@ __PACKAGE__->add_columns( size => 100, is_nullable => 1, }, + rank => { + data_type => 'integer', + default_value => 13, + }, + charfield => { + data_type => 'char', + size => 10, + is_nullable => 1, + }, ); __PACKAGE__->set_primary_key('artistid'); +__PACKAGE__->add_unique_constraint(['name']); +__PACKAGE__->add_unique_constraint(artist => ['artistid']); # do not remove, part of a test + __PACKAGE__->mk_classdata('field_name_for', { artistid => 'primary key', @@ -29,11 +41,14 @@ __PACKAGE__->mk_classdata('field_name_for', { __PACKAGE__->has_many( cds => 'DBICTest::Schema::CD', undef, - { order_by => 'year' }, + { order_by => { -asc => 'year'} }, ); __PACKAGE__->has_many( cds_unordered => 'DBICTest::Schema::CD' ); +__PACKAGE__->has_many( + cds_very_very_very_long_relationship_name => 'DBICTest::Schema::CD' +); __PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' ); __PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' ); @@ -44,14 +59,26 @@ __PACKAGE__->has_many( { cascade_copy => 0 } # this would *so* not make sense ); +__PACKAGE__->has_many( + artwork_to_artist => 'DBICTest::Schema::Artwork_to_Artist' => 'artist_id' +); +__PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork'); + + sub sqlt_deploy_hook { my ($self, $sqlt_table) = @_; - if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/ ) { - $sqlt_table->add_index( name => 'artist_name', fields => ['name'] ) + $sqlt_table->add_index( name => 'artist_name_hookidx', fields => ['name'] ) or die $sqlt_table->error; } } +sub store_column { + my ($self, $name, $value) = @_; + $value = 'X '.$value if ($name eq 'name' && $value && $value =~ /(X )?store_column test/); + $self->next::method($name, $value); +} + + 1;