Open gam6itko opened 1 year ago
UPDATED the workaround for this case.
class User {
#[Cycle\Column(type: 'primary')]
private ?int $id = null;
#[Cycle\Relation\HasOne(target: UserOneLove::class, outerKey: 'user_id', indexCreate: false)]
private UserOneLove $oneLove;
}
class UserOneLove {
#[Cycle\Column(type: 'primary', name: 'user_id')]
private ?int $user_id = null;
#[Cycle\Relation\BelongsTo(target: User::class, innerKey: 'user_id', indexCreate: false)]
private User $user;
}
In your examples innerKey and outerKey should contain property name, not column name
I actually use this sometimes and it works fine. You still do need to declare the field on the child entity as it's a separate column, I don't see a problem with that.
Also, keep in mind that starting from PHP 8.2 dynamic properties will start giving you a headache, so it's better to have them declared explicitly.
I have an idea!
It would be very useful to use one field instead of two like in Doctrine.
Something like...