Ticket #4130 (new defect)

Opened 2 years ago

Postgis like/ilike comparison with integer field

Reported by: aboudreault Owned by: aboudreault
Priority: normal Milestone: 6.2 release
Component: MapServer C Library Version: svn-trunk (development)
Severity: normal Keywords:
Cc: pramsey

Description

A client has the need to use a WFS filter with a like comparison and an integer field. Checking the mapogcfilter.c code and I see that an easy fix could be done: cast all fields to string when like is used. In the function FLTGetIsLikeComparisonSQLExpression(), we would replace:

if (bCaseInsensitive == 1 && lp->connectiontype == MS_POSTGIS)
      strlcat(szBuffer, " ilike '", bufferSize);
    else
      strlcat(szBuffer, " like '", bufferSize);

by

const char *like_stmt = lp->connectiontype == MS_POSTGIS ? "::text like '" : " like '";
if (bCaseInsensitive == 1 && lp->connectiontype == MS_POSTGIS)
      strlcat(szBuffer, "::text ilike '", bufferSize);
    else
      strlcat(szBuffer, like_stmt, bufferSize);

Paul, do you see any issue about that?

Note: See TracTickets for help on using tickets.