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