@@ -152,29 +152,42 @@ static buffer *fe_binary_comparison_op(ows * o, buffer * typename, filter_encodi
152152 */
153153static buffer * fe_property_is_like (ows * o , buffer * typename , filter_encoding * fe , xmlNodePtr n )
154154{
155- xmlChar * content , * wildcard , * singlechar , * escape ;
155+ xmlChar * content , * wildcard , * singlechar , * escape , * matchcase ;
156156 buffer * pg_string ;
157157 char * escaped ;
158+ bool sensitive_case = true;
158159
159160 assert (o && typename && fe && n );
160161
161162 wildcard = xmlGetProp (n , (xmlChar * ) "wildCard" );
162163 singlechar = xmlGetProp (n , (xmlChar * ) "singleChar" );
164+ matchcase = xmlGetProp (n , (xmlChar * ) "matchCase" );
163165
164166 if (ows_version_get (o -> request -> version ) == 100 )
165167 escape = xmlGetProp (n , (xmlChar * ) "escape" );
166168 else
167169 escape = xmlGetProp (n , (xmlChar * ) "escapeChar" );
168170
171+ /* By default, comparison is case sensitive */
172+ if (matchcase && !strcmp ((char * ) matchcase , "false" )) sensitive_case = false;
169173
170174 n = n -> children ;
171175
172176 while (n -> type != XML_ELEMENT_NODE ) n = n -> next ; /* eat spaces */
173177
178+ /* If comparison are explicitly not case sensitive */
179+ if (!sensitive_case ) buffer_add_str (fe -> sql , "LOWER(" );
180+
174181 /* We need to cast as varchar at least for timestamp PostgreSQL data type */
175182 buffer_add_str (fe -> sql , " CAST(\"" );
176183 fe -> sql = fe_property_name (o , typename , fe , fe -> sql , n , false, true);
177- buffer_add_str (fe -> sql , "\" AS varchar) LIKE E" );
184+ buffer_add_str (fe -> sql , "\" AS varchar)" );
185+
186+ if (!sensitive_case ) {
187+ buffer_add_str (fe -> sql , ") LIKE LOWER(E" );
188+ } else {
189+ buffer_add_str (fe -> sql , " LIKE E" );
190+ }
178191
179192 n = n -> next ;
180193
@@ -200,9 +213,12 @@ static buffer *fe_property_is_like(ows * o, buffer * typename, filter_encoding *
200213 }
201214 buffer_add_str (fe -> sql , "'" );
202215
216+ if (!sensitive_case ) buffer_add_str (fe -> sql , ")" );
217+
203218 xmlFree (content );
204219 xmlFree (wildcard );
205220 xmlFree (singlechar );
221+ xmlFree (matchcase );
206222 xmlFree (escape );
207223 buffer_free (pg_string );
208224
0 commit comments