I think I'm missing something obvious here. But I've fried my brain
thinking about it.
A foo can have many associated bars. So I have this.
__PACKAGE__->has_many(
'bars' => 'MyDB::Result::Bar',
{ 'foreign.foo_id' => 'self.id' },
);
But, each bar has start and end dates associated with it. So at most
one bar record is active for a foo at any given time[1].
I thought I could do something like this:
__PACKAGE__->might_have(
'active_bar' => 'MyDB::Result::Bar',
{
'foreign.foo_id' => 'self.id',
'foreign.start' => { '<=' => \'now()' },
'foreign.end => { '>=' => \'now()' }
},
);
But I get an error saying 'Invalid rel cond val'. This comes from code
in DBIx::Class::ResultSource::_resolve_condition which checks that all
values in the condition hash include the string 'self'.
So how do I model this relationship? Am I mad for even trying?
Dave...
[1] Yes, this is hard to maintain. But the schema isn't going to change.
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/[email protected]