8 use DBIC::SqlMakerTest;
11 my $schema = DBICTest->init_schema();
13 $schema->storage->sql_maker->quote_char('`');
14 $schema->storage->sql_maker->name_sep('.');
17 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
18 $schema->storage->debug(1);
22 $rs = $schema->resultset('CD')->search(
23 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
24 { join => 'artist' });
28 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
29 'got correct SQL for count query with quoting'
32 my $order = 'year DESC';
33 $rs = $schema->resultset('CD')->search({},
34 { 'order_by' => $order });
36 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
38 $rs = $schema->resultset('CD')->search({},
39 { 'order_by' => \$order });
41 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
43 $schema->storage->sql_maker->quote_char([qw/[ ]/]);
44 $schema->storage->sql_maker->name_sep('.');
46 $rs = $schema->resultset('CD')->search(
47 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
48 { join => 'artist' });
52 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
53 'got correct SQL for count query with bracket quoting'
61 $schema->storage->sql_maker->quote_char('`');
62 $schema->storage->sql_maker->name_sep('.');
64 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');