Re: Problem with empty has_a
[prev]
[thread]
[next]
[Date index for 2005/05/20]
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$_.$/}