Added doc patch about race condition in find_or_create from MNDRIX
[dbsrgits/DBIx-Class.git] / t / 96_is_deteministic_value.t
CommitLineData
561f003c 1use strict;
2use warnings;
3
4# 6 tests
5
6use Test::More qw(no_plan);
7use lib qw(t/lib);
8use DBICTest;
9use DateTime;
10use DateTime::Format::Strptime;
11use Test::Exception;
12
13my $schema = DBICTest->init_schema();
14my $artist_rs = $schema->resultset('Artist');
15my $cd_rs = $schema->resultset('CD');
16
17 {
18 my $cd;
19 lives_ok {
20 $cd = $cd_rs->search({ year => {'=' => 1999}})->create
21 ({
22 artist => {name => 'Guillermo1'},
23 title => 'Guillermo 1',
24 });
25 };
26 is($cd->year, 1999);
27 }
28
29 {
30 my $formatter = DateTime::Format::Strptime->new(pattern => '%Y');
31 my $dt = DateTime->new(year => 2006, month => 06, day => 06,
32 formatter => $formatter );
33 my $cd;
34 lives_ok {
35 $cd = $cd_rs->search({ year => $dt})->create
36 ({
37 artist => {name => 'Guillermo2'},
38 title => 'Guillermo 2',
39 });
40 };
41 is($cd->year, 2006);
42 }
43
44
45{
46 my $artist;
47 lives_ok {
48 $artist = $artist_rs->search({ name => {'!=' => 'Killer'}})
49 ->create({artistid => undef});
50 };
51 is($artist->name, undef);
52}
53
54
55{
56 my $artist;
57 lives_ok {
58 $artist = $artist_rs->search({ name => [ q/ some stupid names here/]})
59 ->create({artistid => undef});
60 };
61 is($artist->name, undef);
62}
63
64
651;