[Rt-commit] rt branch, 4.0/advanced-search-unknown-field-fix, created. rt-4.0.1rc1-6-g0f880df

? sunnavy sunnavy at bestpractical.com
Wed Jun 1 09:00:28 EDT 2011


The branch, 4.0/advanced-search-unknown-field-fix has been created
        at  0f880df49f3960f9e2823769eb59dd7379383fbf (commit)

- Log -----------------------------------------------------------------
commit 43853e43b33fe4741a74745ab8c888e0b8743f8e
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jun 1 19:34:46 2011 +0800

    avoid error "Unknown field: Status" or alike in advanced search
    
    this happens if use other cases of "Status".
    e.g. "status = 'open'"

diff --git a/lib/RT/Interface/Web/QueryBuilder/Tree.pm b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
index 493ab44..860485e 100644
--- a/lib/RT/Interface/Web/QueryBuilder/Tree.pm
+++ b/lib/RT/Interface/Web/QueryBuilder/Tree.pm
@@ -260,8 +260,9 @@ sub ParseSQL {
 
         my $class;
         if ( exists $lcfield{ lc $main_key } ) {
-            $class = $field{ $main_key }->[0];
             $key =~ s/^[^.]+/ $lcfield{ lc $main_key } /e;
+            ($main_key) = split /[.]/, $key;  # make the case right
+            $class = $field{ $main_key }->[0];
         }
         unless( $class ) {
             push @results, [ $args{'CurrentUser'}->loc("Unknown field: [_1]", $key), -1 ]

commit 0f880df49f3960f9e2823769eb59dd7379383fbf
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Jun 1 20:59:35 2011 +0800

    test lower cased field in advanced search

diff --git a/t/web/query_builder.t b/t/web/query_builder.t
index 4ae4392..0abbfac 100644
--- a/t/web/query_builder.t
+++ b/t/web/query_builder.t
@@ -5,7 +5,7 @@ use HTTP::Request::Common;
 use HTTP::Cookies;
 use LWP;
 use Encode;
-use RT::Test tests => 52;
+use RT::Test tests => 56;
 
 my $cookie_jar = HTTP::Cookies->new;
 my ($baseurl, $agent) = RT::Test->started_ok;
@@ -281,3 +281,17 @@ diag "click advanced, enter an invalid SQL IS NOT restriction, apply and check t
     );
 }
 
+diag "click advanced, enter a valid SQL, but the field is lower cased";
+{
+    my $response = $agent->get($url."Search/Edit.html");
+    ok( $response->is_success, "Fetched /Search/Edit.html" );
+    ok($agent->form_name('BuildQueryAdvanced'), "found the form");
+    $agent->field("Query", "status = 'new'");
+    $agent->submit;
+    $agent->content_lacks( 'Unknown field:', 'no "unknown field" warning' );
+    is( getQueryFromForm($agent),
+        "Status = 'new'",
+        "field's case is corrected"
+    );
+}
+

-----------------------------------------------------------------------


More information about the Rt-commit mailing list