[Dbix-class] belongs_to with non-foreign keys

Christopher Heschong chris at wiw.org
Fri Jun 22 20:28:20 GMT 2007


So I have this search:

my $addr = 16843009;

$rs->search( {
            address => { '<=', $addr },
            $addr => \'<= (address - 1 + (2 << 31 - bits))'
});


(Essentially, this finds the parent networks of an IP address whose int
val is $addr (aka 1.1.1.1))

And I want to turn it into a join (so I can prefetch it), but I'm running
into problems.  I've tried something like this:

__PACKAGE__->belongs_to( parent => 'MyApp::DB::Network',
    {
        'foreign.address'      => { '<=', 'self.address' },
        'self.address'         => \'<= (foreign.address - 1 + (2 << 31 -
foreign.bits))'
    },
    { join     => [qw(network)] }
);


but it looks like DBIx::Class joins won't accept anything but /^foreign./
named keys.  Any ideas on how I could get something like this to work?

--
/chris/




More information about the Dbix-class mailing list