orm
orm copied to clipboard
Two similar entity properties generated in runtime/cache/cycle.php
If u manually specify name of inner key in a relation
/**
* @Cycle\Column(type="bigPrimary")
*/
protected int $id;
/**
* @Cycle\Column(type="bigInteger", nullable=true)
*/
private ?int $parentId;
/**
* @Cycle\Relation\BelongsTo(target="ProductCategory", innerKey="parent_id", nullable=true, fkAction="SET NULL")
*/
private ?ProductCategory $parent;
You get this
'id' => 'id',
'parentId' => 'parent_id',
'parent_id' => 'parent_id',
Expected result
'id' => 'id',
'parentId' => 'parent_id',
The documentation says:
innerKey-- Inner key in source entity. Defaults to{relationName}_{outerKey}
Therefore, for your case it will be more correct like this:
/**
* @Cycle\Relation\BelongsTo(target="ProductCategory", innerKey="parentId", nullable=true, fkAction="SET NULL")
*/
private ?ProductCategory $parent;
But be careful: in your example, the settings for the $parentId field will be different from those implied for the BelongsTo relation. Among other things, the BelongsTo relaction sets the default value to NULL for the innerKey field.