$sql .= $self->_sqlcase(' start with ') . $ws;
push @bind, @wb;
}
- if ( my $connect_by = $attrs->{'connect_by'} ) {
- my ($connect_by_sql, @connect_by_sql_bind) = $self->_recurse_where( $attrs->{'connect_by'} );
+ if ( my $connect_by = $attrs->{'connect_by'} || $attrs->{'connect_by_nocycle'} ) {
+ my ($connect_by_sql, @connect_by_sql_bind) = $self->_recurse_where( $connect_by );
$sql .= sprintf(" %s %s",
( $attrs->{'connect_by_nocycle'} ) ? $self->_sqlcase('connect by nocycle')
: $self->_sqlcase('connect by'),
$connect_by_sql,
);
push @bind, @connect_by_sql_bind;
- # $sql .= $self->_sqlcase(' connect by');
- # foreach my $key ( keys %$connect_by ) {
- # $sql .= " $key = " . $connect_by->{$key};
- # }
}
if ( $attrs->{'order_siblings_by'} ) {
$sql .= $self->_order_siblings_by( $attrs->{'order_siblings_by'} );
Following additional attributes can be used in resultsets.
-=head2 connect_by
+=head2 connect_by or connect_by_nocycle
=over 4
A hashref of conditions used to specify the relationship between parent rows
and child rows of the hierarchy.
+
connect_by => { parentid => 'prior personid' }
# adds a connect by statement to the query:
# person me
# CONNECT BY
# parentid = prior persionid
+
-=head2 connect_by_nocycle
-
-=over 4
-
-=item Value: [1|0]
-
-=back
-
-If you want to use NOCYCLE set to 1.
+ connect_by_nocycle => { parentid => 'prior personid' }
- connect_by => { parentid => 'prior personid' },
- connect_by_nocycle => 1
-
- # adds a connect by statement to the query:
- # SELECT
- # me.persionid me.firstname, me.lastname, me.parentid
- # FROM
- # person me
- # CONNECT BY NOCYCLE
- # parentid = prior persionid
+ # adds a connect by statement to the query:
+ # SELECT
+ # me.persionid me.firstname, me.lastname, me.parentid
+ # FROM
+ # person me
+ # CONNECT BY NOCYCLE
+ # parentid = prior persionid
=head2 start_with
# select the whole cycle tree with nocylce
{
my $rs = $schema->resultset('Artist')->search({}, {
- connect_by_nocycle => 1,
start_with => { name => 'cycle-root' },
'+select' => [ \ 'CONNECT_BY_ISCYCLE' ],
- connect_by => { parentid => { -prior => \ 'artistid' } },
+ connect_by_nocycle => { parentid => { -prior => \ 'artistid' } },
});
is_same_sql_bind (