[limb-issues] Created: (AR-4) Current implementation of AR does not allow to create single direction one-to-one relation. This should be possible.
Sergey Yudin (JIRA)
jira at limb-project.com
Mon Nov 20 16:45:33 MSK 2006
Current implementation of AR does not allow to create single direction one-to-one relation. This should be possible.
--------------------------------------------------------------------------------------------------------------------
Key: AR-4
URL: http://jira.limb-project.com/browse/AR-4
Project: ACTIVE_RECORD
Issue Type: Improvement
Reporter: Sergey Yudin
Current implementation of AR does not allow to create single direction one-to-one relation.
One describe one-to-one relation with 2 attrubutes in 2 classes: $_has_on and $_belongs_to, e.g.:
[code]
class PersonForTest extends lmbActiveRecord
{
protected $_has_one = array('social_security' => array('field' => 'person_id',
'class' => 'SocialSecurityForTest'));
}
class SocialSecurityForTest extends lmbActiveRecord
{
protected $_belongs_to = array('person' => array('field' => 'person_id',
'class' => 'PersonForTest'));
}
[/code]
There person_id field is stored in social_security_for_test db_table.
I need to create several single direction one-to-one relations like that I would describe like this:
[code]
class CatalogItem extends lmbActiveRecord
{
protected $_has_one = array('large_image' => array('field' => 'image_id',
'class' => 'Image'),
small_image' => array('field' => 'small_image_id',
'class' => 'Image'));
}
class Sertificate extends lmbActiveRecord
{
protected $_has_one = array('image' => array('field' => 'image_id'));
}
class Image extends lmbActiveRecord
{
}
[/code]
I want Image objects don't know anything about what objects are related to them.
We should "revert" our implementation of one-to-one relation that is storing key field in parent table (say in "person_for_test" table as in the first example) not in child table (say in "social_security_for_test" table).
There are some problems here:
1) $_belongs_to is used in one-to-many relations. If we "revert" one-to-one relation we will face problems with one-to-many relations. It seems we will need a new attribute say $_many_belongs_to that will work like the old $_belongs_to
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.limb-project.com/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the limb-issues
mailing list