[Jifty-commit] r1872 - jifty/trunk/lib/Jifty/Action/Record

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Aug 28 11:12:53 EDT 2006


Author: nelhage
Date: Mon Aug 28 11:12:50 2006
New Revision: 1872

Modified:
   jifty/trunk/lib/Jifty/Action/Record/Search.pm

Log:
Integer C<gt> or C<lt> searching.

Modified: jifty/trunk/lib/Jifty/Action/Record/Search.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record/Search.pm	(original)
+++ jifty/trunk/lib/Jifty/Action/Record/Search.pm	Mon Aug 28 11:12:50 2006
@@ -30,10 +30,18 @@
 
 =over 4
 
-=item C<text> or C<textarea> fields
+=item C<text> or C<varchar> fields
 
 Create C<field>_contains and C<field>_lacks arguments.
 
+=item C<date>, or C<timestamp> fields
+
+Create C<field>_before and C<field>_after ar
+
+=item integer fields
+
+Generate C<field>_lt and C<field>_gt arguments
+
 =back
 
 =cut
@@ -74,7 +82,7 @@
         # XXX TODO: What about booleans? Checkbox doesn't quite work,
         # since there are three choices: yes, no, either.
 
-        if($column->type =~ /^text/i) {
+        if($column->type =~ /^(?:text|varchar)/i) {
             my $label = $info->{label} || $field;
             $args->{"${field}_contains"} = {%$info, label => "$label contains"};
             $args->{"${field}_lacks"} = {%$info, label => "$label lacks"};
@@ -82,6 +90,11 @@
             my $label = $info->{label} || $field;
             $args->{"${field}_after"} = {%$info, label => "$label after"};
             $args->{"${field}_before"} = {%$info, label => "$label before"};
+        } elsif(    $column->type =~ /(?:int)/
+                && !$column->refers_to) {
+            my $label = $info->{label} || $field;
+            $args->{"${field}_gt"} = {%$info, label => "$label greater than"};
+            $args->{"${field}_lt"} = {%$info, label => "$label less than"};
         }
     }
 
@@ -130,9 +143,9 @@
                 } elsif($op eq 'lacks') {
                     $op = 'NOT LIKE';
                     $value = "%$value%";
-                } elsif($op eq 'after') {
+                } elsif($op eq 'after' || $op eq 'gt') {
                     $op = '>';
-                } elsif($op eq 'before') {
+                } elsif($op eq 'before' || $op eq 'lt') {
                     $op = '<';
                 }
             } else {


More information about the Jifty-commit mailing list