1SQL::Abstract::Plugin::UBsaenrgOCvoenrtrriidbeust(e3d)PSeQrLl::DAobcsutmreanctta:t:iPolnugin::BangOverrides(3)
2
3
4

NAME

6       SQL::Abstract::Plugin::BangOverrides
7
8   SYNOPSIS
9         $sqla->plugin('+BangOverrides');
10         ...
11         profit();
12

METHODS

14   register_extensions
15       Wraps all currently existing clause based statements such that when a
16       clause of '!name' is encountered, if its value is a coderef, it's
17       called with the original value of the 'name' clause and expected to
18       return a replacement, and if not, it's simply used as a direct
19       replacement.
20
21       This allows for passing data through existing systems that attempt to
22       have their own handling for thing but whose capabilities are now
23       superceded by SQL::Abstract, and is primarily useful to provide access
24       to experimental feature bundles such as
25       SQL::Abstract::Plugin::ExtraClauses.
26
27       As an example of such a thing, given an appropriate DBIC setup (see
28       "examples/bangdbic.pl"):
29
30         $s->storage->sqlmaker->plugin('+ExtraClauses')->plugin('+BangOverrides');
31
32         my $rs2 = $s->resultset('Foo')->search({
33           -op => [ '=', { -ident => 'outer.y' }, { -ident => 'me.x' } ]
34         });
35         # (SELECT me.x, me.y, me.z FROM foo me WHERE ( outer.y = me.x ))
36
37         my $rs3 = $rs2->search({}, {
38           '!from' => sub { my ($sqla, $from) = @_;
39             my $base = $sqla->expand_expr({ -old_from => $from });
40             return [ $base, -join => [ 'wub', on => [ 'me.z' => 'wub.z' ] ] ];
41           }
42         });
43         # (SELECT me.x, me.y, me.z FROM foo me JOIN wub ON me.z = wub.z WHERE ( outer.y = me.x ))
44
45         my $rs4 = $rs3->search({}, {
46           '!with' => [ [ qw(wub x y z) ], $s->resultset('Bar')->as_query ],
47         });
48         # (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 ))
49
50         my $rs5 = $rs->search({}, { select => [ { -coalesce => [ { -ident => 'x' }, { -value => 7 } ] } ] });
51         # (SELECT -COALESCE( -IDENT( x ), -VALUE( 7 ) ) FROM foo me WHERE ( z = ? ))
52
53         my $rs6 = $rs->search({}, { '!select' => [ { -coalesce => [ { -ident => 'x' }, { -value => 7 } ] } ] });
54         # (SELECT COALESCE(x, ?) FROM foo me WHERE ( z = ? ))
55
56
57
58perl v5.38.0                      2023-0S7Q-L2:1:Abstract::Plugin::BangOverrides(3)
Impressum