Commit | Line | Data |
cc422895 |
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; |