X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F08special_ops.t;h=c4b303e7b5ab616f8b26c35118b2a93d5041c3ac;hb=e67751dd9effc7f5066e264c1d6149613a7efa42;hp=d989a79b0b78819cde60bcf7899c0163d1bdcbdf;hpb=46dc2f3e47d514cd376003cea2df63222c492b0b;p=scpubgit%2FQ-Branch.git diff --git a/t/08special_ops.t b/t/08special_ops.t index d989a79..c4b303e 100644 --- a/t/08special_ops.t +++ b/t/08special_ops.t @@ -33,6 +33,29 @@ my $sqlmaker = SQL::Abstract->new(special_ops => [ } }, + # PRIOR op from DBIx::Class::SQLMaker::Oracle + + { + regex => qr/^prior$/i, + handler => sub { + my ($self, $lhs, $op, $rhs) = @_; + my ($sql, @bind) = $self->_recurse_where ($rhs); + + $sql = sprintf ('%s = %s %s ', + $self->_convert($self->_quote($lhs)), + $self->_sqlcase ($op), + $sql + ); + + return ($sql, @bind); + }, + }, + +], unary_ops => [ + # unary op from Mojo::Pg + {regex => qr/^json$/i, + handler => sub { '?', { json => $_[2] } } + }, ]); my @tests = ( @@ -50,6 +73,28 @@ my @tests = ( bind => [], }, + #3 + { where => { foo => { -json => { bar => 'baz' } } }, + stmt => "WHERE foo = ?", + bind => [ { json => { bar => 'baz' } } ], + }, + + #4 + { where => { foo => { '@>' => { -json => { bar => 'baz' } } } }, + stmt => "WHERE foo @> ?", + bind => [ { json => { bar => 'baz' } } ], + }, + + # Verify inconsistent behaviour from DBIx::Class:SQLMaker::Oracle works + # (unary use of special op is not equivalent to special op + =) + { + where => { + foo_id => { '=' => { '-prior' => { -ident => 'bar_id' } } }, + baz_id => { '-prior' => { -ident => 'quux_id' } }, + }, + stmt => ' WHERE ( baz_id = PRIOR quux_id AND foo_id = ( PRIOR bar_id ) )', + bind => [], + }, ); for (@tests) {