--- /dev/null
+use Test::More;
+use lib qw(t/lib);
+use DBICTest;
+use DBICTest::HelperRels;
+
+require "t/run/26positioned.tl";
+run_tests(DBICTest->schema);
use base 'DBIx::Class::Core';
-__PACKAGE__->load_components('PK::Auto');
+__PACKAGE__->load_components('Positioned','PK::Auto');
DBICTest::Schema::Artist->table('artist');
DBICTest::Schema::Artist->add_columns(
size => 100,
is_nullable => 1,
},
+ position => {
+ data_type => 'integer',
+ },
);
DBICTest::Schema::Artist->set_primary_key('artistid');
+__PACKAGE__->position_column('position');
__PACKAGE__->mk_classdata('field_name_for', {
artistid => 'primary key',
name => 'artist name',
+ position => 'list position',
});
1;
--
CREATE TABLE artist (
artistid INTEGER PRIMARY KEY NOT NULL,
- name varchar
+ name varchar,
+ position INTEGER
);
--
'data_type' => 'varchar',
'is_nullable' => 0,
'size' => undef,
- }
+ },
+ 'position' => {
+ 'data_type' => 'INTEGER',
+ 'is_nullable' => 0,
+ 'size' => undef,
+ },
};
is_deeply($type_info, $test_type_info, 'columns_info_for - column data types');
--- /dev/null
+# vim: filetype=perl
+
+sub run_tests {
+
+ my $schema = shift;
+ my $artists = $schema->resultset("Artist")->search({},{order_by=>'position'});
+
+ plan tests => $artists->count();
+
+ my $expected_position = 0;
+ while (my $artist = $artists->next()) {
+ $expected_position ++;
+ ok( ($artist->position()==$expected_position), 'default positions set as expected' );
+ }
+}
+
+1;