Skip to content

Conversation

tuupola
Copy link
Contributor

@tuupola tuupola commented Sep 30, 2013

Fixes #364 primary_key support when using belongs_to relationship. 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);

generated query before the patch is:

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

after the patch it will be:

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

Fixes primary_key support when using belongs_to relationship (#364).
@tblanchard tblanchard mentioned this pull request Sep 30, 2013
@jpfuentes2
Copy link
Owner

Also great and similar to #368. Do you think you could add a quick test to this?

@tuupola
Copy link
Contributor Author

tuupola commented Nov 14, 2013

I actually looked at writing the tests. However I had hard time trying to understand the models and how to write the actual tests. I do know how to use PHPunit though :)

This pull request was closed.
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

Successfully merging this pull request may close these issues.

$belongs_to ignores primary_key option
3 participants