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

Updated setParameters function for not replace all parameters #1224

Closed
wants to merge 1 commit into from

Conversation

uthopiko
Copy link

When you create QueryBuilder and you bind some parameters, if you use setParameters function after bind other parameters, previous parameters are removed(https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/QueryBuilder.php#L558). This would not be a problem if it was the same behaviour with the attribute $_parameterMappings (in ParserResult), but it's not the case, given that it keeps the number of parameters introduced, throwing an exception(https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query.php#L293). To prevent this, I've made it initialize the setParameters with the existing ones.

@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-3454

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

@Ocramius
Copy link
Member

setParameters is supposed to clear previously existing parameters...

@Ocramius Ocramius self-assigned this Dec 17, 2014
@uthopiko
Copy link
Author

Yes, but if you do setParameters after call setParameter or another setParameters, clears existing parameters, but not $_parameterMappings and throws exception

@stof
Copy link
Member

stof commented Dec 26, 2014

This change is a BC break. And a BC break in a BC layer is strictly forbidden (the goal of the BC layer is to emulate the old API, otherwise it is useless)

@guilhermeblanco
Copy link
Member

I somehow understand why you have parameter count discrepancies, but that's a potential flaw in your code.
The only situation I can imagine is when consuming a DQL providing an IN with an array parameter. When being parsed, this IN becomes N bindable parameters, but your setParameters() call may alter this number.
To solve this, you need to call getQuery() again after you do your new setParameters().

Closing this issue, because your proposed solution is a BC break and cannot be done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants