Skip Menu |
 

This queue is for tickets about the DBIx-SearchBuilder CPAN distribution.

Report information
The Basics
Id: 4134
Status: resolved
Priority: 0/
Queue: DBIx-SearchBuilder

People
Owner: Nobody in particular
Requestors: autrijus [...] autrijus.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Date: Fri, 17 Oct 2003 08:10:39 +0800
From: Autrijus Tang <autrijus [...] autrijus.org>
To: bug-dbix-searchbuilder [...] rt.cpan.org
Subject: [PATCH] Make OrderBy take FUNCTION(FIELD)
Here I have a query that must be ->OrderByCols( { FIELD => 'ISNULL(Description)'}, { FIELD => 'Name' } ); So below is the patch that makes it happen. :-) Thanks, /Autrijus/ --- SearchBuilder.pm Mon Aug 11 20:10:15 2003 +++ /usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder.pm Thu Aug 14 20:46:04 2003 @@ -923,7 +923,7 @@ Takes a paramhash of ALIAS, FIELD and ORDER. ALIAS defaults to main -FIELD defaults to the primary key of the main table. +FIELD defaults to the primary key of the main table. Also accepts C<FUNCTION(FIELD)> format ORDER defaults to ASC(ending). DESC(ending) is also a valid value for OrderBy @@ -966,6 +966,12 @@ if ( ($rowhash{'ALIAS'}) and ($rowhash{'FIELD'}) and ($rowhash{'ORDER'}) ) { + + if ($rowhash{'FIELD'} =~ /^(\w+\()(.*\))$/) { + # handle 'FUNCTION(FIELD)' formatted fields + $rowhash{'ALIAS'} = $1 . $rowhash{'ALIAS'}; + $rowhash{'FIELD'} = $2; + } $clause .= ($clause ? ", " : " "); $clause .= $rowhash{'ALIAS'} . ".";
Download (untitled) / with headers
text/plain 1.1k
Applied a long time ago. Show quoted text
> > Here I have a query that must be ->OrderByCols( > { FIELD => 'ISNULL(Description)'}, > { FIELD => 'Name' } > ); > > So below is the patch that makes it happen. :-) > > Thanks, > /Autrijus/ > > --- SearchBuilder.pm Mon Aug 11 20:10:15 2003 > +++ /usr/local/lib/perl5/site_perl/5.8.0/DBIx/SearchBuilder.pm
Thu Aug Show quoted text
> 14 20:46:04 2003 > @@ -923,7 +923,7 @@ > > Takes a paramhash of ALIAS, FIELD and ORDER. > ALIAS defaults to main > -FIELD defaults to the primary key of the main table. > +FIELD defaults to the primary key of the main table. Also accepts > C<FUNCTION(FIELD)> format > ORDER defaults to ASC(ending). DESC(ending) is also a valid value > for OrderBy > > > @@ -966,6 +966,12 @@ > if ( ($rowhash{'ALIAS'}) and > ($rowhash{'FIELD'}) and > ($rowhash{'ORDER'}) ) { > + > + if ($rowhash{'FIELD'} =~ /^(\w+\()(.*\))$/) { > + # handle 'FUNCTION(FIELD)' formatted fields > + $rowhash{'ALIAS'} = $1 . $rowhash{'ALIAS'}; > + $rowhash{'FIELD'} = $2; > + } > > $clause .= ($clause ? ", " : " "); > $clause .= $rowhash{'ALIAS'} . ".";


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.