Fix silent failures on autoinc PK without an is_auto_increment attribute
[dbsrgits/DBIx-Class.git] / t / cdbi / copy.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
83eef562 2use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat';
3
e60dc79f 4use strict;
4a233f30 5use warnings;
83eef562 6
e60dc79f 7use Test::More;
8
a40329c4 9use lib 't/cdbi/testlib';
e60dc79f 10
11{
8273e845 12 package # hide from PAUSE
e60dc79f 13 MyFilm;
14
97d61088 15 use base 'DBIC::Test::SQLite';
e60dc79f 16 use strict;
17
18 __PACKAGE__->set_table('Movies');
19 __PACKAGE__->columns(All => qw(id title));
20
7305f6f9 21 # Disables the implicit autoinc-on-non-supplied-pk behavior
22 # (and the warning that goes with it)
23 # This is the same behavior as it was pre 0.082900
24 __PACKAGE__->column_info('id')->{is_auto_increment} = 0;
25
e60dc79f 26 sub create_sql {
27 return qq{
28 id INTEGER PRIMARY KEY AUTOINCREMENT,
29 title VARCHAR(255)
30 }
31 }
32}
33
34my $film = MyFilm->create({ title => "For Your Eyes Only" });
35ok $film->id;
36
37my $new_film = $film->copy;
38ok $new_film->id;
39isnt $new_film->id, $film->id, "copy() gets new primary key";
40
41$new_film = $film->copy(42);
42is $new_film->id, 42, "copy() with new id";
43
d9bd5195 44done_testing;