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

Fixed DoctrineDataSource filtering #447

Closed
wants to merge 1 commit into
base: master
from

Conversation

3 participants
@foxycode
Copy link

foxycode commented Jan 20, 2017

When you have filter with native and custom condition, native condition uses postional parameter in QueryBuilder and custom condition must use named parameter. For example:

public function createConditionYear(QueryBuilder $queryBuilder, $value)
{
	if ($value) {
		$queryBuilder->andWhere('actuarial.createYear = :year')
			->setParameter('year', $value);
	}
}

With another native condition, result in DQL would be something like this:

SELECT actuarial
FROM Actuarial
WHERE actuarial.createYear = :year AND actuarial.type = ?0

If native condition is evaluated after named condition, doctrine rewrites first value, in this case year and second value is never set (error is thrown). When named conditions are evaluated after positional, everything works ok.

Better approach could be generating named aliases instead of positional arguments in native conditions.

@juniwalk

This comment has been minimized.

Copy link
Collaborator

juniwalk commented Jan 20, 2017

@paveljanda What do you think of this?

@paveljanda

This comment has been minimized.

Copy link
Member

paveljanda commented Jan 20, 2017

@juniwalk Generated aliases are not that big change of code. If it won't cause any BC break and fix that issue, sure, why not.

@foxycode Can doctrine query builder take as named parameter a integer? ( :$p instead of ?$p)

@juniwalk

This comment has been minimized.

Copy link
Collaborator

juniwalk commented Jan 20, 2017

@paveljanda I am used to use named parameters everywhere so I did not encounter this issue yet. However we can switch to using generating named parameters in data-source too. We could use pattern for example :param$p

@juniwalk juniwalk closed this in cd793e9 Mar 13, 2017

juniwalk added a commit that referenced this pull request Mar 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.