Skip to content

$belongs_to ignores primary_key option #364

@tuupola

Description

@tuupola

With the following code:

class Car extends ActiveRecord\Model {
    static $belongs_to = array(
        array("alarm", "foreign_key" => "slug", "primary_key" => "slug")
    );
}

var_dump(Car::find($id)->alarm);

The generated query will be

SELECT * FROM `alarms` WHERE `id`='something' LIMIT 0,1

when it should be

SELECT * FROM `alarms` WHERE `slug`='something' LIMIT 0,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