patch for has_a() on primary keys

[prev] [thread] [next] [Date index for 2005/05/27]

From: Perrin Harkins
Subject: patch for has_a() on primary keys
Date: 18:51 on 27 May 2005
--=-3MFO1eGFp4xsdNhuxlQx
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

I finally needed this to work, so here's a test that shows the failure
and a patch that fixes it.

- Perrin

--=-3MFO1eGFp4xsdNhuxlQx
Content-Disposition: attachment; filename=has_a.patch
Content-Type: text/x-patch; name=has_a.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -r -u orig/Class-DBI-0.96/lib/Class/DBI/Relationship/HasA.pm Class-DBI-0.96/lib/Class/DBI/Relationship/HasA.pm
--- orig/Class-DBI-0.96/lib/Class/DBI/Relationship/HasA.pm	2004-04-25 11:33:36.000000000 -0400
+++ Class-DBI-0.96/lib/Class/DBI/Relationship/HasA.pm	2005-05-27 14:43:36.000000000 -0400
@@ -23,6 +23,7 @@
 	my $column = $self->accessor;
 	return (
 		select              => $self->_inflator,
+		after_create        => $self->_inflator,
 		"after_set_$column" => $self->_inflator,
 		deflate_for_create  => $self->_deflator(1),
 		deflate_for_update  => $self->_deflator,
diff -r -u orig/Class-DBI-0.96/t/06-hasa.t Class-DBI-0.96/t/06-hasa.t
--- orig/Class-DBI-0.96/t/06-hasa.t	2003-08-19 12:50:07.000000000 -0400
+++ Class-DBI-0.96/t/06-hasa.t	2005-05-27 14:30:14.000000000 -0400
@@ -3,7 +3,7 @@
 
 BEGIN {
 	eval "use DBD::SQLite";
-	plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 24);
+	plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 25);
 }
 
 @YA::Film::ISA = 'Film';
@@ -164,3 +164,19 @@
 	isa_ok $foo, "Film", "Object in after_create trigger";
 }
 
+# test has_a() on primary keys
+package MultiKey;
+use base 'CDBase';
+__PACKAGE__->table('multikey');
+__PACKAGE__->columns('Primary' => qw/ id film /);
+__PACKAGE__->has_a(film => "Film");
+__PACKAGE__->db_Main->do( qq{
+     CREATE TABLE multikey (
+	     id        INTEGER,
+	     film      VARCHAR(255)
+     )
+});
+
+package main;
+my $from_scalar = MultiKey->create({ id => 7, film => 'Bad Taste' });
+isa_ok($from_scalar->film(), "Film");
Only in Class-DBI-0.96/t: 06-hasa.t~

--=-3MFO1eGFp4xsdNhuxlQx--

patch for has_a() on primary keys
Perrin Harkins 18:51 on 27 May 2005

Re: patch for has_a() on primary keys
Charles Bailey 19:01 on 27 May 2005

Re: patch for has_a() on primary keys
Perrin Harkins 19:58 on 27 May 2005

Re: patch for has_a() on primary keys
Charles Bailey 22:16 on 27 May 2005

Generated at 20:11 on 05 Jun 2005 by mariachi v0.52