You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For example, wanting to use UUID v6 as a primary key. What happens when you set up your entities and repositories appropriately for this? Well, it almost works, but then it breaks.
Due to the way parable-php/orm is written, for inserts, the primary key is always removed from the value set, to allow the sql flavor you're using to auto-generate it. Which, obviously, is a terrible idea when you're using custom primary keys.
There's multiple ways of approaching a fix for this, which is either specific about fixing custom primary keys, or offers a more generic way of tying into the insert process (perhaps even update, delete?).
Specific: Introduce HasCustomPrimaryKey and skip the id auto-removal upon insert if set.
Generic: Introduce beforeInsert(array $values) and possibly more. If implemented, would it just skip the default logic?
What if both?
interface HasCustomPrimaryKey {
protected function beforeInsert(array $values): array;
}
The text was updated successfully, but these errors were encountered:
For example, wanting to use UUID v6 as a primary key. What happens when you set up your entities and repositories appropriately for this? Well, it almost works, but then it breaks.
Due to the way parable-php/orm is written, for inserts, the primary key is always removed from the value set, to allow the sql flavor you're using to auto-generate it. Which, obviously, is a terrible idea when you're using custom primary keys.
There's multiple ways of approaching a fix for this, which is either specific about fixing custom primary keys, or offers a more generic way of tying into the insert process (perhaps even update, delete?).
Specific: Introduce
HasCustomPrimaryKey
and skip the id auto-removal upon insert if set.Generic: Introduce
beforeInsert(array $values)
and possibly more. If implemented, would it just skip the default logic?What if both?
The text was updated successfully, but these errors were encountered: