Skip to content

BelongsTo column name is not working #104

@khairilanuar

Description

@khairilanuar

After upgrade to Jelly for Kohana 3.2.

I cannot use different column name for a belongsto field as in documentation

In my company model (model/company.php) I have this. Please note I have a column name 'status_id' which hold a foreign key of member_status table;

...
'id' => Jelly::field('primary');
'status' => Jelly::field('belongsto', array('column' => 'status_id', 'foreign' => 'member_status')),
...

while in my member_status model (model/member/status.php), I have this;

...
'id' => Jelly::field('primary');
'members'  => Jelly::field('hasmany'),
...

sample query;

$members = Jelly::query('company')->select();
$member_status_id = $member->status->id;

I receive this error when try to access $member_status_id, because Jelly still using 'member_status_id' as column name even when I set it to 'status_id' in the company model;

Database_Exception [ 1054 ]: Unknown column 'companies.company_status_id' in 'where clause' [ SELECT `companies`.`id` AS `id`, `companies`.`name` AS `name`, `companies`.`code` AS `code`, `companies`.`no_of_staff` AS `no_of_staff`, `companies`.`paid_up_capital` AS `paid_up_capital`, `companies`.`msc_status` AS `msc_status`, `companies`.`created` AS `created`, `companies`.`modified` AS `modified`, `companies`.`status_id` AS `status` FROM `companies` AS `companies` WHERE `companies`.`company_status_id` = 1 ]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions