7 use DBIC::SqlMakerTest;
10 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 my $dsn = $schema->storage->_dbi_connect_info->[0];
22 { quote_char => '`', name_sep => '.' },
26 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
27 $schema->storage->debug(1);
31 $rs = $schema->resultset('CD')->search(
32 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
33 { join => 'artist' });
37 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
38 'got correct SQL for count query with quoting'
41 my $order = 'year DESC';
42 $rs = $schema->resultset('CD')->search({},
43 { 'order_by' => $order });
45 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
47 $rs = $schema->resultset('CD')->search({},
48 { 'order_by' => \$order });
50 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
56 { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' }
59 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
60 $schema->storage->debug(1);
62 $rs = $schema->resultset('CD')->search(
63 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
64 { join => 'artist' });
68 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
69 'got correct SQL for count query with bracket quoting'
81 { AutoCommit => 1, quote_char => '`', name_sep => '.' }
84 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');