Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does DBIx::Class do unions?

I haven't found a way to do unions with DBIx::Class other than using a view and writing out the SQL manually. This seems strange to me. I feel like there should be some way to union two ResultSets without a lot of extra work because set addition and subtraction are such a core part of SQL. Is there an easier way to do unions? If not, why not?

like image 407
Eric Johnson Avatar asked Oct 26 '11 08:10

Eric Johnson


1 Answers

DBIx::Class::Helper::ResultSet::SetOperations

my $rs1 = $rs->search({ foo => 'bar' });  
my $rs2 = $rs->search({ baz => 'biff' });  
for ($rs1->union($rs2)->all) { ... }
like image 98
aartist Avatar answered Sep 28 '22 06:09

aartist