When a foreign entity is contracted the nif column value MAY BE a single space string (" ") or a random string.
When 2 foreign entities share the same contract we get a database unique constraint violation. Because we used to have a composite key (entityNif, contractId), if entityNif = " " and contractId is the same this causes a constraint violation.
2.
It seems that some Portuguese entities have the same nif but different ids, this causes duplicate entities to be stored. And because of this we are using nif as an entity primary key.
However, this is not the case for foreign entities with a random nif value, because these values are not unique. Usually they are identified by their id, and in these cases we should store their id
Bug description
1.
When a foreign entity is contracted the
nif
column value MAY BE a single space string (" ") or a random string.When 2 foreign entities share the same contract we get a database unique constraint violation. Because we used to have a composite key (
entityNif
,contractId
), ifentityNif
= " " andcontractId
is the same this causes a constraint violation.2.
It seems that some Portuguese entities have the same
nif
but differentid
s, this causes duplicate entities to be stored. And because of this we are usingnif
as an entity primary key.However, this is not the case for foreign entities with a random
nif
value, because these values are not unique. Usually they are identified by theirid
, and in these cases we should store theirid
Steps to reproduce
Additional details / screenshots
Check out the
contracted
key: http://www.base.gov.pt/base2/rest/contratos/635915 Simtech entity: http://www.base.gov.pt/base2/rest/entidades/334915