Commit | Line | Data |
83eef562 |
1 | use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; |
2 | |
e60dc79f |
3 | use strict; |
4a233f30 |
4 | use warnings; |
83eef562 |
5 | |
e60dc79f |
6 | use Test::More; |
7 | |
a40329c4 |
8 | use lib 't/cdbi/testlib'; |
e60dc79f |
9 | |
10 | { |
8273e845 |
11 | package # hide from PAUSE |
e60dc79f |
12 | MyFilm; |
13 | |
97d61088 |
14 | use base 'DBIC::Test::SQLite'; |
e60dc79f |
15 | use strict; |
16 | |
17 | __PACKAGE__->set_table('Movies'); |
18 | __PACKAGE__->columns(All => qw(id title)); |
19 | |
20 | sub create_sql { |
21 | return qq{ |
22 | id INTEGER PRIMARY KEY AUTOINCREMENT, |
23 | title VARCHAR(255) |
24 | } |
25 | } |
26 | } |
27 | |
28 | my $film = MyFilm->create({ title => "For Your Eyes Only" }); |
29 | ok $film->id; |
30 | |
31 | my $new_film = $film->copy; |
32 | ok $new_film->id; |
33 | isnt $new_film->id, $film->id, "copy() gets new primary key"; |
34 | |
35 | $new_film = $film->copy(42); |
36 | is $new_film->id, 42, "copy() with new id"; |
37 | |
d9bd5195 |
38 | done_testing; |