--- /dev/null
+use warnings;
+use strict;
+
+use Test::More;
+
+use lib qw(t/lib);
+use DBICTest;
+
+my $schema = DBICTest->init_schema();
+
+TODO: {
+ local $TODO = 'call accessors when calling create() or update()';
+
+ my $row =
+ $schema->resultset('Track')->new_result( { title => 'foo', cd => 1 } );
+ $row->increment(1);
+ $row->insert;
+ is( $row->increment, 2 );
+
+ $row =
+ $schema->resultset('Track')
+ ->create( { title => 'bar', cd => 1, increment => 1 } );
+ is( $row->increment, 2 );
+
+ # $row isa DBICTest::Schema::Track
+ $row->get_from_storage;
+ is( $row->increment, 2 );
+
+ $row->update( { increment => 3 } );
+ $row->get_from_storage;
+ is( $row->increment, 4 );
+
+ $row->increment(3);
+ $row->get_from_storage;
+ is( $row->increment, 4 );
+
+ eval {
+ $row =
+ $schema->resultset('Track')
+ ->create( { title => 'bar', cd => 2, set_increment => 1 } );
+ };
+ ok( !$@, 'lives ok' );
+ is( $row->increment, 1 );
+
+}
+
+done_testing;
data_type => 'smalldatetime',
is_nullable => 1
},
+ increment => {
+ data_type => 'integer',
+ is_nullable => 1,
+ accessor => '_increment',
+ }
);
__PACKAGE__->set_primary_key('trackid');
__PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
__PACKAGE__->might_have( lyrics => 'DBICTest::Schema::Lyrics', 'track_id' );
+sub increment {
+ my $self = shift;
+ if(@_) {
+ return $self->_increment($_[0] + 1);
+ }
+ return $self->_increment();
+}
+
+sub set_increment {
+ my $self = shift;
+ if(@_) {
+ return $self->_increment($_[0]);
+ }
+ return $self->_increment();
+}
+
1;
title varchar(100) NOT NULL,
last_updated_on datetime,
last_updated_at datetime,
- small_dt smalldatetime
+ small_dt smalldatetime,
+ increment integer
);
CREATE INDEX track_idx_cd ON track (cd);
'(
SELECT
cds.cdid, cds.artist, cds.title, cds.year, cds.genreid, cds.single_track,
- single_track.trackid, single_track.cd, single_track.position, single_track.title, single_track.last_updated_on, single_track.last_updated_at, single_track.small_dt,
- single_track_2.trackid, single_track_2.cd, single_track_2.position, single_track_2.title, single_track_2.last_updated_on, single_track_2.last_updated_at, single_track_2.small_dt,
+ single_track.trackid, single_track.cd, single_track.position, single_track.title, single_track.last_updated_on, single_track.last_updated_at, single_track.small_dt, single_track.increment,
+ single_track_2.trackid, single_track_2.cd, single_track_2.position, single_track_2.title, single_track_2.last_updated_on, single_track_2.last_updated_at, single_track_2.small_dt, single_track_2.increment,
cd.cdid, cd.artist, cd.title, cd.year, cd.genreid, cd.single_track
FROM artist me
LEFT JOIN cd cds ON cds.artist = me.artistid
$most_tracks_rs->as_query,
'(
SELECT me.cdid, me.track_count,
- tracks.trackid, tracks.cd, tracks.position, tracks.title, tracks.last_updated_on, tracks.last_updated_at, tracks.small_dt,
+ tracks.trackid, tracks.cd, tracks.position, tracks.title, tracks.last_updated_on, tracks.last_updated_at, tracks.small_dt, tracks.increment,
liner_notes.liner_id, liner_notes.notes
FROM (
SELECT me.cdid, COUNT( tracks.trackid ) AS track_count