[Dbix-class] help building query w/ ->search() or using arbitrary select?
George Hartzell
hartzell at alerce.com
Wed Aug 9 20:14:43 CEST 2006
George Hartzell writes:
> [...]
> Holy Mackerel:
>
> my $rs = $s->resultset('...')->search({
> 'node_count(me.id)' => 2,
> 'control_count(me.id)' => 1,
> 'attrs.name' => 'NodeType',
> 'attrs.value' => 'Protein',
> 'attrs_2.name' => 'Organism',
> 'attrs_2.value' => 'Homo sapiens',
> 'attrs_3.name' => 'NodeType',
> 'attrs_3.value' => 'Protein',
> 'attrs_4.name' => 'Organism',
> 'attrs_4.value' => 'Homo sapiens',
> 'rncbts.value' => 'Protein',
> 'rncbts.count' => 2,
> },
> {
> join => [{nodes =>
> ['attrs', 'attrs']},
> {nodes =>
> ['attrs', 'attrs']},
> 'rncbts',
> ]
> },
> );
>
>
> which says that attrs and attrs_2 belong_to one node, and attrs_3 and
> attrs_4 belong to the other.
>
> wow. yeesh.
> [...]
As it stands above, it finds <rn>'s that have two nodes, but it
happily just uses one of them to meet the constraints on attrs/attrs_1
then uses the same node to satisfy the constraints on attrs_3/attrs_4.
I need nodes and nodes_2 to be different. e.g. my hand coded sql said
something like nodes.id != nodes_2.id.
I'm not sure where to express that conststraint.
Thanks,
g.
More information about the Dbix-class
mailing list