1DBIx::Class::Helper::ReUssuelrtSCeotn:t:rViDibBruIttxue:ad:lCVPlieaerswls(:3D:)oHceulmpeenrt:a:tRieosnultSet::VirtualView(3)
2
3
4

NAME

6       DBIx::Class::Helper::ResultSet::VirtualView - Clean up your SQL
7       namespace (DEPRECATED)
8

SYNOPSIS

10        # note that this is normally a component for a ResultSet
11        package MySchema::ResultSet::Bar;
12
13        use strict;
14        use warnings;
15
16        use parent 'DBIx::Class::ResultSet';
17
18        __PACKAGE__->load_components('Helper::ResultSet::VirtualView');
19
20        # and then in code that uses the ResultSet Join with relation x
21        my $rs = $schema->resultset('Bar')->search({'x.name' => 'abc'},{ join => 'x' });
22
23        # 'x' now pollutes the query namespace
24
25        # So the following works as expected
26        my $ok_rs = $rs->search({'x.other' => 1});
27
28        # But this doesn't: instead of finding a 'Bar' related to two x rows (abc and
29        # def) we look for one row with contradictory terms and join in another table
30        # (aliased 'x_2') which we never use
31        my $broken_rs = $rs->search({'x.name' => 'def'});
32
33        my $rs2 = $rs->as_virtual_view;
34
35        # doesn't work - 'x' is no longer accessible in $rs2, having been sealed away
36        my $not_joined_rs = $rs2->search({'x.other' => 1});
37
38        # works as expected: finds a 'table' row related to two x rows (abc and def)
39        my $correctly_joined_rs = $rs2->search({'x.name' => 'def'});
40

DESCRIPTION

42       This component is will allow you to clean up your SQL namespace.  See
43       "NOTE" in DBIx::Class::Helper::ResultSet for a nice way to apply it to
44       your entire schema.
45

DEPRECATED

47       This component has been suplanted by
48       DBIx::Class::ResultSet::as_subselect_rs.  In the next major version (3)
49       we will begin issuing a warning on it's use.  In the major version
50       after that (4) we will remove it entirely.
51

METHODS

53   as_virtual_view
54       Act as a barrier to SQL symbols.  The resultset provided will be made
55       into a "virtual view" by including it as a subquery within the from
56       clause.  From this point on, any joined tables are inaccessible to
57       ->search on the resultset (as if it were simply where-filtered without
58       joins).  See "SYNOPSIS" for example.
59

NOTE

61       You don't have to use this as a Component.  If you prefer you can use
62       it in the following manner:
63
64        # in code using ResultSet:
65        use DBIx::Class:Helper::VirtualView;
66
67        my $new_rs = DBIx::Class::Helper::VirtualView::as_virtual_view($rs);
68

THANKS

70       Thanks to ijw from #dbix-class for the idea for this helper (originally
71       called seal), most of the code, and most of the documentation.
72

AUTHOR

74       Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
75
77       This software is copyright (c) 2019 by Arthur Axel "fREW" Schmidt.
78
79       This is free software; you can redistribute it and/or modify it under
80       the same terms as the Perl 5 programming language system itself.
81
82
83
84perl v5.30.1                    DB2I0x2:0:-C0l1a-s2s9::Helper::ResultSet::VirtualView(3)
Impressum