[Bast-commits] r9011 -
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks
rbo at dev.catalyst.perl.org
rbo at dev.catalyst.perl.org
Mon Mar 15 17:24:47 GMT 2010
Author: rbo
Date: 2010-03-15 17:24:47 +0000 (Mon, 15 Mar 2010)
New Revision: 9011
Modified:
DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm
Log:
Update _order_siblings_by, use _order_by_chunks instead of own stuff
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-03-15 15:52:24 UTC (rev 9010)
+++ DBIx-Class/0.08/branches/oracle_hierarchical_queries_rt39121/lib/DBIx/Class/SQLAHacks/Oracle.pm 2010-03-15 17:24:47 UTC (rev 9011)
@@ -66,16 +66,25 @@
}
sub _order_siblings_by {
- my $self = shift;
- my $ref = ref $_[0];
+ my ( $self, $arg ) = @_;
- my @vals = $ref eq 'ARRAY' ? @{$_[0]} :
- $ref eq 'SCALAR' ? ${$_[0]} :
- $ref eq '' ? $_[0] :
- puke( "Unsupported data struct $ref for ORDER SIBILINGS BY" );
+ my ( @sql, @bind );
+ for my $c ( $self->_order_by_chunks($arg) ) {
+ $self->_SWITCH_refkind(
+ $c,
+ {
+ SCALAR => sub { push @sql, $c },
+ ARRAYREF => sub { push @sql, shift @$c; push @bind, @$c },
+ }
+ );
+ }
- my $val = join ', ', map { $self->_quote($_) } @vals;
- return $val ? $self->_sqlcase(' order siblings by')." $val" : '';
+ my $sql =
+ @sql
+ ? sprintf( '%s %s', $self->_sqlcase(' order siblings by'), join( ', ', @sql ) )
+ : '';
+
+ return wantarray ? ( $sql, @bind ) : $sql;
}
1;
More information about the Bast-commits
mailing list