Store the final calculated select args in the original $rs
[dbsrgits/DBIx-Class.git] / t / resultset / inflatemap_abuse.t
CommitLineData
25a942fa 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use lib qw(t/lib);
7use 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
23my $s = DBICTest->init_schema;
24
25my $rs_2nd_track = $s->resultset('Track')->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',
31 }
32);
33
34is_deeply (
35 [ map { $_->[-1] } $rs_2nd_track->cursor->all ],
36 [ ('Caterwauler McCrae') x 3, 'Random Boy Band', 'We Are Goth' ],
37 'Artist name cartesian product correct off cursor',
38);
39
40is_deeply (
41 $rs_2nd_track->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
67throws_ok
68 { $rs_2nd_track->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
73done_testing;