Commit | Line | Data |
e9bd1473 |
1 | use warnings; |
2 | |
3 | use Test::More; |
4 | use Test::Exception; |
5 | use lib qw(t/lib); |
6 | use DBICTest; |
7 | use Data::Dumper; |
8 | |
9 | my $schema = DBICTest->init_schema(); |
10 | |
11 | my $orig_debug = $schema->storage->debug; |
12 | |
13 | use IO::File; |
14 | |
15 | BEGIN { |
16 | eval "use DBD::SQLite"; |
17 | plan $@ |
18 | ? ( skip_all => 'needs DBD::SQLite for testing' ) |
19 | : ( tests => 3 ); |
20 | } |
21 | |
22 | # figure out if we've got a version of sqlite that is older than 3.2.6, in |
23 | # which case COUNT(DISTINCT()) doesn't work |
24 | my $is_broken_sqlite = 0; |
25 | my ($sqlite_major_ver,$sqlite_minor_ver,$sqlite_patch_ver) = |
26 | split /\./, $schema->storage->dbh->get_info(18); |
27 | if( $schema->storage->dbh->get_info(17) eq 'SQLite' && |
28 | ( ($sqlite_major_ver < 3) || |
29 | ($sqlite_major_ver == 3 && $sqlite_minor_ver < 2) || |
30 | ($sqlite_major_ver == 3 && $sqlite_minor_ver == 2 && $sqlite_patch_ver < 6) ) ) { |
31 | $is_broken_sqlite = 1; |
32 | } |
33 | |
34 | # bug in 0.07000 caused attr (join/prefetch) to be modifed by search |
35 | # so we check the search & attr arrays are not modified |
36 | my $search = { 'artist.name' => 'Caterwauler McCrae' }; |
37 | my $attr = { prefetch => [ qw/artist liner_notes/ ], |
38 | order_by => 'me.cdid' }; |
39 | my $search_str = Dumper($search); |
40 | my $attr_str = Dumper($attr); |
41 | |
42 | my $rs = $schema->resultset("CD")->search($search, $attr); |
43 | |
44 | is(Dumper($search), $search_str, 'Search hash untouched after search()'); |
45 | is(Dumper($attr), $attr_str, 'Attribute hash untouched after search()'); |
46 | cmp_ok($rs + 0, '==', 3, 'Correct number of records returned'); |