remove obsolete thing that never worked
[scpubgit/Q-Branch.git] / t / 21op_ident.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use SQL::Abstract;
7 use SQL::Abstract::Test import => [qw/is_same_sql_bind/];
8
9
10 for my $q ('', '"') {
11   my $sql_maker = SQL::Abstract->new(
12     quote_char => $q,
13     name_sep => $q ? '.' : '',
14   );
15
16   throws_ok {
17     $sql_maker->where({ foo => { -ident => undef } })
18   } qr/-ident requires a single plain scalar argument/;
19
20   throws_ok {
21     local $sql_maker->{disable_old_special_ops} = 1;
22     $sql_maker->where({'-or' => [{'-ident' => 'foo'},'foo']})
23   } qr/Illegal.*top-level/;
24
25   throws_ok {
26     local $sql_maker->{disable_old_special_ops} = 1;
27     $sql_maker->where({'-or' => [{'-ident' => 'foo'},{'=' => \'bozz'}]})
28   } qr/Illegal.*top-level/;
29
30   my ($sql, @bind) = $sql_maker->select('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } );
31   is_same_sql_bind (
32     $sql,
33     \@bind,
34     "SELECT *
35       FROM ${q}artist${q}
36       WHERE ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
37     ",
38     [],
39   );
40
41   ($sql, @bind) = $sql_maker->update('artist',
42     { 'artist.name' => { -ident => 'artist.pseudonym' } },
43     { 'artist.name' => { '!=' => { -ident => 'artist.pseudonym' } } },
44   );
45   is_same_sql_bind (
46     $sql,
47     \@bind,
48     "UPDATE ${q}artist${q}
49       SET ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
50       WHERE ${q}artist${q}.${q}name${q} != ${q}artist${q}.${q}pseudonym${q}
51     ",
52     [],
53   );
54
55   ($sql) = $sql_maker->select(
56     \(my $from = 'foo JOIN bar ON foo.bar_id = bar.id'),
57     [ { -ident => [ 'foo', 'name' ] }, { -ident => [ 'bar', '*' ] } ]
58   );
59
60   is_same_sql_bind(
61     $sql,
62     undef,
63     "SELECT ${q}foo${q}.${q}name${q}, ${q}bar${q}.*
64      FROM $from"
65   );
66 }
67
68 done_testing;