plugin registration
[scpubgit/Q-Branch.git] / t / 21op_ident.t
index 29ff46f..d73b11c 100644 (file)
@@ -17,7 +17,17 @@ for my $q ('', '"') {
     $sql_maker->where({ foo => { -ident => undef } })
   } qr/-ident requires a single plain scalar argument/;
 
-  my ($sql, @bind) = $sql_maker->select ('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } );
+  throws_ok {
+    local $sql_maker->{disable_old_special_ops} = 1;
+    $sql_maker->where({'-or' => [{'-ident' => 'foo'},'foo']})
+  } qr/Illegal.*top-level/;
+
+  throws_ok {
+    local $sql_maker->{disable_old_special_ops} = 1;
+    $sql_maker->where({'-or' => [{'-ident' => 'foo'},{'=' => \'bozz'}]})
+  } qr/Illegal.*top-level/;
+
+  my ($sql, @bind) = $sql_maker->select('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } );
   is_same_sql_bind (
     $sql,
     \@bind,
@@ -28,7 +38,7 @@ for my $q ('', '"') {
     [],
   );
 
-  ($sql, @bind) = $sql_maker->update ('artist',
+  ($sql, @bind) = $sql_maker->update('artist',
     { 'artist.name' => { -ident => 'artist.pseudonym' } },
     { 'artist.name' => { '!=' => { -ident => 'artist.pseudonym' } } },
   );
@@ -41,6 +51,18 @@ for my $q ('', '"') {
     ",
     [],
   );
+
+  ($sql) = $sql_maker->select(
+    \(my $from = 'foo JOIN bar ON foo.bar_id = bar.id'),
+    [ { -ident => [ 'foo', 'name' ] }, { -ident => [ 'bar', '*' ] } ]
+  );
+
+  is_same_sql_bind(
+    $sql,
+    undef,
+    "SELECT ${q}foo${q}.${q}name${q}, ${q}bar${q}.*
+     FROM $from"
+  );
 }
 
 done_testing;