Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison like/notlike support #1219

Open
wants to merge 1 commit into
base: old-prototype-3.x
Choose a base branch
from

Conversation

Fedik
Copy link
Contributor

@Fedik Fedik commented Dec 10, 2014

Support Comparison::LIKE and Comparison::NOTLIKE additionally to doctrine/collections#50

as alternative for #1150

@doctrinebot
Copy link

Hello,

thank you for creating this pull request. I have automatically opened an issue
on our Jira Bug Tracker for you. See the issue link:

http://www.doctrine-project.org/jira/browse/DDC-3446

We use Jira to track the state of pull requests and the versions they got
included in.

@stof
Copy link
Member

stof commented Dec 10, 2014

The usage of the constants to define the array would bump the requirement on doctrine/collections. Couldn't you use the value of the constant instead (eventually putting a comment with the constant in it), so that it works fine for older versions of doctrine/collections too (people would oviously not be passing the LIKE operator if they don't have it, but it would not break things for other operators)

@stof
Copy link
Member

stof commented Dec 10, 2014

another thing which is necessary (but probably as a separate PR) is fixing the SQL conversion of the CONTAINS operator (it needs to escape the placeholders in the value)

@Fedik
Copy link
Contributor Author

Fedik commented Dec 10, 2014

sorry, I not very understand your first suggestion

about second, I think it out of scope for current pull,
fix the CONTAINS better separately, also I not sure how to do it .. first thinking is use preg_replace, but then better stay as is 😄

@stof
Copy link
Member

stof commented Dec 26, 2014

My first suggestion is to write the code this way:

    'LIKE' => 'LIKE %s', // Comparison::LIKE
    'NOTLIKE' => 'NOT LIKE %s', // Comparison::NOT_LIKE

This way, it will still be possible to use the ORM with older versions of Doctrine Collections which does not have these constants.

For CONTAINS, the fix is to escape placeholders in the value when building the SQL parameters, so that a % in the value matches only a %

Base automatically changed from master to old-prototype-3.x February 23, 2021 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants