7 use DBIC::SqlMakerTest;
10 eval "use DBD::SQLite";
12 ? ( skip_all => 'needs DBD::SQLite for testing' )
17 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 my $dsn = $schema->storage->_dbi_connect_info->[0];
29 { quote_char => '`', name_sep => '.' },
33 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
34 $schema->storage->debug(1);
38 $rs = $schema->resultset('CD')->search(
39 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
40 { join => 'artist' });
44 "SELECT COUNT( * ) FROM cd `me` JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
45 'got correct SQL for count query with quoting'
48 my $order = 'year DESC';
49 $rs = $schema->resultset('CD')->search({},
50 { 'order_by' => $order });
52 like($sql, qr/ORDER BY `\Q${order}\E`/, 'quoted ORDER BY with DESC (should use a scalarref anyway)');
54 $rs = $schema->resultset('CD')->search({},
55 { 'order_by' => \$order });
57 like($sql, qr/ORDER BY \Q${order}\E/, 'did not quote ORDER BY with scalarref');
63 { AutoCommit => 1, quote_char => [qw/[ ]/], name_sep => '.' }
66 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
67 $schema->storage->debug(1);
69 $rs = $schema->resultset('CD')->search(
70 { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
71 { join => 'artist' });
75 "SELECT COUNT( * ) FROM cd [me] JOIN [artist] [artist] ON ( [artist].[artistid] = [me].[artist] ) WHERE ( [artist].[name] = ? AND [me].[year] = ? )", ["'Caterwauler McCrae'", "'2001'"],
76 'got correct SQL for count query with bracket quoting'
88 { AutoCommit => 1, quote_char => '`', name_sep => '.' }
91 is($schema->storage->sql_maker->update('group', \%data), 'UPDATE `group` SET `name` = ?, `order` = ?', 'quoted table names for UPDATE');