-ident implementation
[dbsrgits/DBIx-Class.git] / t / sqlmaker / op_ident.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5
6 use lib qw(t/lib);
7 use DBIC::SqlMakerTest;
8
9 use_ok('DBICTest');
10
11 my $schema = DBICTest->init_schema();
12
13 my $sql_maker = $schema->storage->sql_maker;
14
15 for my $q ('', '"') {
16
17   $sql_maker->quote_char($q);
18
19   is_same_sql_bind (
20     \[ $sql_maker->select ('artist', '*', { 'artist.name' => { -ident => 'artist.pseudonym' } } ) ],
21     "SELECT *
22       FROM ${q}artist${q}
23       WHERE ${q}artist${q}.${q}name${q} = ${q}artist${q}.${q}pseudonym${q}
24     ",
25     [],
26   );
27
28   is_same_sql_bind (
29     \[ $sql_maker->update ('artist',
30       { 'artist.name' => { -ident => 'artist.pseudonym' } },
31       { 'artist.name' => { '!=' => { -ident => 'artist.pseudonym' } } },
32     ) ],
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;