[Bast-commits] r5150 - in DBIx-Class/0.08/trunk/t: . lib lib/DBICTest/Schema

ribasushi at dev.catalyst.perl.org ribasushi at dev.catalyst.perl.org
Sun Nov 16 22:16:31 GMT 2008


Author: ribasushi
Date: 2008-11-16 22:16:31 +0000 (Sun, 16 Nov 2008)
New Revision: 5150

Modified:
   DBIx-Class/0.08/trunk/t/50fork.t
   DBIx-Class/0.08/trunk/t/51threads.t
   DBIx-Class/0.08/trunk/t/51threadtxn.t
   DBIx-Class/0.08/trunk/t/60core.t
   DBIx-Class/0.08/trunk/t/74mssql.t
   DBIx-Class/0.08/trunk/t/91debug.t
   DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/CD.pm
   DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Track.pm
   DBIx-Class/0.08/trunk/t/lib/sqlite.sql
Log:
Add new test relationship - a track can have a relates single_cd

Modified: DBIx-Class/0.08/trunk/t/50fork.t
===================================================================
--- DBIx-Class/0.08/trunk/t/50fork.t	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/50fork.t	2008-11-16 22:16:31 UTC (rev 5150)
@@ -34,7 +34,7 @@
     {
         local $SIG{__WARN__} = sub {};
         eval { $dbh->do("DROP TABLE cd") };
-        $dbh->do("CREATE TABLE cd (cdid serial PRIMARY KEY, artist INTEGER NOT NULL UNIQUE, title VARCHAR(100) NOT NULL UNIQUE, year VARCHAR(100) NOT NULL, genreid INTEGER);");
+        $dbh->do("CREATE TABLE cd (cdid serial PRIMARY KEY, artist INTEGER NOT NULL UNIQUE, title VARCHAR(100) NOT NULL UNIQUE, year VARCHAR(100) NOT NULL, genreid INTEGER, single_track INTEGER);");
     }
 
     $schema->resultset('CD')->create({ title => 'vacation in antarctica', artist => 123, year => 1901 });

Modified: DBIx-Class/0.08/trunk/t/51threads.t
===================================================================
--- DBIx-Class/0.08/trunk/t/51threads.t	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/51threads.t	2008-11-16 22:16:31 UTC (rev 5150)
@@ -44,7 +44,7 @@
     {
         local $SIG{__WARN__} = sub {};
         eval { $dbh->do("DROP TABLE cd") };
-        $dbh->do("CREATE TABLE cd (cdid serial PRIMARY KEY, artist INTEGER NOT NULL UNIQUE, title VARCHAR(100) NOT NULL UNIQUE, year VARCHAR(100) NOT NULL, genreid INTEGER);");
+        $dbh->do("CREATE TABLE cd (cdid serial PRIMARY KEY, artist INTEGER NOT NULL UNIQUE, title VARCHAR(100) NOT NULL UNIQUE, year VARCHAR(100) NOT NULL, genreid INTEGER, single_track INTEGER);");
     }
 
     $schema->resultset('CD')->create({ title => 'vacation in antarctica', artist => 123, year => 1901 });

Modified: DBIx-Class/0.08/trunk/t/51threadtxn.t
===================================================================
--- DBIx-Class/0.08/trunk/t/51threadtxn.t	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/51threadtxn.t	2008-11-16 22:16:31 UTC (rev 5150)
@@ -44,7 +44,7 @@
     {
         local $SIG{__WARN__} = sub {};
         eval { $dbh->do("DROP TABLE cd") };
-        $dbh->do("CREATE TABLE cd (cdid serial PRIMARY KEY, artist INTEGER NOT NULL UNIQUE, title VARCHAR(100) NOT NULL UNIQUE, year VARCHAR(100) NOT NULL, genreid INTEGER);");
+        $dbh->do("CREATE TABLE cd (cdid serial PRIMARY KEY, artist INTEGER NOT NULL UNIQUE, title VARCHAR(100) NOT NULL UNIQUE, year VARCHAR(100) NOT NULL, genreid INTEGER, single_track INTEGER);");
     }
 
     $schema->resultset('CD')->create({ title => 'vacation in antarctica', artist => 123, year => 1901 });

Modified: DBIx-Class/0.08/trunk/t/60core.t
===================================================================
--- DBIx-Class/0.08/trunk/t/60core.t	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/60core.t	2008-11-16 22:16:31 UTC (rev 5150)
@@ -153,7 +153,7 @@
 my $cd = $schema->resultset("CD")->find(1);
 my %cols = $cd->get_columns;
 
-cmp_ok(keys %cols, '==', 5, 'get_columns number of columns ok');
+cmp_ok(keys %cols, '==', 6, 'get_columns number of columns ok');
 
 is($cols{title}, 'Spoonful of bees', 'get_columns values ok');
 
@@ -169,7 +169,7 @@
 # check whether ResultSource->columns returns columns in order originally supplied
 my @cd = $schema->source("CD")->columns;
 
