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
It seems wrong to have to change a "regular" ternary relationship for a classical Entity with onr Primary key and userId, sessionId, institutionId as foreign keys, which can be null.
Why can't a keys like (userIdValue, null, institutionIdValue), (userIdValue, sessionId, institutionIdValue), (null, null, institutionIdValue)... as long as the composite key stay unique
Did i miss something in the doc, is it a limitation or is is a real bug ?
Thank you
The text was updated successfully, but these errors were encountered:
CPASimUSante
changed the title
Impossible to have part of a composite key null in a ternary relationship ?
Impossible to have part of a composite key to be null in a ternary relationship ?
Aug 24, 2017
@CPASimUSante Doctrine ORM does not allow nor support NULL for primary key fields. If a field is an identifier, then it should be forced to be NOT NULL by the ORM.
A unique index where all key columns must be defined as NOT NULL. If they are not explicitly declared as NOT NULL, MySQL declares them so implicitly (and silently). A table can have only one PRIMARY KEY. The name of a PRIMARY KEY is always PRIMARY, which thus cannot be used as the name for any other kind of index.
If you do not have a PRIMARY KEY and an application asks for the PRIMARY KEY in your tables, MySQL returns the first UNIQUE index that has no NULL columns as the PRIMARY KEY.
In other engines, a primary key with nullable fields would also make no sense, because NULL is not used for uniqueness comparison (as it cannot be compared to other values), so you may end up having two records with a PK (1, 2, NULL), even though you have a primary key set on these 3 columns.
Not to reopen, but as a side note, NULL can not indeed be compared to a value, but it can be checked : null or not null, which does 2 states => values possible. But i understand it would be a different kind of check...
I have an entity that holds relation with 3 entities Session, User and Institution.
but when i try to generate the schema, i have :
the three part of the key have NOT NULL even if i add explicitly nullable=true...
i've validated the schema with a app/console doctrine:schema:validate and it's OK
I've read the doc for ID annotation
and
those for join column with nullable
Finally , I'm not sure to understand the implication of "General Considerations" part for the composite keys in the doc
It seems wrong to have to change a "regular" ternary relationship for a classical Entity with onr Primary key and userId, sessionId, institutionId as foreign keys, which can be null.
Why can't a keys like (userIdValue, null, institutionIdValue), (userIdValue, sessionId, institutionIdValue), (null, null, institutionIdValue)... as long as the composite key stay unique
Did i miss something in the doc, is it a limitation or is is a real bug ?
Thank you
The text was updated successfully, but these errors were encountered: