From: Robert Bohne Date: Mon, 15 Mar 2010 17:24:47 +0000 (+0000) Subject: Update _order_siblings_by, use _order_by_chunks instead of own stuff X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2a770efe3271dc733b55d61f9fc28ab57ae33285;p=dbsrgits%2FDBIx-Class-Historic.git Update _order_siblings_by, use _order_by_chunks instead of own stuff --- diff --git a/lib/DBIx/Class/SQLAHacks/Oracle.pm b/lib/DBIx/Class/SQLAHacks/Oracle.pm index a4a815e..6046372 100644 --- a/lib/DBIx/Class/SQLAHacks/Oracle.pm +++ b/lib/DBIx/Class/SQLAHacks/Oracle.pm @@ -66,16 +66,25 @@ sub _connect_by { } sub _order_siblings_by { - my $self = shift; - my $ref = ref $_[0]; + my ( $self, $arg ) = @_; + + 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 @vals = $ref eq 'ARRAY' ? @{$_[0]} : - $ref eq 'SCALAR' ? ${$_[0]} : - $ref eq '' ? $_[0] : - puke( "Unsupported data struct $ref for ORDER SIBILINGS BY" ); + my $sql = + @sql + ? sprintf( '%s %s', $self->_sqlcase(' order siblings by'), join( ', ', @sql ) ) + : ''; - my $val = join ', ', map { $self->_quote($_) } @vals; - return $val ? $self->_sqlcase(' order siblings by')." $val" : ''; + return wantarray ? ( $sql, @bind ) : $sql; } 1;