Factor out bindattr resolver and tighten code a bit
[dbsrgits/DBIx-Class.git] / t / sqlmaker / op_ident.t
CommitLineData
e6600283 1use strict;
2use warnings;
3
4use Test::More;
5
6use lib qw(t/lib);
7use DBIC::SqlMakerTest;
8
9use_ok('DBICTest');
10
11my $schema = DBICTest->init_schema();
12
13my $sql_maker = $schema->storage->sql_maker;
14
15for 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
41done_testing;