
interchange-cvs at icdevgroup
Dec 15, 2011, 1:08 AM
Views: 201
Permalink
|
|
[interchange] New "rawsort" attribute, fixed sort attribute whitespace problem.
|
|
commit a0cf98858c613303984fb3f20765cf520a45f5c4 Author: Peter Ajamian <peter [at] pajamian> Date: Thu Dec 15 22:01:37 2011 +1300 New "rawsort" attribute, fixed sort attribute whitespace problem. New "rawsort" attribute allows you to pass a verbatim sort to the SQL database without any parsing by Interchange. This allows you to do things like this: Options Simple sort CAST(o_sort AS int) Options Simple rawsort 1 ...the above would sort option widgets based on teh o_sort attribute and force a numeric sort. There are numerous other possibilities of how you might want to use this as well. The existing find_sort routine returned the "ORDER BY ..." without any leading whitespace, and was tacked onto the end of the sql query in Simple.pm without any trailing whitespace thus causing a syntax error in the generated SQL. This is now fixed by adding a leading space onto the returned value of find_sort(). lib/Vend/Options.pm | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) --- diff --git a/lib/Vend/Options.pm b/lib/Vend/Options.pm index 827d99c..3d0d898 100644 --- a/lib/Vend/Options.pm +++ b/lib/Vend/Options.pm @@ -165,6 +165,7 @@ sub find_sort { #::logDebug("called find_sort from " . scalar(caller()) . ", opt=" . ::uneval($opt)); $opt->{sort} = defined $opt->{sort} ? $opt->{sort} : $loc->{sort}; return '' unless $opt->{sort}; + return " ORDER BY $opt->{sort}" if $opt->{rawsort} || $loc->{rawsort}; my @fields = split /\s*,\s*/, $opt->{sort}; my $map = $loc->{map} ||= {}; for(@fields) { @@ -182,7 +183,7 @@ sub find_sort { $_ .= $extra if $extra; } - return "ORDER BY " . join(",", @fields); + return " ORDER BY " . join(",", @fields); } sub tag_options { _______________________________________________ interchange-cvs mailing list interchange-cvs [at] icdevgroup http://www.icdevgroup.org/mailman/listinfo/interchange-cvs
|