On Tue, Apr 18, 2017 at 06:59:48PM +0300, Vladimir Melnik wrote:
> Hello,
>
> And one more question, if anyone doesn't mind. :-)
>
> Is there an elegant way to apply a Result's method to the whole ResultSet?
>
> In other words, here's what I have to do:
> # MyApp::Schema::Result::Foo->has_
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 muc
Oh, and this will work, almost. You don't need the "->all". The
has_many('bars') relation creates a 'bars' method on each Foo Result object:
foreach my $r_bar (map { $_->bars } $rs_foo->all) {
$r_bar->some_method;
}
For speed, prefetch bars.
> On 18 Apr 2017, at 16:59, Vladimir Melnik
If I was developing the schema, in addition to the relation you show, in
Result::Bar I'd have:
__PACKAGE__->belongs_to('foo', 'MyApp::Schema::Result::Foo', { ... });
Then search for all the bars with a particular foo (you use the name of the
relation, not the table) property:
foreach my $r
Hello,
And one more question, if anyone doesn't mind. :-)
Is there an elegant way to apply a Result's method to the whole ResultSet?
In other words, here's what I have to do:
# MyApp::Schema::Result::Foo->has_many('bars',
'MyApp::Schema::Result::Bar', { ... });
my $rs_foo = $sch
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!
--
V.Melnik
Vladimir Melnik writes:
> Hello,
>
> Is that possible to merge multiple ResultSets into one? For example,
> I’ve got 3 different ResultSets (as the yields of 3 different
> SQL-queries), but I’m pretty sure that they are based on the same
> class. Yes, I can work with their Results as with element
Hello,
Is that possible to merge multiple ResultSets into one? For example, I’ve got 3
different ResultSets (as the yields of 3 different SQL-queries), but I’m pretty
sure that they are based on the same class. Yes, I can work with their Results
as with elements of a list, but sometimes it woul