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

Bad doctrine LIKE condition when filter have set other db field than column #237

Open
foxycode opened this issue Nov 21, 2015 · 3 comments

Comments

@foxycode
Copy link
Contributor

I have doctrine QB which I use as model:

$queryBuilder = $dao->createQueryBuilder()
    ->select('item, actuarial, customer')
    ->from(ActuarialItem::class, 'item')
    ->innerJoin('item.actuarial', 'actuarial')
    ->innerJoin('actuarial.customer', 'customer');

I am creating column like this:

$grid->addColumnText('customer', 'Customer')
    ->setColumn('actuarial.customer.bName');

$grid->addFilterText('customer', 'Customer')
    ->setColumn('customer.bName');

When I try to filter by customer, bad DQL is constructed:

SELECT item, actuarial, customer 
FROM App\Model\Entities\ActuarialItem item 
INNER JOIN item.actuarial actuarial 
INNER JOIN actuarial.customer customer 
WHERE actuarial.type = :akwm0 AND (customer.bName LIKE :vvqz0 OR actuarial.customer.bName LIKE
:vvqz1) 
ORDER BY item.actuarialItemId DESC

Filter by actuarial.customer.bName does not work. I am not sure why is OR added for column field, maybe it could be fixed by using only setted filter field?

@o5
Copy link
Owner

o5 commented Nov 21, 2015

@foxycode: Are you sure, you pasted exactly same part of grid definition? Calling setColumn() after addColumnText() is not for filtering but for sorting.

@foxycode
Copy link
Contributor Author

@o5 When I change setColumn on column from actuarial.customer.bName to customer.bName, it will display error right after displaying grid. And you're right about sorting, it doesn't work too on customer column.

@foxycode
Copy link
Contributor Author

@o5 I created test from your examples here: https://github.com/foxycode/grido-examples
It gives me now another error that I have, maybe because of SQLite instead MySQL. Please look at it.

Test web is here: http://grido.liquid.sunfox.cz/inner/doctrine/?grid-sort[customer]=asc

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

No branches or pull requests

2 participants