Browse files

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().
  • Loading branch information...
1 parent d992a7d commit a0cf98858c613303984fb3f20765cf520a45f5c4 @pajamian pajamian committed Dec 15, 2011
Showing with 2 additions and 1 deletion.
  1. +2 −1 lib/Vend/Options.pm
View
3 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 {

0 comments on commit a0cf988

Please sign in to comment.