Somebody kick the tires at this and apply it if it seems sane please?
Begin forwarded message:
From: Marc Espie <[EMAIL PROTECTED]>
Date: 6 December 2006 15:12:15 GMT
To: [EMAIL PROTECTED]
Subject: DBIx::Class patch: better error diagnostics
Reply-To: [EMAIL PROTECTED]
As I said in former messages, I'm (still) a novice to DBIx::Class,
so I'm
probably qualified to comment on diagnostics ;-)
Those two patches actually helped me set up my schema correctly
(yes, they're
very simple).
I've noticed that the primary key check is the same, so it probably
means
some refactoring would help more, but those were a life-saver for me.
--- lib/DBIx/Class/Relationship/HasMany.pm.orig Wed Dec 6 15:56:28
2006
+++ lib/DBIx/Class/Relationship/HasMany.pm Wed Dec 6 15:57:00 2006
@@ -16,6 +16,10 @@ sub has_many {
"${class} has more"
) if $too_many;
+ $class->throw_exception(
+ "has_many needs a primary key to infer a join; ".
+ "${class} has none"
+ ) if !defined $pri;
my ($f_key,$guess);
if (defined $cond && length $cond) {
$f_key = $cond;
--- lib/DBIx/Class/Relationship/HasOne.pm.orig Wed Dec 6 15:57:05
2006
+++ lib/DBIx/Class/Relationship/HasOne.pm Wed Dec 6 15:58:09 2006
@@ -21,6 +21,10 @@ sub _has_one {
"might_have/has_one can only infer join for a single primary
key; ".
"${class} has more"
) if $too_many;
+ $class->throw_exception(
+ "might_have/has_one needs a primary key to infer a join; ".
+ "${class} has none"
+ ) if !defined $pri;
my $f_class_loaded = eval { $f_class->columns };
my ($f_key,$guess);
if (defined $cond && length $cond) {
--
Matt S Trout, Technical Director, Shadowcat Systems Ltd.
Offering custom development, consultancy and support contracts for
Catalyst,
DBIx::Class and BAST. Contact mst (at) shadowcatsystems.co.uk for
details.
+ Help us build a better perl ORM: http://dbix-
class.shadowcatsystems.co.uk/ +
_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/