8 eval "use DBD::SQLite";
10 ? ( skip_all => 'needs DBD::SQLite for testing' )
16 use DBIC::SqlMakerTest;
20 my $schema = DBICTest->init_schema();
22 diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
24 my $dsn = $schema->storage->connect_info->[0];
30 { quote_char => '`', name_sep => '.' },
34 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql));
35 $schema->storage->debug (1);
37 my $rs = $schema->resultset('CD')->search(
38 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
39 { join => 'artist' });
44 q/SELECT COUNT( * ) FROM `cd` `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )/,
46 'got correct SQL for count query with quoting'
48 my $order = 'year DESC';
49 $rs = $schema->resultset('CD')->search({},
50 { 'order_by' => $order });
55 qq/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `${order}`/,
57 'quoted ORDER BY with DESC (should use a scalarref anyway)'
60 $rs = $schema->resultset('CD')->search({},
61 { 'order_by' => \$order });
66 qq/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY ${order}/,
68 'did not quote ORDER BY with scalarref'
75 { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' }
77 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql));
78 $schema->storage->debug(1);
80 $rs = $schema->resultset('CD')->search(
81 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
82 { join => 'artist' });
87 q/SELECT COUNT( * ) FROM [cd] [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )/,
89 'got correct SQL for count query with bracket quoting'
101 { AutoCommit => 1, quote_char => '`', name_sep => '.' }
104 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');