Skip to content
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

Crash on Inspector with belongs-to relation #147

Open
smeeckaert opened this issue Feb 2, 2015 · 0 comments
Open

Crash on Inspector with belongs-to relation #147

smeeckaert opened this issue Feb 2, 2015 · 0 comments

Comments

@smeeckaert
Copy link
Collaborator

When using an Inspector with a custom query using a belongs-to relation the controller will create a query using wrong aliases resulting in a crash.

Config example:

return array(
    'model' => 'Model_With_BelongsTo',
    'query' => array(
        'model'    => 'Model_With_BelongsTo',
       'related' => array('relation'),
        'callback' => function ($query) {
                return $query->where('relation.field', 1);
            }

    ),
    'input' => array(
        'key' => 'id',
    )
);

Will create something similar to

SELECT COUNT(DISTINCT `t0`.`id`) AS count_result,
`t1`.`id` AS `t1_c0`,`t1`.`other_fields_from_t0` AS `t1_c1`,
`t1`.`t1_real_fields` as `t1_c2`
FROM `table_0` AS `t0`
LEFT JOIN `table_2` AS `t1` ON (`t0`.`rel_id` = `t1`.`id`)
WHERE `t0`.`id` = 1

The where is executed on the wrong table and half the fields are selected on the wrong alias too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant