collections
collections copied to clipboard
Improve Comparison::CONTAINS: allow to use the SQL wildcard characters
This pull additional to doctrine/doctrine2#1150
And allow to use the SQL wildcard characters %
and _
for Comparison::CONTAINS
Allow to build the contains
expressions like:
Criteria::expr()->contains('myField', 'some string%');
Criteria::expr()->contains('myField', '%some string');
Criteria::expr()->contains('myField', '%10\%'); // search for 10% at end of the string
Criteria::expr()->contains('myField', 's_m_ string');
Note: this changes can make b/c issue for existing Comparison::CONTAINS
expressions, when someone use not escaped %
, _
.
I'm -1 for this:
- it makes the API harder to use
- it is a BC break
If we want wilcard support, the only way is to uuse a new operator. We cannot change existing ones
I agree, that a new operator would be a better solution, but my knowledge not enough to do that, so I did what I can ...
This is probably an actual like
/ilike
operator to be introduced
@Ocramius I think if like/notlike #50 will be accepted then current issue can be closed ... I keep it open as get not to much feedback about like/notlike
The current issue cannot be closed even if #50 is accepted. this PR is about fixing a bug in the current implementation, where the SQL generated for CONTAINS is not consistent with the behavior of Doctrine Common.
Thanks for clearing that up, @stof - missed that part completely while responding to the issue today.
Marco Pivetta
http://twitter.com/Ocramius
http://ocramius.github.com/
On 22 January 2015 at 11:38, Christophe Coevoet [email protected] wrote:
The current issue cannot be closed even if #50 https://github.com/doctrine/collections/pull/50 is accepted. this PR is about fixing a bug in the current implementation, where the SQL generated for CONTAINS is not consistent with the behavior of Doctrine Common.
— Reply to this email directly or view it on GitHub https://github.com/doctrine/collections/pull/45#issuecomment-71001493.
@stof I thought doctrine/doctrine2#1150 about SQL .. (where you told about unescaped value)