Closed podolinek closed 4 years ago
Since the fix can cause a BC break, I will patch version 3.1.
Hello, I have a similar issue.
I have an region
table with foreign key to a district
table. Both tables have code
column as primary key.
Now, when I iterate over regions and in every iteration I do the ref()
call to get its district, Nette automatically optimizes this repeating query to call a database only once and get all the districts.
Resulting query in intermediate form looks like this: SELECT * FROM `district` WHERE (`code` IN (?))
However, after preprocessing the query changes to this: SELECT * FROM `district` WHERE (`code` IN ((?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)))
. Please notice the extra parentheses. This causes MySQL to compare int to a row and throws an error General error: 4078 Illegal parameter data types int unsigned and row for operation '='
.
@dg Do you have any idea what causes the issue? I have been using nette/database for many years now and I haven't had any problems so far. Now I got stuck in this simple usecase and I am not able to solve it.
I am using latest version 3.1.5.
Could you create a working minimal example? Just the database dump and the code that causes the error.
@dg While creating minimal example and comparing backtraces, I found it was indeed my error. In one middleware function I forgot to unpack arguments, which caused additional layer of array, which resulted in extra parentheses.Thank you for your assistance.
Nette database 2.4.9 translates query code
into query
Query with placed IN at beginning is ok.