Ticket #279 (closed enhancement: fixed)
Add support for one-to-one relationships.
| Reported by: | hans | Owned by: | hans |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.3 |
| Component: | Generator | Version: | devel |
| Severity: | normal | Keywords: | one-to-one relationship |
| Cc: |
Description (last modified by hans) (diff)
Add support for one-to-one relationships in the builder classes. One-to-one relationships can be represented in an RDBMS by having the foreign key also be the primary key of a table.
<table name="users" phpName="User"> <column name="id" type="INTEGER" primaryKey="true" autoIncrement="true"/> <!-- ... --> </table> <table name="profiles" phpName="Profile"> <column name="uid" type="INTEGER" primaryKey="true"/> <foreign-key foreignTable="users"> <reference local="uid" foreign="id"/> </foreign-key> <!-- ... --> </table>
Currently in Propel a User->Profiles() method would be generated, but clearly there can only be one profile per user, since uid is the primary key. So, we should expect instead to have a User->getProfile() for relationships defined in this way.
Note, this could also apply to composite fkey and pkey columns.
Change History
comment:2 Changed 4 years ago by hans
Added a basic implementation of this (only get method) in changeset:409
comment:3 Changed 4 years ago by hans
- Status changed from new to closed
- Resolution set to fixed
- Milestone changed from 2.0 to 1.3
Added full & tested implementation to 1.3 branch in changeset:498. See wiki:Documentation/1.3/Relationships for documentation.
comment:4 Changed 4 years ago by apinstein
So this will cause BC-breakage when upgrading existing apps, right? Just wanted to be sure that if so, it's documented in a BC note for 1.3 somewhere...
comment:5 Changed 4 years ago by hans
That's correct; this will cause BC-breakage if you are currently using one-to-one relationships in Propel. Thanks for the reminder; I added a section on this to the upgrading document: wiki:Documentation/1.3/Upgrading