eval "use DBD::SQLite";
plan $@
? ( skip_all => 'needs DBD::SQLite for testing' )
- : ( tests => 9 );
+ : ( tests => 7 );
}
use_ok('DBICTest');
'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'
-);
-
-# check that the table works
-eval {
- my $rs = $schema->resultset('CDTableRef');
- $rs->create({ cdid => 6, artist => 3, title => 'mtfnpy', year => 2009 });
- my $row = $rs->find(6);
- $row->update({ title => 'bleh' });
- $row->delete;
-};
-ok !$@, 'operations on scalarref table name work';
-
my $order = 'year DESC';
$rs = $schema->resultset('CD')->search({},
{ 'order_by' => $order });
--- /dev/null
+use strict;
+use warnings;
+
+use Test::More;
+use IO::File;
+
+use lib qw(t/lib);
+use DBICTest;
+use DBIC::SqlMakerTest;
+use DBIC::DebugObj;
+
+plan tests => 2;
+
+my $schema = DBICTest->init_schema();
+
+$schema->storage->sql_maker->quote_char('`');
+$schema->storage->sql_maker->name_sep('.');
+
+my ($sql, @bind);
+$schema->storage->debugobj(DBIC::DebugObj->new(\$sql, \@bind)),
+$schema->storage->debug(1);
+
+my $rs;
+
+# ->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'
+);
+
+# check that the table works
+eval {
+ $rs = $schema->resultset('CDTableRef');
+ $rs->create({ cdid => 6, artist => 3, title => 'mtfnpy', year => 2009 });
+ my $row = $rs->find(6);
+ $row->update({ title => 'bleh' });
+ $row->delete;
+};
+ok !$@, 'operations on scalarref table name work';
+diag $@ if $@;
DBICTest::Schema::CDTableRef;
use base qw/DBICTest::BaseResult/;
+use DBIx::Class::ResultSource::View;
+__PACKAGE__->table_class('DBIx::Class::ResultSource::View');
__PACKAGE__->table(\'cd');
+__PACKAGE__->result_source_instance->is_virtual(0);
__PACKAGE__->add_columns(
'cdid' => {
is_deferrable => 1,
});
-# in case this is a single-cd it promotes a track from another cd
-__PACKAGE__->belongs_to( single_track => 'DBICTest::Schema::Track', 'single_track',
- { join_type => 'left'}
-);
-
-__PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track', 'cd' );
-__PACKAGE__->has_many(
- tags => 'DBICTest::Schema::Tag', 'cd',
- { order_by => 'tag' },
-);
-__PACKAGE__->has_many(
- cd_to_producer => 'DBICTest::Schema::CD_to_Producer' => 'cd'
-);
-
-__PACKAGE__->might_have(
- liner_notes => 'DBICTest::Schema::LinerNotes', undef,
- { proxy => [ qw/notes/ ] },
-);
-__PACKAGE__->might_have(artwork => 'DBICTest::Schema::Artwork', 'cd_id');
-
-__PACKAGE__->many_to_many( producers => cd_to_producer => 'producer' );
-__PACKAGE__->many_to_many(
- producers_sorted => cd_to_producer => 'producer',
- { order_by => 'producer.name' },
-);
-
-__PACKAGE__->belongs_to('genre', 'DBICTest::Schema::Genre',
- { 'foreign.genreid' => 'self.genreid' },
- {
- join_type => 'left',
- on_delete => 'SET NULL',
- on_update => 'CASCADE',
- },
-);
-
-#This second relationship was added to test the short-circuiting of pointless
-#queries provided by undef_on_null_fk. the relevant test in 66relationship.t
-__PACKAGE__->belongs_to('genre_inefficient', 'DBICTest::Schema::Genre',
- { 'foreign.genreid' => 'self.genreid' },
- {
- join_type => 'left',
- on_delete => 'SET NULL',
- on_update => 'CASCADE',
- undef_on_null_fk => 0,
- },
-);
-
1;