[ 
https://issues.apache.org/jira/browse/CAY-1971?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrus Adamchik updated CAY-1971:
---------------------------------
    Description: 
http://markmail.org/message/cx7dzla46lcykkzq

An idea that I had while analyzing boilerplate code of the client Cayenne apps. 
An argument to Property.like(..) (or second argument to 
ExpressionFactory.likeExp(..)) requires a full pattern to match against. So 
people would often write their own utility code to wrap a String in "%" signs. 
Cayenne can easily take care of this via a few extra methods. In addition these 
new methods can do proper symbol escaping, making "like" much safer to use. 

Property.contains(string); // same as Property.like("%" + string + "%");
Property.containsInsensitive(string);

Property.startsWith(string); // same as Property.like(string + "%");
Property.startsWithInsensitive(string);

Property.endsWith(string); // same as Property.like("%" + string);
Property.endsWithInsensitive(string);


  was:
http://markmail.org/message/cx7dzla46lcykkzq

An idea that I had while analyzing boilerplate code of the client Cayenne apps. 
An argument to Property.like(..) (or second argument to 
ExpressionFactory.likeExp(..)) requires a full pattern to match against. So 
people would often write their own utility code to wrap a String in "%" signs. 
Cayenne can easily take care of this via a few extra methods. In addition these 
new methods can do proper symbol escaping, making "like" much safer to use. 

Property.contains(string); // same as Property.like("%" + string + "%");
Property.containsIgnoreCase(string);

Property.startsWith(string); // same as Property.like(string + "%");
Property.startsWithIgnoreCase(string);

Property.endsWith(string); // same as Property.like("%" + string);
Property.endsWithIgnoreCase(string);



> Variants of Property.like(..) : contains(..), startsWith(..), endsWith(..)
> --------------------------------------------------------------------------
>
>                 Key: CAY-1971
>                 URL: https://issues.apache.org/jira/browse/CAY-1971
>             Project: Cayenne
>          Issue Type: Improvement
>            Reporter: Andrus Adamchik
>            Assignee: Andrus Adamchik
>             Fix For: 4.0.M2
>
>
> http://markmail.org/message/cx7dzla46lcykkzq
> An idea that I had while analyzing boilerplate code of the client Cayenne 
> apps. An argument to Property.like(..) (or second argument to 
> ExpressionFactory.likeExp(..)) requires a full pattern to match against. So 
> people would often write their own utility code to wrap a String in "%" 
> signs. Cayenne can easily take care of this via a few extra methods. In 
> addition these new methods can do proper symbol escaping, making "like" much 
> safer to use. 
> Property.contains(string); // same as Property.like("%" + string + "%");
> Property.containsInsensitive(string);
> Property.startsWith(string); // same as Property.like(string + "%");
> Property.startsWithInsensitive(string);
> Property.endsWith(string); // same as Property.like("%" + string);
> Property.endsWithInsensitive(string);



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to