restore unary op functionality
[scpubgit/Q-Branch.git] / t / 08special_ops.t
index d989a79..131f99e 100644 (file)
@@ -33,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 = (
@@ -50,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) {