Hello,

i've a problem to define a relationship between two tables where the join condition need an operator different than '='.

The idea of the db design is (i'm using postgresql) :
TABLE networks => VARCHAR name, CIDR net
TABLE ips => INET addr, VARCHAR hostname
* CIDR is a type to define a network (for exemple 192.168.1.0/24)
* INET is a type to define an IP address (for exemple 192.168.1.37)
* with pgsql, you can use the '<<=' operator to know if an INET is inside of a CIDR.

i'd like to select all ips, and for each, the associated network name.
With SQL i can (successfully) use this request :
"SELECT ips.addr, networks.name FROM ips INNER JOIN networks ON ips.addr <<= networks.net;"

as you can see, the join condition is "ips.addr <<= networks.net"

In the documentation (DBIx::Class::Relationship::Base) i saw that :
"The condition needs to be an SQL::Abstract <http://search.cpan.org/perldoc?SQL%3A%3AAbstract>-style representation of the join between the tables"

so, into my schema module i tried this :
__PACKAGE__->add_relationship("network", "Networks", { 'foreign.net' => { '<<=', 'self.addr'} } ); to force an operator other than 'equal', but it don't work, because the condition key/value is check (into ResultSource.pm, function resolve_condition) and it doesn't like an hash ref as the value (because it check directly if the scalar contains foreign or self keywords).

Any idea how i can describe this "simple" join condition with DBIx::Class ??
The only thing missing (i think) is to force the condition operator ...

Thank you for helps

Anthony Hinsinger.
Universite de Pau - France


_______________________________________________
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]/

Reply via email to