Closed jbarberillo closed 8 years ago
I solved the problem adding and cast function(orocrm\doctrine-functions) to symfony 2 and changing the _addSearch function on DoctrineBuilder file of alidatatables
_addSearch function code: http://pastebin.com/35ZcW99g
Hello, I'm getting an error when I try to filter a field. The thing is that the error doesn’t happen with all fields. Seeing the AJAX response, there is an more explained error. Here is the AJAX response: [1] Doctrine\DBAL\DBALException: An exception occurred while executing 'SELECT count(s0.id) AS sclr0 FROM Subministrament s0 INNER JOIN Abonat a1 ON s0.abonatsubministrament = a1.id WHERE s0_.tipus LIKE ?' with params ["%Comercial%"]:
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: integer ~~ unknown LINE 1: ... s0_.abonatsubministrament = a1.id WHERE s0_.tipus LIKE $1
Edit: 12/02/2016 I'm still with the problem but I found more details about it. The problem is that field "s0.tipus" data type is integer and I'm trying to find a string. Well that's right but if I try to search a field that contains integer data type and I search for example the number 1 also fails and shows me the error below.
An exception occurred while executing 'SELECT count(s0.id) AS sclr0 FROM Subministrament s0 INNER JOIN Abonat a1 ON s0.abonatsubministrament = a1.id WHERE s0_.id LIKE ?' with params ["%1%"]:
SQLSTATE[42883]: Undefined function: 7 ERROR: operator does not exist: integer ~~ unknown LINE 1: ... ON s0_.abonatsubministrament = a1.id WHERE s0_.id LIKE $1 ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
That is because like cannot be used with integer fields but I'm trying to filter a integer from a table that has integer values in the fields. That is solved with a casting to the integer value as text but Doctrine 2 cannot do that. My question is, how can I filter a field that is integer data type using Ali DatatableBundle?