Select to view content in your preferred language

setDefinitionExpression and LIKE operator and wildcard % issues

1260
1
09-24-2014 04:19 PM
GustafJonsson
Deactivated User

I am using the setDefinitionExpression on some of my FeatureLayers. This works fine in most cases but I believe there might be a bug in the API when it comes to the LIKE operator and the % wildcard.

When using expressions such as;

myField LIKE '%Ca%' 

I get no results even though "myField"  has several records including the word "Catchment"

however I always get correct results when just using a single character between the % wildcards, such as

myField LIKE '%C%' 

or

myField LIKE '%a%' 

interestingly, it does sometimes work as expected with multiple characters (depends on the character combination), e.g.

myField LIKE '%tr%' 

works fine and returns the correct features

I suspect this may be a bug in the API since the getDefinitionExpression always returns the expression exactly as I stated it.

In essence, it appears to be a parsing issue with %xx in the definition expressions.

I'm on version 3.10 now and I am pretty sure this was not an issue in 3.8.

Anyone else had this issue?

Thanks

0 Kudos
1 Reply
GustafJonsson
Deactivated User

I still think this is an issue however I did find a workaround for what I am doing.

Replace any % wildcards with its hexadecimal encoding %25

E.g. replace misbehaving expressions such as

myField LIKE '%Ca%'

with

myField LIKE '%25Ca%25'

This works well for me

0 Kudos