Opened 14 years ago

Closed 13 years ago

#3521 closed defect (fixed)

WFS: case insesitive filters do not work

Reported by: assefa Owned by: assefa
Priority: normal Milestone:
Component: WFS Server Version: unspecified
Severity: normal Keywords:
Cc: sdlime, bartvde

Description

This is what is currently generated for case inseitive searches:

FILTER ("[NAME]" =~ /syd.*/i)

But this seems to be invalid and gives errors such as:

msEvalExpression: Expression parser error. Failed to parse expression: "Tignish" =~ /syd.*/i

Is there a way to use this operand (~=) in a case sensitive way?

Note that using filteritem and then just a regex /syd.*/i works.

Change History (10)

comment:1 by sdlime, 14 years ago

What about trying:

  FILTER ("[NAME]" =~ "^syd.*"i)

Steve

comment:2 by assefa, 14 years ago

Component: MapServer C LibraryWFS Server

Thanks Steve, I tried it but in both cases, I get a parsing error.

Failed to parse expression "Yarmouth" =~ "Syd.*" Failed to parse expression: "Yarmouth" =~ "Syd.*"i

I am disabling (r10460) the matchCase for now until we figure out the correct syntax (if possible).

comment:3 by sdlime, 14 years ago

Well, in 6.0 I'm aiming to add case insensitive operators for string and regex equality (=* and =~*) and do away with the friggin' trailing i's. Let me do some more testing and report back.

Steve

comment:4 by bartvde, 14 years ago

Steve, Assefa,

a colleague of mine had a look and came up with the following patch to mapparser.y:

--- mapparser.y.orig    2010-08-23 13:25:22.000000000 +0200
+++ mapparser.y 2010-08-23 13:21:07.000000000 +0200
@@ -48,6 +48,7 @@
 %type <dblval> math_exp
 %type <strval> string_exp
 %type <strval> regular_exp
+%type <strval> iregular_exp
 %type <tmval> time_exp

 /* Bison/Yacc grammar */
@@ -67,6 +68,7 @@
 ;

 regular_exp: REGEX ;
+iregular_exp: IREGEX ;

 logical_exp:
        logical_exp OR logical_exp      {
@@ -139,6 +141,19 @@
                                       }
        | NOT logical_exp              { $$ = !$2; }
        | NOT math_exp                 { $$ = !$2; }
+       | string_exp RE iregular_exp     {
+                                         ms_regex_t re;
+
+                                         if(ms_regcomp(&re, $3, MS_REG_EXTENDED|MS_REG_NOSUB|MS_REG_ICASE) != 0)
+                                           $$ = MS_FALSE;
+
+                                         if(ms_regexec(&re, $1, 0, NULL, 0) == 0)
+                                          $$ = MS_TRUE;
+                                        else
+                                          $$ = MS_FALSE;
+
+                                         ms_regfree(&re);
+                                       }
        | string_exp RE regular_exp     {
                                          ms_regex_t re;

Are you able to look into this again? We really need to have this working. TIA.

comment:5 by sdlime, 14 years ago

Bart: Which version are you wanting to work against?

Steve

comment:6 by bartvde, 14 years ago

Hi Steve, trunk would be fine for us.

comment:7 by sdlime, 14 years ago

Then it would make more sense for me to implement the case insensitive operators I mentioned earlier (=* and =~*) then... I can do that.

Steve

comment:8 by sdlime, 14 years ago

Ok, I added a case insensitive regex operator to the parser/lexer. The syntax is:

('[county]' ~* /A/)

This follows, fairly closely, the PostgreSQL syntax. This will likely change further with RFC 59 (no /'s necessary) if adopted but should good enough for testing now.

Assefa, can you try modifying the filter code?

Steve

comment:9 by assefa, 14 years ago

out of the office last week ...

reactivate the islike operator r10488. Please give it a try.

comment:10 by assefa, 13 years ago

Resolution: fixed
Status: newclosed

This is fixed. closing.

Note: See TracTickets for help on using tickets.