Open nikitamaximov opened 5 years ago
That's interesting. Where does the error occur in the code? A backtrace would be even better.
I'm fairly new to js, not quite sure how to trace. But i have a feeling it's a cakephp issue (at the bottom), since something calls function to check if it's a valid integer type
Actual Exception
{
"message": "Cannot convert value of type `string` to integer",
"url": "\/BigDatas?draw=2\u0026amp;columns%5B0%5D%5Bdata%5D=id\u0026amp;columns%5B0%5D%5Bname%5D=\u0026amp;columns%5B0%5D%5Bsearchable%5D=true\u0026amp;columns%5B0%5D%5Borderable%5D=true\u0026amp;columns%5B0%5D%5Bsearch%5D%5Bvalue%5D=\u0026amp;columns%5B0%5D%5Bsearch%5D%5Bregex%5D=false\u0026amp;columns%5B1%5D%5Bdata%5D=amount\u0026amp;columns%5B1%5D%5Bname%5D=\u0026amp;columns%5B1%5D%5Bsearchable%5D=true\u0026amp;columns%5B1%5D%5Borderable%5D=true\u0026amp;columns%5B1%5D%5Bsearch%5D%5Bvalue%5D=\u0026amp;columns%5B1%5D%5Bsearch%5D%5Bregex%5D=false\u0026amp;columns%5B2%5D%5Bdata%5D=unit\u0026amp;columns%5B2%5D%5Bname%5D=\u0026amp;columns%5B2%5D%5Bsearchable%5D=true\u0026amp;columns%5B2%5D%5Borderable%5D=true\u0026amp;columns%5B2%5D%5Bsearch%5D%5Bvalue%5D=\u0026amp;columns%5B2%5D%5Bsearch%5D%5Bregex%5D=false\u0026amp;columns%5B3%5D%5Bdata%5D=stir\u0026amp;columns%5B3%5D%5Bname%5D=\u0026amp;columns%5B3%5D%5Bsearchable%5D=true\u0026amp;columns%5B3%5D%5Borderable%5D=true\u0026amp;columns%5B3%5D%5Bsearch%5D%5Bvalue%5D=\u0026amp;columns%5B3%5D%5Bsearch%5D%5Bregex%5D=false\u0026amp;order%5B0%5D%5Bcolumn%5D=0\u0026amp;order%5B0%5D%5Bdir%5D=asc\u0026amp;start=0\u0026amp;length=10\u0026amp;search%5Bvalue%5D=z\u0026amp;search%5Bregex%5D=false\u0026amp;_=1560767739335",
"code": 500,
"file": "\/var\/www\/myapp2\/vendor\/cakephp\/cakephp\/src\/Database\/Type\/IntegerType.php",
"line": 64
}
First Exception DOMException: Failed to execute 'querySelectorAll' on 'Document': '.panel-summary:contains(xhr)' is not a valid selector.
Stack Trace
Searching for 'z' when all 4 columns are searchable
/src/Database/ValueBinder.php (line 148)
[
':c0' => [
'value' => 'z',
'type' => 'integer',
'placeholder' => 'c0'
],
':c1' => [
'value' => 'z%',
'type' => 'string',
'placeholder' => 'c1'
],
':c2' => [
'value' => 'z',
'type' => 'integer',
'placeholder' => 'c2'
],
':c3' => [
'value' => 'z%',
'type' => 'string',
'placeholder' => 'c3'
]
]
Searching for 'z' when only 2 (string) columns are searchable
/src/Database/ValueBinder.php (line 148)
[
':c0' => [
'value' => 'z%',
'type' => 'string',
'placeholder' => 'c0'
],
':c1' => [
'value' => 'z%',
'type' => 'string',
'placeholder' => 'c1'
]
]
The binded value is being casted as the type of the db column it's searching through, just not sure why the datatables search function goes through ValueBinder
Uou!
In Component...
private function _addCondition($column, $value, $type = 'and') { ... if (strpos(strtolower($comparison), 'like') !== false) { ... } else if (!($comparison === '=' && is_numeric($value))) {//I ADDED THIS AND WORKED! return; }
Uou!
In Component...
private function _addCondition($column, $value, $type = 'and') { ... if (strpos(strtolower($comparison), 'like') !== false) { ... } else if (!($comparison === '=' && is_numeric($value))) {//I ADDED THIS AND WORKED! return; }
I think the comparison === might be overkill at this moment. You already know that it's not LIKE. So a check if the value is not numeric only the is_numeric would be enough.
This is a weird one, clearly I'm doing something wrong, just wondering if you can point me to the right direction. When i let my INT columns be searchable, the search field doesn't accept string values (Err: Cannot convert value of type
string
to integer), however when I specify my INT columns with'searchable' => false
and I mean all of them, the string columns become searchable, but not the int columns obviously.My Controller
My Template