From: Matt S Trout Date: Mon, 30 Sep 2019 19:09:10 +0000 (+0000) Subject: doc between op expander X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dee79057e5d03dd6c0715d577eb22b7a057ef146;p=scpubgit%2FQ-Branch.git doc between op expander --- diff --git a/lib/SQL/Abstract/Reference.pm b/lib/SQL/Abstract/Reference.pm index f20cb06..ff020b3 100644 --- a/lib/SQL/Abstract/Reference.pm +++ b/lib/SQL/Abstract/Reference.pm @@ -744,4 +744,65 @@ treated as rows: VALUES (?, ?), (?, ?) [ 1, 2, 3, 4 ] +=head2 between op + +The RHS of between must either be a pair of exprs/plain values, or a single +literal expr: + + # expr + { -between => [ 'size', 3, { -ident => 'max_size' } ] } + + # aqt + { -op => [ + 'between', { -ident => [ 'size' ] }, { -bind => [ undef, 3 ] }, + { -ident => [ 'max_size' ] }, + ] } + + # query + ( size BETWEEN ? AND max_size ) + [ 3 ] + + # expr + { size => { -between => [ 3, { -ident => 'max_size' } ] } } + + # aqt + { -op => [ + 'between', { -ident => [ 'size' ] }, { -bind => [ 'size', 3 ] }, + { -ident => [ 'max_size' ] }, + ] } + + # query + ( size BETWEEN ? AND max_size ) + [ 3 ] + + # expr + { size => { -between => \"3 AND 7" } } + + # aqt + { -op => + [ + 'between', { -ident => [ 'size' ] }, + { -literal => [ '3 AND 7' ] }, + ] + } + + # query + ( size BETWEEN 3 AND 7 ) + [] + +C is also expanded: + + # expr + { size => { -not_between => [ 3, 7 ] } } + + # aqt + { -op => [ + 'not_between', { -ident => [ 'size' ] }, + { -bind => [ 'size', 3 ] }, { -bind => [ 'size', 7 ] }, + ] } + + # query + ( size NOT BETWEEN ? AND ? ) + [ 3, 7 ] + =cut