5ba3f271f88054fa855e4e29235a6cd35f1fc3e5
[dbsrgits/SQL-Abstract.git] / t / 21op_ident.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use SQL::Abstract;
6 use SQL::Abstract::Test import => [qw/is_same_sql_bind/];
7
8
9 for my $q ('', '"') {
10   my $sql_maker = SQL::Abstract->new(
11     quote_char => $q,
12     name_sep => $q ? '.' : '',
13   );
14
15   my ($sql, @bind) = $sql_maker->select ('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } );
16   is_same_sql_bind (
17     $sql,
18     \@bind,
19     "SELECT *
20       FROM ${q}artist${q}
21       WHERE ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
22     ",
23     [],
24   );
25
26   ($sql, @bind) = $sql_maker->update ('artist',
27     { 'artist.name' => { -ident => 'artist.pseudonym' } },
28     { 'artist.name' => { '!=' => { -ident => 'artist.pseudonym' } } },
29   );
30   is_same_sql_bind (
31     $sql,
32     \@bind,
33     "UPDATE ${q}artist${q}
34       SET ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
35       WHERE ${q}artist${q}.${q}name${q} != ${q}artist${q}.${q}pseudonym${q}
36     ",
37     [],
38   );
39 }
40
41 done_testing;