-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update operations do not update the td id correctly #18
Update operations do not update the td id correctly #18
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I just have a little comment. I don't like the name of the newly introduced method checkDuplicateThingDescriptionId
, it is verbose. What about assertUniqueID
?
I would say it is better to be verbose than vague.
|
Ok then I think we have a consensus here: I've also noticed that we have |
private async checkDuplicateThingDescriptionId(urn: string, id: string | undefined): Promise<void> { | ||
if (!id || id === urn) return; | ||
const idExist = await this.thingDescriptionRepository.exist({ where: { urn: id } }); | ||
if (idExist) throw new DuplicateIdException(id as string); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function signature could become clearer by renaming the parameters urn
and id
to something like currentId
and newId
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is great. Thanks for the work!
If possible, it would be important to add a couple of failing tests (for both the PUT and PATCH) when the client tries to change the TD id
to an existing one. Basically check the correct behavior of the checkDuplicateThingDescriptionId
in the respective two cases.
…ThingDescriptionId
…already existing id
Done in commit #2dc14bb . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last thing, update the contributing.md
with this new guideline. Then we can close also #19
To maintain consistency, I will open another branch to do it. That way, we have a 1-to-1 relationship between issues, branches, and PRs. |
Ok, I thought that in 55f7688 you updated also the other methods. Then it's ok as it is! |
When a TD is updated (PUT or PATCH), the
internalThingDescription
urn is updated as well. Additionally, there is an additional check to ensure that the new id is not a duplicated one. The new exception is: