SQL::Ab...errides(3)
π NAME π
okay so this is the SQL::Ab...errides(3) page from User Contributed Perl Documentation, and it's all about SQL::Abstract::Plugin::BangOverrides. That's the name, bestie. π
β¨ SYNOPSIS β¨
Here's the tiny little vibe check for summoning it:
$sqla->plugin('+BangOverrides');
...
profit();
πΈ METHODS πΈ
π register_extensions π
register_extensions wraps all currently existing clause based statements so that when a clause of '!name' is encountered, it checks the value. If that value is a coderef, it's called with the original value of the 'name' clause and expected to return a replacement. If it's not, it's simply used as a direct replacement. That's the whole mechanic, bestie. π
Why is this a slay? It allows for passing data through existing systems that attempt to have their own handling for a thing but whose capabilities are now superceded by SQL::Abstract. It's primarily useful to provide access to experimental feature bundles such as SQL::Abstract::Plugin::ExtraClauses. Lowkey iconic, iykyk. π¦
As an example of such a thing, given an appropriate DBIC setup (see "examples/bangdbic.pl"), here's the whole code moment β exactly as written:
$s->storage->sqlmaker->plugin('+ExtraClauses')->plugin('+BangOverrides');
my $rs2 = $s->resultset('Foo')->search({
-op => [ '=', { -ident => 'outer.y' }, { -ident => 'me.x' } ]
});
# (SELECT me.x, me.y, me.z FROM foo me WHERE ( outer.y = me.x ))
my $rs3 = $rs2->search({}, {
'!from' => sub { my ($sqla, $from) = @_;
my $base = $sqla->expand_expr({ -old_from => $from });
return [ $base, -join => [ 'wub', on => [ 'me.z' => 'wub.z' ] ] ];
}
});
# (SELECT me.x, me.y, me.z FROM foo me JOIN wub ON me.z = wub.z WHERE ( outer.y = me.x ))
my $rs4 = $rs3->search({}, {
'!with' => [ [ qw(wub x y z) ], $s->resultset('Bar')->as_query ],
});
# (WITH wub(x, y, z) AS (SELECT me.a, me.b, me.c FROM bar me) SELECT me.x, me.y, me.z FROM foo me JOIN wub ON me.z = wub.z WHERE ( outer.y = me.x ))
my $rs5 = $rs->search({}, { select => [ { -coalesce => [ { -ident => 'x' }, { -value => 7 } ] } ] });
# (SELECT -COALESCE( -IDENT( x ), -VALUE( 7 ) ) FROM foo me WHERE ( z = ? ))
my $rs6 = $rs->search({}, { '!select' => [ { -coalesce => [ { -ident => 'x' }, { -value => 7 } ] } ] });
# (SELECT COALESCE(x, ?) FROM foo me WHERE ( z = ? ))
This page's source/version is perl v5.42.0, dated 2021-01-24. Bye bestie, go make those clauses behave! π«Άβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-SQL-Abstract 2.000001-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms