Re: Problem with empty has_a

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

From: Thomas Klausner
Subject: Re: Problem with empty has_a
Date: 07:05 on 20 May 2005
Hi!

On Thu, May 19, 2005 at 10:01:28PM +0100, Tony Bowden wrote:
> On Thu, May 19, 2005 at 09:34:45PM +0200, Thomas Klausner wrote:
> > Anyway, what's causing the problem 
> 
> Your database is in a state of broken referential integrity. In
> particular you have a foreign key pointing at a table which doesn't have
> an entry matching the value that you've given it.

Seems I need a might_has_a relationship.

/me re-reads the docs and scribbles some code...

In fact might_have works as well. D'oh!

I didn't consider might_have because I once used it to import methods from
the might_have class and sort of forgot that it also works without importing.

33,34c33,34
< Bar->columns(All=>qw[id bar foo]);
< Bar->has_a(foo=>'Foo');
---
> Bar->columns(All=>qw[id bar]);
> Bar->might_have(foo=>'Foo');


> I'm not sure what Class::DBI should do here. At the minute it takes
> the view that if you've told it that the row exists, then it's happy to
> believe you.
>
> We could have select_row() in DBIx::ContextualFetch check to see if
> there really was any results from fetching the row, and throw an
> exception otherwise, but I'm not clear at a glance what the other
> repercussions might be...

As might_have is doing what I needed I guess no changes to Class::DBI are
neccessary. Unless you consider the reported behaviour a bug...

        -- 
        #!/usr/bin/perl                               http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}

Problem with empty has_a
Thomas Klausner 19:34 on 19 May 2005

Re: Problem with empty has_a
Tony Bowden 21:01 on 19 May 2005

Re: Problem with empty has_a
Thomas Klausner 07:05 on 20 May 2005

Re: Problem with empty has_a
Thomas Klausner 07:39 on 20 May 2005

Re: Problem with empty has_a
merlyn (Randal L. Schwartz) 12:20 on 20 May 2005

Re: Problem with empty has_a
Tony Bowden 12:33 on 20 May 2005

Re: Problem with empty has_a
Perrin Harkins 13:43 on 20 May 2005

Generated at 15:51 on 25 May 2005 by mariachi v0.52