>table(\"foo") now works
[dbsrgits/DBIx-Class.git] / t / 19quotes_newstyle.t
index 748b112..01a8c77 100644 (file)
@@ -11,7 +11,7 @@ BEGIN {
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 7 );
+        : ( tests => 8 );
 }
 
 use_ok('DBICTest');
@@ -19,7 +19,7 @@ use_ok('DBIC::DebugObj');
 
 my $schema = DBICTest->init_schema();
 
-diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
+#diag('Testing against ' . join(' ', map { $schema->storage->dbh->get_info($_) } qw/17 18/));
 
 my $dsn = $schema->storage->_dbi_connect_info->[0];
 $schema->connection(
@@ -30,7 +30,7 @@ $schema->connection(
   { quote_char => '`', name_sep => '.' },
 );
 
-my ($sql, @bind) = ('');
+my ($sql, @bind);
 $schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
 $schema->storage->debug(1);
 
@@ -46,6 +46,17 @@ is_same_sql_bind(
   'got correct SQL for count query with quoting'
 );
 
+# try with ->table(\'cd') should NOT be quoted
+$rs = $schema->resultset('CDTableRef')->search(
+           { 'me.year' => 2001, 'artist.name' => 'Caterwauler McCrae' },
+           { join => 'artist' });
+eval { $rs->count };
+is_same_sql_bind(
+  $sql, \@bind,
+  "SELECT COUNT( * ) FROM cd `me`  JOIN `artist` `artist` ON ( `artist`.`artistid` = `me`.`artist` ) WHERE ( `artist`.`name` = ? AND `me`.`year` = ? )", ["'Caterwauler McCrae'", "'2001'"],
+  'got correct SQL for count query with quoting'
+);
+
 my $order = 'year DESC';
 $rs = $schema->resultset('CD')->search({},
             { 'order_by' => $order });