You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cayenne.apache.org by Victor Antonovich <v....@gmail.com> on 2010/08/25 14:48:17 UTC

Escaping of characters in like/likeIgnoreCase expressions

Hello!

What is correct way of escaping of '%' and '_' characters in query 
like/likeIgnoreCase expressions? Looks like escape chars can be 
specified when Expression instances are created using ExpressionFactory 
methods, but what about expression string representation to use with 
Expression.fromString() method?

Thanks,
Victor.

Re: Escaping of characters in like/likeIgnoreCase expressions

Posted by Victor Antonovich <v....@gmail.com>.
Hello!

25.08.2010 17:21, Michael Gentry wrote:

> Hi Victor,
>
> What does your Expression.fromString() look like?
>
> If I recall correctly, a % or _ in the substitution map will
> automatically be escaped for you, but the actual fromString("...")
> part will not.
>
> mrg

Thank you for the reply. Actually string expression for passing to 
Expression.fromString() is composed from LDAP-like query by ANTLR 
generated parser. For example, LDAP expression "(someProperty=a*b*c)" 
will be transformed into Cayenne query "(someProperty like a%b%c)", but 
what is Cayenne representation of LDAP expression like 
"(someProperty=%*b*%)"?

Regards,
Victor.

Re: Escaping of characters in like/likeIgnoreCase expressions

Posted by Andrus Adamchik <an...@objectstyle.org>.
Actually support for escape char was added per CAY-1380 to ExpressionFactory in Cayenne 3.0.1 (which will hopefully be released in a week or two. To get this feature you can either do a build from 3.0-STABLE branch [1] or wait, or use EJBQLQuery that already supports it in 3.0.

Cheers,
Andrus


[1] https://svn.apache.org/repos/asf/cayenne/main/branches/STABLE-3.0/

On Aug 25, 2010, at 4:21 PM, Michael Gentry wrote:

> Hi Victor,
> 
> What does your Expression.fromString() look like?
> 
> If I recall correctly, a % or _ in the substitution map will
> automatically be escaped for you, but the actual fromString("...")
> part will not.
> 
> mrg
> 
> 
> On Wed, Aug 25, 2010 at 8:48 AM, Victor Antonovich
> <v....@gmail.com> wrote:
>> Hello!
>> 
>> What is correct way of escaping of '%' and '_' characters in query
>> like/likeIgnoreCase expressions? Looks like escape chars can be specified
>> when Expression instances are created using ExpressionFactory methods, but
>> what about expression string representation to use with
>> Expression.fromString() method?
>> 
>> Thanks,
>> Victor.
>> 
> 


Re: Escaping of characters in like/likeIgnoreCase expressions

Posted by Michael Gentry <mg...@masslight.net>.
Hi Victor,

What does your Expression.fromString() look like?

If I recall correctly, a % or _ in the substitution map will
automatically be escaped for you, but the actual fromString("...")
part will not.

mrg


On Wed, Aug 25, 2010 at 8:48 AM, Victor Antonovich
<v....@gmail.com> wrote:
> Hello!
>
> What is correct way of escaping of '%' and '_' characters in query
> like/likeIgnoreCase expressions? Looks like escape chars can be specified
> when Expression instances are created using ExpressionFactory methods, but
> what about expression string representation to use with
> Expression.fromString() method?
>
> Thanks,
> Victor.
>