-#this duplicates/ovverrides the DBIx::SearchBuilder version..
-# we need to fix the "handle FUNCTION(FIELD)" stuff and this is much easier
-# than patching SB
-# but does this have other terrible ramifications? maybe a flag to trigger
-# this specific case?
-sub _OrderClause {
- my $self = shift;
-
- return '' unless $self->{'order_by'};
-
- my $clause = '';
- foreach my $row ( @{$self->{'order_by'}} ) {
-
- my %rowhash = ( ALIAS => 'main',
- FIELD => undef,
- ORDER => 'ASC',
- %$row
- );
- if ($rowhash{'ORDER'} && $rowhash{'ORDER'} =~ /^des/i) {
- $rowhash{'ORDER'} = "DESC";
- }
- else {
- $rowhash{'ORDER'} = "ASC";
- }
- $rowhash{'ALIAS'} = 'main' unless defined $rowhash{'ALIAS'};
-
- if ( defined $rowhash{'ALIAS'} and
- $rowhash{'FIELD'} and
- $rowhash{'ORDER'} ) {
-
- if ( length $rowhash{'ALIAS'} && $rowhash{'FIELD'} =~ /^((\w+\()+)(.*\)+)$/ ) {
- # handle 'FUNCTION(FIELD)' formatted fields
- $rowhash{'FIELD'} = $1. $rowhash{'ALIAS'}. '.'. $3;
- $rowhash{'ALIAS'} = '';
- }
-
- $clause .= ($clause ? ", " : " ");
- $clause .= $rowhash{'ALIAS'} . "." if length $rowhash{'ALIAS'};
- $clause .= $rowhash{'FIELD'} . " ";
- $clause .= $rowhash{'ORDER'};
- }
- }
- $clause = " ORDER BY$clause " if $clause;
-
- return $clause;
-}
-