X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSQL%2FAbstract%2FReference.pm;h=b030f39b9d387811c4f0cb26c5d6830997c84501;hb=3c700ca3444b64dccee80083cb0970d63eb7d338;hp=adb96df8e2891a100e099e82e5d3960779569a5c;hpb=d4c5cd244e51d6dcc0f8d179e2a3c59114f4e0ac;p=scpubgit%2FQ-Branch.git diff --git a/lib/SQL/Abstract/Reference.pm b/lib/SQL/Abstract/Reference.pm index adb96df..b030f39 100644 --- a/lib/SQL/Abstract/Reference.pm +++ b/lib/SQL/Abstract/Reference.pm @@ -625,4 +625,91 @@ next element as the value. ( x = ? OR ( y = ? OR z = ? ) OR key = ? OR lit() ) [ 1, 2, 3, 'value' ] +=head1 Default Expanders + +=head2 bool + +Turns the old -bool syntax into the value expression, i.e. + + # expr + { -bool => { -ident => 'foo' } } + + # aqt + { -ident => [ 'foo' ] } + + # query + foo + [] + +behaves the same way as the now-directly-supported + + # expr + { -ident => 'foo' } + + # aqt + { -ident => [ 'foo' ] } + + # query + foo + [] + +=head2 row + +Expands the elements of the value arrayref: + + # expr + { -row => [ 1, { -ident => 'foo' }, 2, 3 ] } + + # aqt + { -row => [ + { -bind => [ undef, 1 ] }, { -ident => [ 'foo' ] }, + { -bind => [ undef, 2 ] }, { -bind => [ undef, 3 ] }, + ] } + + # query + (?, foo, ?, ?) + [ 1, 2, 3 ] + +=head2 op + +If an expander is registered for the op name, delegates to the expander; if +not, expands the argument values: + + # expr + { -op => [ 'ident', 'foo.bar' ] } + + # aqt + { -ident => [ 'foo', 'bar' ] } + + # query + foo.bar + [] + + # expr + { -op => [ '=', { -ident => 'foo' }, 3 ] } + + # aqt + { -op => [ '=', { -ident => [ 'foo' ] }, { -bind => [ undef, 3 ] } ] } + + # query + foo = ? + [ 3 ] + +=head2 func + +Expands the argument values: + + # expr + { -func => [ 'coalesce', { -ident => 'thing' }, 'fallback' ] } + + # aqt + { -func => [ + 'coalesce', { -ident => [ 'thing' ] }, + { -bind => [ undef, 'fallback' ] }, + ] } + + # query + COALESCE(thing, ?) + [ 'fallback' ] + =cut