8 use DBIC::SqlMakerTest;
11 my $schema = DBICTest->init_schema();
13 my $dsn = $schema->storage->_dbi_connect_info->[0];
19 { quote_char => '`', name_sep => '.' },
23 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
24 $schema->storage->debug(1);
28 $rs = $schema->resultset('CD')->search(
29 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
30 { join => 'artist' });
34 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
35 'got correct SQL for count query with quoting'
38 my $order = 'year DESC';
39 $rs = $schema->resultset('CD')->search({},
40 { 'order_by' => $order });
42 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
44 $rs = $schema->resultset('CD')->search({},
45 { 'order_by' => \$order });
47 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
53 { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' }
56 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
57 $schema->storage->debug(1);
59 $rs = $schema->resultset('CD')->search(
60 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
61 { join => 'artist' });
65 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
66 'got correct SQL for count query with bracket quoting'
78 { AutoCommit => 1, quote_char => '`', name_sep => '.' }
81 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');