7 use DBIC::SqlMakerTest;
11 use_ok('DBIC::DebugObj');
12 my $schema = DBICTest->init_schema();
14 $schema->storage->sql_maker->quote_char('`');
15 $schema->storage->sql_maker->name_sep('.');
18 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
19 $schema->storage->debug(1);
23 $rs = $schema->resultset('CD')->search(
24 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
25 { join => 'artist' });
29 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
30 'got correct SQL for count query with quoting'
33 my $order = 'year DESC';
34 $rs = $schema->resultset('CD')->search({},
35 { 'order_by' => $order });
37 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
39 $rs = $schema->resultset('CD')->search({},
40 { 'order_by' => \$order });
42 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
44 $schema->storage->sql_maker->quote_char([qw/[ ]/]);
45 $schema->storage->sql_maker->name_sep('.');
47 $rs = $schema->resultset('CD')->search(
48 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
49 { join => 'artist' });
53 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
54 'got correct SQL for count query with bracket quoting'
62 $schema->storage->sql_maker->quote_char('`');
63 $schema->storage->sql_maker->name_sep('.');
65 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');