[Bast-commits] r9374 - in
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121:
lib/DBIx/Class/SQLAHacks lib/DBIx/Class/Storage/DBI/Oracle t
rbo at dev.catalyst.perl.org
rbo at dev.catalyst.perl.org
Fri May 14 22:02:41 GMT 2010
Author: rbo
Date: 2010-05-14 23:02:41 +0100 (Fri, 14 May 2010)
New Revision: 9374
Modified:
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t
Log:
Use connect_by OR connect_by_nocycle
Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm 2010-05-14 21:55:28 UTC (rev 9373)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm 2010-05-14 22:02:41 UTC (rev 9374)
@@ -55,18 +55,14 @@
$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'} );
Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm 2010-05-14 21:55:28 UTC (rev 9373)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm 2010-05-14 22:02:41 UTC (rev 9374)
@@ -421,7 +421,7 @@
Following additional attributes can be used in resultsets.
-=head2 connect_by
+=head2 connect_by or connect_by_nocycle
=over 4
@@ -432,6 +432,7 @@
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:
@@ -441,29 +442,19 @@
# person me
# CONNECT BY
# parentid = prior persionid
+
-=head2 connect_by_nocycle
+ connect_by_nocycle => { parentid => 'prior personid' }
-=over 4
+ # 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
-=item Value: [1|0]
-=back
-
-If you want to use NOCYCLE set to 1.
-
- 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
-
-
=head2 start_with
=over 4
Modified: DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t
===================================================================
--- DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t 2010-05-14 21:55:28 UTC (rev 9373)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/t/73oracle.t 2010-05-14 22:02:41 UTC (rev 9374)
@@ -640,10 +640,9 @@
# 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 (
More information about the Bast-commits
mailing list