[Dbix-class] Merging ResultSets

Mitchell Elutovich melutovich at gmail.com
Wed Apr 19 09:52:25 GMT 2017


Matt will your way though not have multiple trips to the db?

On Wed, Apr 19, 2017 at 3:17 AM, Matt S Trout <mst at shadowcat.co.uk> wrote:

> On Tue, Apr 18, 2017 at 05:20:55PM +0300, Vladimir Melnik wrote:
> > On Tue, Apr 18, 2017 at 02:43:55PM +0100, Dagfinn Ilmari Mannsåker wrote:
> > > What you are looking for is the 'union_all' method from
> > > https://metacpan.org/pod/DBIx::Class::Helper::ResultSet::SetOperations
> >
> > Thank you very much, it's exactly what I've been looking for!
>
> Note that if you don't need an actual UNION query you can also do -
>
>   my $merged = $schema->resultset('Foo');
>   $merged->set_cache([ map $_->all, $rs1, $rs2, $rs3 ]);
>
> and then iterating $merged will just use the cache.
>
> This may or may not be better, depending on your goal.
>
> --
> Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a
> clue
>
> http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_
> mst/
>
> Email me now on mst (at) shadowcat.co.uk and let's chat about how our CPAN
> commercial support, training and consultancy packages could help your team.
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive: http://www.grokbase.com/group/
> dbix-class at lists.scsys.co.uk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20170419/2a7f5ad8/attachment-0001.htm>


More information about the DBIx-Class mailing list