2

Within classes I'm able to match strings using CLASSITEM, but not when including the field name in the expression, for example (inside a layer declaration):

CLASSITEM "myfieldname"
CLASS
    EXPRESSION "sometext"
END

Works fine, but

CLASS
    EXPRESSION ([myfieldname] = "sometext")
END

Doesn't return any data

The second method is fine when working with integers, e.g.

CLASS
    EXPRESSION ([myintegerfieldname] = 10)
END

I've tried enclosing the strings with single quotes, double quotes, using a regex instead. The same behaviour occurs when the source data is a shapefile or a postgis layer.

Using CLASSITEM is obviously a good work-around, but it would be useful to know what I'm doing wrong with the direct comparison.

Thanks!

Tom
  • 365
  • 2
  • 9

1 Answers1

1

Try:

CLASS
   EXPRESSION ("[myfieldname]" = "sometext")
END

this should force mapserver to use the string equality operator on both fields and explains why it does work with numbers.

unicoletti
  • 7,339
  • 22
  • 33