7 use DBIC::SqlMakerTest;
10 eval "use DBD::SQLite";
12 ? ( skip_all => 'needs DBD::SQLite for testing' )
18 use_ok('DBIC::DebugObj');
19 my $schema = DBICTest->init_schema();
21 #diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
23 $schema->storage->sql_maker->quote_char('`');
24 $schema->storage->sql_maker->name_sep('.');
27 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind));
28 $schema->storage->debug(1);
32 $rs = $schema->resultset('CD')->search(
33 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
34 { join => 'artist' });
38 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
39 'got correct SQL for count query with quoting'
42 my $order = 'year DESC';
43 $rs = $schema->resultset('CD')->search({},
44 { 'order_by' => $order });
46 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
48 $rs = $schema->resultset('CD')->search({},
49 { 'order_by' => \$order });
51 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
53 $schema->storage->sql_maker->quote_char([qw/[ ]/]);
54 $schema->storage->sql_maker->name_sep('.');
56 $rs = $schema->resultset('CD')->search(
57 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
58 { join => 'artist' });
62 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
63 'got correct SQL for count query with bracket quoting'
71 $schema->storage->sql_maker->quote_char('`');
72 $schema->storage->sql_maker->name_sep('.');
74 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');