X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2F21op_ident.t;h=d73b11cece340844075cda101c11c625d62bc7ac;hb=28605008bc0a369d4da57ef504679e52a50953a9;hp=5ba3f271f88054fa855e4e29235a6cd35f1fc3e5;hpb=cc4228955c41e945e3515aa9d77266a0dacc43af;p=scpubgit%2FQ-Branch.git diff --git a/t/21op_ident.t b/t/21op_ident.t index 5ba3f27..d73b11c 100644 --- a/t/21op_ident.t +++ b/t/21op_ident.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; +use Test::Exception; use SQL::Abstract; use SQL::Abstract::Test import => [qw/is_same_sql_bind/]; @@ -12,7 +13,21 @@ for my $q ('', '"') { name_sep => $q ? '.' : '', ); - my ($sql, @bind) = $sql_maker->select ('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } ); + throws_ok { + $sql_maker->where({ foo => { -ident => undef } }) + } qr/-ident requires a single plain scalar argument/; + + 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, @@ -23,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' } } }, ); @@ -36,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;