use warnings;
use Test::More;
+use Test::Exception;
use SQL::Abstract;
use SQL::Abstract::Test import => [qw/is_same_sql_bind/];
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/;
+
+ my ($sql, @bind) = $sql_maker->select('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } );
is_same_sql_bind (
$sql,
\@bind,
[],
);
- ($sql, @bind) = $sql_maker->update ('artist',
+ ($sql, @bind) = $sql_maker->update('artist',
{ 'artist.name' => { -ident => 'artist.pseudonym' } },
{ 'artist.name' => { '!=' => { -ident => 'artist.pseudonym' } } },
);
",
[],
);
+
+ ($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;