make list always parenthesised, make , op work for everything else
[scpubgit/Q-Branch.git] / t / 08special_ops.t
index dc6a618..131f99e 100644 (file)
@@ -1,5 +1,3 @@
-#!/usr/bin/perl
-
 use strict;
 use warnings;
 use Test::More;
@@ -35,6 +33,11 @@ my $sqlmaker = SQL::Abstract->new(special_ops => [
      }
    },
 
+], unary_ops => [
+  # unary op from Mojo::Pg
+  {regex => qr/^json$/i,
+   handler => sub { '?', { json => $_[2] } }
+  },
 ]);
 
 my @tests = (
@@ -52,6 +55,18 @@ 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' } } ],
+  },
+
 );
 
 for (@tests) {