[Bast-commits] r7715 - DBIx-Class/0.08/trunk/t/relationship
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Mon Sep 21 14:26:07 GMT 2009
Author: ribasushi
Date: 2009-09-21 14:26:07 +0000 (Mon, 21 Sep 2009)
New Revision: 7715
Modified:
DBIx-Class/0.08/trunk/t/relationship/core.t
Log:
A test for an obscure join syntax - make sure we don't break it
Modified: DBIx-Class/0.08/trunk/t/relationship/core.t
===================================================================
--- DBIx-Class/0.08/trunk/t/relationship/core.t 2009-09-21 11:34:26 UTC (rev 7714)
+++ DBIx-Class/0.08/trunk/t/relationship/core.t 2009-09-21 14:26:07 UTC (rev 7715)
@@ -5,12 +5,11 @@
use Test::Exception;
use lib qw(t/lib);
use DBICTest;
+use DBIC::SqlMakerTest;
my $schema = DBICTest->init_schema();
my $sdebug = $schema->storage->debug;
-plan tests => 79;
-
# has_a test
my $cd = $schema->resultset("CD")->find(4);
my ($artist) = ($INC{'DBICTest/HelperRels'}
@@ -260,8 +259,22 @@
is($def_artist_cd->search_related('artist')->count, 0, 'closed search on null FK');
# test undirected many-to-many relationship (e.g. "related artists")
-my $undir_maps = $schema->resultset("Artist")->find(1)->artist_undirected_maps;
+my $undir_maps = $schema->resultset("Artist")
+ ->search ({artistid => 1})
+ ->search_related ('artist_undirected_maps');
is($undir_maps->count, 1, 'found 1 undirected map for artist 1');
+is_same_sql_bind (
+ $undir_maps->as_query,
+ '(
+ SELECT artist_undirected_maps.id1, artist_undirected_maps.id2
+ FROM artist me
+ LEFT JOIN artist_undirected_map artist_undirected_maps
+ ON artist_undirected_maps.id1 = me.artistid OR artist_undirected_maps.id2 = me.artistid
+ WHERE ( artistid = ? )
+ )',
+ [[artistid => 1]],
+ 'expected join sql produced',
+);
$undir_maps = $schema->resultset("Artist")->find(2)->artist_undirected_maps;
is($undir_maps->count, 1, 'found 1 undirected map for artist 2');
@@ -310,3 +323,5 @@
$cds = $schema->resultset("CD")->search({ 'me.cdid' => 5 }, { join => { single_track => { cd => {} } } });
is($cds->count, 1, "subjoins under left joins force_left (hashref)");
+
+done_testing;
More information about the Bast-commits
mailing list