Marantesss / glass-base

MIT License
0 stars 0 forks source link

Entities with empty/invalid NIF cause problems with contract-entity relation tables #5

Open Marantesss opened 3 years ago

Marantesss commented 3 years ago

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), 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

Steps to reproduce

  1. N/A

Additional details / screenshots

image

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