Debian Codegraph @

t/resultset/inflatemap_abuse.t

raw symbols SCIP
1 use strictscip-perl cpan DBIx-Class 0.082844 strict/;
2 use warningsscip-perl cpan DBIx-Class 0.082844 warnings/;
3
4 use Test::Morescip-perl cpan DBIx-Class 0.082844 Test/More/;
5 use Test::Exceptionscip-perl cpan DBIx-Class 0.082844 Test/Exception/;
6 use libscip-perl cpan DBIx-Class 0.082844 lib/ qw(t/lib);
7 use DBICTestscip-perl cpan DBIx-Class 0.082844 DBICTest/;
8
9 # From http://lists.scsys.co.uk/pipermail/dbix-class/2013-February/011119.html
10 #
11 # > Right, at this point we have an "undefined situation turned into an
12 # > unplanned feature", therefore 0.08242 will downgrade the exception to a
13 # > single-warning-per-process. This seems like a sane middle ground for
14 # > "you gave me an 'as' that worked by accident before - fix it at your
15 # > convenience".
16 #
17 # When the things were reshuffled it became apparent implementing a warning
18 # for the HRI case *only* is going to complicate the code a lot, without
19 # adding much benefit at this point. So just make sure everything works the
20 # way it used to and move on
21
22
23 my $s = DBICTest->init_schemascip-perl cpan DBIx-Class 0.082844 DBICTest/init_schema().;
24
25 my $rs_2nd_track = $s->resultsetscip-perl cpan DBIx-Class 0.082844 DBICTest/resultset().('Track')->searchscip-perl cpan DBIx-Class 0.082844 main/search().(
26 { 'me.position' => 2 },
27 {
28 join => { cd => 'artist' },
29 columns => [ 'me.title', { 'artist.cdtitle' => 'cd.title' }, 'artist.name' ],
30 order_by => [ 'artist.name', { -desc => 'cd.cdid' }, 'me.trackid' ],
31 }
32 );
33
34 is_deeplyscip-perl cpan DBIx-Class 0.082844 main/is_deeply(). (
35 [ mapscip-perl cpan DBIx-Class 0.082844 main/map(). { $_scip-perl cpan DBIx-Class 0.082844 main/$_.->[-1] } $rs_2nd_track->cursorscip-perl cpan DBIx-Class 0.082844 main/cursor().->allscip-perl cpan DBIx-Class 0.082844 main/all(). ],
36 [ ('Caterwauler McCrae') x 3, 'Random Boy Band', 'We Are Goth' ],
37 'Artist name cartesian product correct off cursor',
38 );
39
40 is_deeplyscip-perl cpan DBIx-Class 0.082844 main/is_deeply(). (
41 $rs_2nd_track->all_hriscip-perl cpan DBIx-Class 0.082844 main/all_hri().,
42 [
43 {
44 artist => { cdtitle => "Caterwaulin' Blues", name => "Caterwauler McCrae" },
45 title => "Howlin"
46 },
47 {
48 artist => { cdtitle => "Forkful of bees", name => "Caterwauler McCrae" },
49 title => "Stripy"
50 },
51 {
52 artist => { cdtitle => "Spoonful of bees", name => "Caterwauler McCrae" },
53 title => "Apiary"
54 },
55 {
56 artist => { cdtitle => "Generic Manufactured Singles", name => "Random Boy Band" },
57 title => "Boring Song"
58 },
59 {
60 artist => { cdtitle => "Come Be Depressed With Us", name => "We Are Goth" },
61 title => "Under The Weather"
62 }
63 ],
64 'HRI with invalid inflate map works'
65 );
66
67 throws_okscip-perl cpan DBIx-Class 0.082844 main/throws_ok().
68 { $rs_2nd_track->nextscip-perl cpan DBIx-Class 0.082844 main/next(). }
69 qr!\QInflation into non-existent relationship 'artist' of 'Track' requested, check the inflation specification (columns/as) ending in '...artist.name'!,
70 'Correct exception on illegal ::Row inflation attempt'
71 ;
72
73 # make sure has_many column redirection does not do weird stuff when collapse is requested
74 for my $pref_args (
75 { prefetch => 'cds'},
76 { collapse => 1 }
77 ) {
78 for my $col_and_join_args (
79 { '+columns' => { 'cd_title' => 'cds_2.title' }, join => [ 'cds', 'cds' ] },
80 { '+columns' => { 'cd_title' => 'cds.title' }, join => 'cds' },
81 { '+columns' => { 'cd_gr_name' => 'genre.name' }, join => { cds => 'genre' } },
82 ) {
83 for my $call (qw(next all first)) {
84
85 my $weird_rs = $s->resultsetscip-perl cpan DBIx-Class 0.082844 DBICTest/resultset().('Artist')->searchscip-perl cpan DBIx-Class 0.082844 main/search().({}, {
86 %$col_and_join_args, %$pref_args,
87 });
88
89 throws_okscip-perl cpan DBIx-Class 0.082844 main/throws_ok().
90 { $weird_rs->$callscip-perl cpan DBIx-Class 0.082844 main/$call(). }
91 qr/\QResult collapse not possible - selection from a has_many source redirected to the main object/
92 for (1,2);
93 }
94 }
95 }
96
97 done_testing;