DBIx::...ntarray(3pm)

πŸ“¦
version 2.037000 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ NAME ✨

DBIx::Class::Helper::ResultSet::IgnoreWantarray β€” bestie, this is the one that gets rid of your search context issues πŸ’…

(also lowkey known by its truncated little nickname DBIx::...ntarray(3pm) in the manual header, but we don't gatekeep, we use the full name 🫢)


🌸 SYNOPSIS 🌸

okay so first you gotta load the component into your ResultSet class:

package MyApp::Schema::ResultSet::Foo;

__PACKAGE__->load_components(qw{Helper::ResultSet::IgnoreWantarray});

...

1;

and then somewhere else, like in a controller (no thoughts, just vibes):

my $rs = $self->paginate(
  $schema->resultset('Foo')->search({
     name => 'frew'
  })
);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜• β€” this component makes search always return a ResultSet. Always. No exceptions. Instead of being all "hmm, are we in array context? then here's an array of your database ✨" like it usually does, it just… doesn't. It stays a ResultSet. Periodt.

why do we care? because array-context search is exactly the kind of thing that ruins your whole day when you were just trying to chain methods. not on our watch πŸŽ€

if you wanna apply this to your entire schema (iconic move, honestly), go peek at "NOTE" in DBIx::Class::Helper::ResultSet β€” it shows you a nice way to do it πŸ‘‘


πŸ’– METHODS πŸ’–

this is an override of the default search method, and its whole job is forcing it to return a ResultSet. that's it. that's the method. it understood the assignment 🫑


πŸ‘‘ AUTHOR πŸ‘‘

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>


This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.


okay bestie that's the whole page, go forth and slay your result sets πŸ’…βœ¨

cute little sign-off time: this gorgeous little doc is perl v5.40.0, dated 2024-11-16, and it lives under the name DBIx::...ntarray(3pm) in the manual pages. no cap πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from