collections icon indicating copy to clipboard operation
collections copied to clipboard

Improve Comparison::CONTAINS: allow to use the SQL wildcard characters

Open Fedik opened this issue 10 years ago • 7 comments

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 %, _ .

Fedik avatar Oct 25 '14 11:10 Fedik

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

stof avatar Oct 27 '14 10:10 stof

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 ...

Fedik avatar Oct 27 '14 12:10 Fedik

This is probably an actual like/ilike operator to be introduced

Ocramius avatar Jan 22 '15 09:01 Ocramius

@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

Fedik avatar Jan 22 '15 10:01 Fedik

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.

stof avatar Jan 22 '15 10:01 stof

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.

Ocramius avatar Jan 22 '15 10:01 Ocramius

@stof I thought doctrine/doctrine2#1150 about SQL .. (where you told about unescaped value)

Fedik avatar Jan 22 '15 11:01 Fedik