Switch t/relationship/core.t $@ checks to Test::Exception
[dbsrgits/DBIx-Class.git] / t / lib / DBICTest / Schema / Artist.pm
CommitLineData
c6d74d3e 1package # hide from PAUSE
2 DBICTest::Schema::Artist;
a02675cd 3
660cf1be 4use base qw/DBICTest::BaseResult/;
a02675cd 5
ff657a43 6__PACKAGE__->table('artist');
a48e92d7 7__PACKAGE__->source_info({
8 "source_info_key_A" => "source_info_value_A",
9 "source_info_key_B" => "source_info_value_B",
10 "source_info_key_C" => "source_info_value_C",
11});
ff657a43 12__PACKAGE__->add_columns(
0009fa49 13 'artistid' => {
14 data_type => 'integer',
6e399b4f 15 is_auto_increment => 1,
0009fa49 16 },
17 'name' => {
18 data_type => 'varchar',
cb561d1a 19 size => 100,
0009fa49 20 is_nullable => 1,
21 },
39da2a2b 22 rank => {
23 data_type => 'integer',
24 default_value => 13,
25 },
a0dd8679 26 charfield => {
27 data_type => 'char',
28 size => 10,
29 is_nullable => 1,
30 },
0009fa49 31);
ff657a43 32__PACKAGE__->set_primary_key('artistid');
1a625304 33__PACKAGE__->add_unique_constraint(artist => ['artistid']); # do not remove, part of a test
a02675cd 34
90e6de6c 35__PACKAGE__->mk_classdata('field_name_for', {
36 artistid => 'primary key',
37 name => 'artist name',
38});
39
ff657a43 40__PACKAGE__->has_many(
41 cds => 'DBICTest::Schema::CD', undef,
d2fcb9b3 42 { order_by => { -asc => 'year'} },
ff657a43 43);
c193d1d2 44__PACKAGE__->has_many(
45 cds_unordered => 'DBICTest::Schema::CD'
46);
62d4dbae 47__PACKAGE__->has_many(
48 cds_very_very_very_long_relationship_name => 'DBICTest::Schema::CD'
49);
ff657a43 50
51__PACKAGE__->has_many( twokeys => 'DBICTest::Schema::TwoKeys' );
52__PACKAGE__->has_many( onekeys => 'DBICTest::Schema::OneKey' );
53
54__PACKAGE__->has_many(
55 artist_undirected_maps => 'DBICTest::Schema::ArtistUndirectedMap',
56 [ {'foreign.id1' => 'self.artistid'}, {'foreign.id2' => 'self.artistid'} ],
57 { cascade_copy => 0 } # this would *so* not make sense
58);
59
d5633096 60__PACKAGE__->has_many(
04e0d6ef 61 artwork_to_artist => 'DBICTest::Schema::Artwork_to_Artist' => 'artist_id'
d5633096 62);
04e0d6ef 63__PACKAGE__->many_to_many('artworks', 'artwork_to_artist', 'artwork');
d5633096 64
65
aaf2403d 66sub sqlt_deploy_hook {
67 my ($self, $sqlt_table) = @_;
68
d6c79cb3 69 if ($sqlt_table->schema->translator->producer_type =~ /SQLite$/ ) {
1f5bf324 70 $sqlt_table->add_index( name => 'artist_name_hookidx', fields => ['name'] )
d6c79cb3 71 or die $sqlt_table->error;
72 }
aaf2403d 73}
c385ecea 74
52c53388 75sub store_column {
76 my ($self, $name, $value) = @_;
a22688ab 77 $value = 'X '.$value if ($name eq 'name' && $value && $value =~ /(X )?store_column test/);
52c53388 78 $self->next::method($name, $value);
79}
80
81
a02675cd 821;