7 use DBIC::SqlMakerTest;
10 use_ok('DBIC::DebugObj');
12 my $schema = DBICTest->init_schema();
14 my $dsn = $schema->storage->_dbi_connect_info->[0];
20 { quote_char => '`', name_sep => '.' },
24 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
25 $schema->storage->debug(1);
29 $rs = $schema->resultset('CD')->search(
30 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
31 { join => 'artist' });
35 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
36 'got correct SQL for count query with quoting'
39 my $order = 'year DESC';
40 $rs = $schema->resultset('CD')->search({},
41 { 'order_by' => $order });
43 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
45 $rs = $schema->resultset('CD')->search({},
46 { 'order_by' => \$order });
48 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
54 { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' }
57 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
58 $schema->storage->debug(1);
60 $rs = $schema->resultset('CD')->search(
61 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
62 { join => 'artist' });
66 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
67 'got correct SQL for count query with bracket quoting'
79 { AutoCommit => 1, quote_char => '`', name_sep => '.' }
82 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');