8 eval "use DBD::SQLite";
10 ? ( skip_all => 'needs DBD::SQLite for testing' )
15 use DBIC::SqlMakerTest;
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));
28 $schema->storage->debug(1);
32 $rs = $schema->resultset('CD')->search(
33 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
34 { join => 'artist' });
39 q/SELECT COUNT( * ) FROM `cd` `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )/,
41 'got correct SQL for count query with quoting'
45 my $order = 'year DESC';
46 $rs = $schema->resultset('CD')->search({},
47 { 'order_by' => $order });
52 qq/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY `${order}`/,
54 'quoted ORDER BY with DESC (should use a scalarref anyway)'
57 $rs = $schema->resultset('CD')->search({},
58 { 'order_by' => \$order });
63 qq/SELECT `me`.`cdid`, `me`.`artist`, `me`.`title`, `me`.`year` FROM `cd` `me` ORDER BY ${order}/,
65 'did not quote ORDER BY with scalarref'
68 $schema->storage->sql_maker->quote_char([qw/[ ]/]);
69 $schema->storage->sql_maker->name_sep('.');
71 $rs = $schema->resultset('CD')->search(
72 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
73 { join => 'artist' });
78 qq/SELECT COUNT( * ) FROM [cd] [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )/,
80 'got correct SQL for count query with bracket quoting'
88 $schema->storage->sql_maker->quote_char('`');
89 $schema->storage->sql_maker->name_sep('.');
91 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');