-
-
Notifications
You must be signed in to change notification settings - Fork 863
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
Fix: Problem to use partial searchFilter with an integer as input. #4356
Conversation
Hello, |
SQL Server does not automatically cast an integer to a string in the concatenation with + method (...WHERE field1 LIKE :param1 + :param2) The CONCAT function is not available before the 2012 version. I so simply force the casting when the searchFilter is not of type exact.
9a75b31
to
6622fcd
Compare
@alanpoulain Thanks . No problem with tests : $ vendor/bin/simple-phpunit --stop-on-failure -vvv tests/Bridge/Doctrine/Orm/Filter/SearchFilterTest.php Runtime: PHP 8.0.6 Testing ApiPlatform\Core\Tests\Bridge\Doctrine\Orm\Filter\SearchFilterTest Time: 00:11.159, Memory: 78.00 MB OK (71 tests, 211 assertions) Legacy deprecation notices (102) |
@alanpoulain : Hello, just to be sure. Is everything ok for my PR or is there anything I forgot to do ? Regards, |
I do think that you should implement your own filter as we don't want to support older version no? |
@soyuka Sorry, this info was confusing. We have recent version, it’s not the problem. |
@alanpoulain , @soyuka Hello ! Thank you ! |
Hi @hogren , I used the following workaround: I set filter strategy to It's not really good solution but it works! |
@alessandrofilira Hello, sorry for the long time of silence. I have never seen your answer. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
SQL Server does not automatically cast an integer to a string in
the concatenation with + method (...WHERE field1 LIKE :param1 + :param2)
So there is an SQL Server error when we try to enter "1" in a partial filter :
An exception occurred while executing 'SELECT […] WHERE b0_.label LIKE ('%' + ? + '%') ORDER BY […]' with params [1]:\n\nSQLSTATE [22018, 245]: [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Conversion failed when converting the varchar value '%' to data type int.
The CONCAT function is not available before the 2012 version.
I so simply force the casting when the searchFilter is not of type exact.
About tests, I did not find your test suite. So don’t hesitate to give me the right procedure.
EDIT : After Alan Poulain message, I run tests without any problem.