[Bast-commits] r6848 - in DBIx-Class/0.08/branches/table_name_ref/t: . lib/DBICTest/Schema

caelum at dev.catalyst.perl.org caelum at dev.catalyst.perl.org
Mon Jun 29 19:39:26 GMT 2009


Author: caelum
Date: 2009-06-29 19:39:26 +0000 (Mon, 29 Jun 2009)
New Revision: 6848

Added:
   DBIx-Class/0.08/branches/table_name_ref/t/19table_name_ref.t
Modified:
   DBIx-Class/0.08/branches/table_name_ref/t/19quotes_newstyle.t
   DBIx-Class/0.08/branches/table_name_ref/t/lib/DBICTest/Schema/CDTableRef.pm
Log:
separated table ref test out, changed CDTableRef to a view with less rels

Modified: DBIx-Class/0.08/branches/table_name_ref/t/19quotes_newstyle.t
===================================================================
--- DBIx-Class/0.08/branches/table_name_ref/t/19quotes_newstyle.t	2009-06-29 17:09:00 UTC (rev 6847)
+++ DBIx-Class/0.08/branches/table_name_ref/t/19quotes_newstyle.t	2009-06-29 19:39:26 UTC (rev 6848)
@@ -11,7 +11,7 @@
     eval "use DBD::SQLite";
     plan $@
         ? ( skip_all => 'needs DBD::SQLite for testing' )
-        : ( tests => 9 );
+        : ( tests => 7 );
 }
 
 use_ok('DBICTest');
@@ -46,27 +46,6 @@
   '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 });

Added: DBIx-Class/0.08/branches/table_name_ref/t/19table_name_ref.t
===================================================================
--- DBIx-Class/0.08/branches/table_name_ref/t/19table_name_ref.t	                        (rev 0)
+++ DBIx-Class/0.08/branches/table_name_ref/t/19table_name_ref.t	2009-06-29 19:39:26 UTC (rev 6848)
@@ -0,0 +1,45 @@
+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 $@;

Modified: DBIx-Class/0.08/branches/table_name_ref/t/lib/DBICTest/Schema/CDTableRef.pm
===================================================================
--- DBIx-Class/0.08/branches/table_name_ref/t/lib/DBICTest/Schema/CDTableRef.pm	2009-06-29 17:09:00 UTC (rev 6847)
+++ DBIx-Class/0.08/branches/table_name_ref/t/lib/DBICTest/Schema/CDTableRef.pm	2009-06-29 19:39:26 UTC (rev 6848)
@@ -2,8 +2,11 @@
     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' => {
@@ -39,51 +42,4 @@
     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;




More information about the Bast-commits mailing list