-is_deeply( \@cd, [qw/cdid artist title year genreid/], 'column order');
+is_deeply( \@cd, [qw/cdid artist title year genreid single_track/], 'column order');
 
 $cd = $schema->resultset("CD")->search({ title => 'Spoonful of bees' }, { columns => ['title'] })->next;
 is($cd->title, 'Spoonful of bees', 'subset of columns returned correctly');
@@ -335,9 +335,9 @@
 
 # test remove_columns
 {
-  is_deeply([$schema->source('CD')->columns], [qw/cdid artist title year genreid/]);
+  is_deeply([$schema->source('CD')->columns], [qw/cdid artist title year genreid single_track/]);
   $schema->source('CD')->remove_columns('year');
-  is_deeply([$schema->source('CD')->columns], [qw/cdid artist title genreid/]);
+  is_deeply([$schema->source('CD')->columns], [qw/cdid artist title genreid single_track/]);
   ok(! exists $schema->source('CD')->_columns->{'year'}, 'year still exists in _columns');
 }
 

Modified: DBIx-Class/0.08/trunk/t/74mssql.t
===================================================================
--- DBIx-Class/0.08/trunk/t/74mssql.t	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/74mssql.t	2008-11-16 22:16:31 UTC (rev 5150)
@@ -30,7 +30,7 @@
     DROP TABLE cd");
 
 $dbh->do("CREATE TABLE artist (artistid INT IDENTITY PRIMARY KEY, name VARCHAR(100), rank INT DEFAULT '13', charfield CHAR(10) NULL);");
-$dbh->do("CREATE TABLE cd (cdid INT IDENTITY PRIMARY KEY, artist INT,  title VARCHAR(100), year VARCHAR(100), genreid INT NULL);");
+$dbh->do("CREATE TABLE cd (cdid INT IDENTITY PRIMARY KEY, artist INT,  title VARCHAR(100), year VARCHAR(100), genreid INT NULL, single_track INT NULL);");
 # Just to test compat shim, Auto is in Core
 $schema->class('Artist')->load_components('PK::Auto::MSSQL');
 

Modified: DBIx-Class/0.08/trunk/t/91debug.t
===================================================================
--- DBIx-Class/0.08/trunk/t/91debug.t	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/91debug.t	2008-11-16 22:16:31 UTC (rev 5150)
@@ -55,7 +55,7 @@
     my @cds = $schema->resultset('CD')->search( { artist => 1, cdid => { -between => [ 1, 3 ] }, } );
     like(
         $sql,
-        qr/\QSELECT me.cdid, me.artist, me.title, me.year, me.genreid FROM cd me WHERE ( artist = ? AND cdid BETWEEN ? AND ? ): '1', '1', '3'\E/,
+        qr/\QSELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE ( artist = ? AND cdid BETWEEN ? AND ? ): '1', '1', '3'\E/,
         'got correct SQL with all bind parameters'
     );
 }

Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/CD.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/CD.pm	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/CD.pm	2008-11-16 22:16:31 UTC (rev 5150)
@@ -23,6 +23,11 @@
   'genreid' => { 
     data_type => 'integer',
     is_nullable => 1,
+  },
+  'single_track' => {
+    data_type => 'integer',
+    is_nullable => 1,
+    is_foreign_key => 1,
   }
 );
 __PACKAGE__->set_primary_key('cdid');
@@ -32,6 +37,9 @@
     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' );
+
 __PACKAGE__->has_many( tracks => 'DBICTest::Schema::Track' );
 __PACKAGE__->has_many(
     tags => 'DBICTest::Schema::Tag', undef,

Modified: DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Track.pm
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Track.pm	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/lib/DBICTest/Schema/Track.pm	2008-11-16 22:16:31 UTC (rev 5150)
@@ -35,4 +35,6 @@
 __PACKAGE__->belongs_to( cd => 'DBICTest::Schema::CD' );
 __PACKAGE__->belongs_to( disc => 'DBICTest::Schema::CD' => 'cd');
 
+__PACKAGE__->might_have( cd_single => 'DBICTest::Schema::CD', 'single_track' );
+
 1;

Modified: DBIx-Class/0.08/trunk/t/lib/sqlite.sql
===================================================================
--- DBIx-Class/0.08/trunk/t/lib/sqlite.sql	2008-11-16 22:14:13 UTC (rev 5149)
+++ DBIx-Class/0.08/trunk/t/lib/sqlite.sql	2008-11-16 22:16:31 UTC (rev 5150)
@@ -1,6 +1,6 @@
 -- 
 -- Created by SQL::Translator::Producer::SQLite
--- Created on Mon Nov 10 23:52:55 2008
+-- Created on Sun Nov 16 10:43:11 2008
 -- 
 BEGIN TRANSACTION;
 
@@ -58,11 +58,13 @@
   artist integer NOT NULL,
   title varchar(100) NOT NULL,
   year varchar(100) NOT NULL,
-  genreid integer
+  genreid integer,
+  single_track integer
 );
 
 CREATE INDEX cd_idx_artist_cd ON cd (artist);
 CREATE INDEX cd_idx_genreid_cd ON cd (genreid);
+CREATE INDEX cd_idx_single_track_cd ON cd (single_track);
 CREATE UNIQUE INDEX cd_artist_title_cd ON cd (artist, title);
 
 --




More information about the Bast-commits mailing list