7 use DBIC::SqlMakerTest;
11 use_ok('DBIC::DebugObj');
12 my $schema = DBICTest->init_schema();
14 #diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
16 $schema->storage->sql_maker->quote_char('`');
17 $schema->storage->sql_maker->name_sep('.');
20 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
21 $schema->storage->debug(1);
25 $rs = $schema->resultset('CD')->search(
26 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
27 { join => 'artist' });
31 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
32 'got correct SQL for count query with quoting'
35 my $order = 'year DESC';
36 $rs = $schema->resultset('CD')->search({},
37 { 'order_by' => $order });
39 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
41 $rs = $schema->resultset('CD')->search({},
42 { 'order_by' => \$order });
44 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
46 $schema->storage->sql_maker->quote_char([qw/[ ]/]);
47 $schema->storage->sql_maker->name_sep('.');
49 $rs = $schema->resultset('CD')->search(
50 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
51 { join => 'artist' });
55 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
56 'got correct SQL for count query with bracket quoting'
64 $schema->storage->sql_maker->quote_char('`');
65 $schema->storage->sql_maker->name_sep('.');
67 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');