Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

HasMany 'column' value is not setting the foreign key #67

Open
creatoro opened this issue Jan 19, 2010 · 1 comment
Open

HasMany 'column' value is not setting the foreign key #67

creatoro opened this issue Jan 19, 2010 · 1 comment

Comments

@creatoro
Copy link

The 'column' filed type can be used with HasMany fields to set the foreign key according to the readme. But if I get it right this isn't the case, as it uses 'model_id' as foreign key even when this value is set.

It seems this line is where a possible fix can be applied (I solved it by a simple if statement checking if the 'column' value is available and using it instead of $this->fk() if so):

http://github.com/shadowhand/sprig/blob/master/classes/sprig.php#L355

@banks
Copy link

banks commented Jan 23, 2010

Foreign key handling is generally not written to support non-standard foreign keys in Sprig. For example the assumtion (by each model having one fk() method) that the foreign key for a given model is the same in all other relationships is a bad one - you can't have a model that relates to two users, one as an author and one as an editor for example.

This and other things I have attemptes to address in my foreign_field branch.

Hopefully my (or another) approach will be used in Sprig core to solve these issues soon.

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

No branches or pull requests

2 participants