Commit | Line | Data |
688e73cb |
1 | use strict; |
2 | use warnings; |
3 | |
4 | use Test::More; |
5 | use IO::File; |
6 | |
7 | use lib qw(t/lib); |
8 | use DBICTest; |
9 | use DBIC::SqlMakerTest; |
10 | use DBIC::DebugObj; |
11 | |
12 | plan tests => 2; |
13 | |
14 | my $schema = DBICTest->init_schema(); |
15 | |
16 | $schema->storage->sql_maker->quote_char('`'); |
17 | $schema->storage->sql_maker->name_sep('.'); |
18 | |
19 | my ($sql, @bind); |
20 | $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)), |
21 | $schema->storage->debug(1); |
22 | |
23 | my $rs; |
24 | |
25 | # ->table(\'cd') should NOT be quoted |
26 | $rs = $schema->resultset('CDTableRef')->search( |
27 | { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' }, |
28 | { join => 'artist' }); |
29 | eval { $rs->count }; |
30 | is_same_sql_bind( |
31 | $sql, \@bind, |
32 | "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"], |
33 | 'got correct SQL for count query with quoting' |
34 | ); |
35 | |
36 | # check that the table works |
37 | eval { |
38 | $rs = $schema->resultset('CDTableRef'); |
39 | $rs->create({ cdid => 6, artist => 3, title => 'mtfnpy', year => 2009 }); |
40 | my $row = $rs->find(6); |
41 | $row->update({ title => 'bleh' }); |
42 | $row->delete; |
43 | }; |
44 | ok !$@, 'operations on scalarref table name work'; |
45 | diag $@ if $@; |