BOGUS – a bug in conventional / related()

Notice: This thread is very old.
petr.pavel
Member | 535
+
0
-

EDIT: It occurred to me to delete database cache and that made the malformed query go away.

Original post:

When using conventional reflection, a wrong query is built for related() call.

$event = $context->table('event')->get(2);
$event->related('question')->fetchAll();

Queries:

0.270 explain

SELECT `id`
FROM `event`
WHERE (`event`.`id` = 2)


ERROR

SELECT `id`, `event_id`, `Nette`\`Database`\`Table`\`ActiveRow``table_id`
FROM `question`
WHERE (`question`.`event_id` IN (2))


0.270 explain

SELECT *
FROM `question`
WHERE (`question`.`event_id` IN (2))

Yes, one get() and one related-fetchAll produces three queries, a correct query follows a malformed one.

Nette Framework 2.1.2 (revision 8065ce5 released on 2014–03–17)

Last edited by petr.pavel (2014-04-10 11:38)