Jifty:...Unique(3pm)

πŸ“¦
version 0.78 Β· 2 versions
  • 0.78 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.78 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Jifty::DBI::Collection::Unique πŸ’–

okay bestie, welcome to the manual page for Jifty::DBI::Collection::Unique (that's the 3pm one, perl module territory, you already knew that tho). It's giving "tiny module, big save." Let's get into it. πŸ¦‹


🌟 NAME 🌟

Jifty::DBI::Collection::Unique β€” literally just here to make sure the records in your collection are unique. No dupes. No doubles. Periodt. πŸ’…


✨ SYNOPSIS ✨

okay so here's the whole vibe, copy-paste ready:

package Foo::Collection;
use base 'Jifty::DBI::Collection';

use Jifty::DBI::Collection::Unique; # mixin

my $collection = Foo::Collection->New();
$collection->SetupComplicatedJoins;
$collection->OrderByMagic;

while (my $thing = $collection->Next) {
    # $thing is going to be distinct
}

see how it's a mixin? you just use it and it slides right into your collection like it always belonged there. 🫢


πŸ’« DESCRIPTION πŸ’«

So here's the tea, and it's lowkey a lil sad. 😭 Right now, Jifty::DBI makes exceptions for databases that can't handle both SELECT DISTINCT and ordering in the same statement β€” and when that happens, it just drops the DISTINCT requirement. Which means... yeah. You can get the same row twice. Not the vibe you might be going for.

If that's your situation, use this module as a mix-in, and it will hand you an AddRecord method that makes sure a record will not appear twice in the same search. No cap. πŸŽ€


πŸ”₯ METHODS πŸ”₯

πŸ“ add_record

Overrides add_record to ensure uniqueness. That's it, that's the whole job, and it does it flawlessly. πŸ‘‘

heads up bestie: this is an override, so you're not getting the original add_record behaviour back β€” that's literally the point of the mixin. πŸ’€

πŸ‘‘ AUTHOR πŸ‘‘

Simon Cozens. iconic behaviour, we stan. 🌸


Copyright 2005 Best Practical Solutions, LLC

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. (free software, as it should be πŸ’š)


and that's the whole page, bestie β€” no notes, no skipped sections, no missing flags (there aren't any flags, it's a Perl module, we're off the hook 😌).

this lil doc came to you courtesy of perl v5.34.0, dated 2022-06-15 β€” bye diva, go make your records distinct πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from