alan-turing-institute / DTBase

A starting point from which digital twins can be developed.
MIT License
11 stars 4 forks source link

Error on conflicting insert differently from duplicate inserts #187

Open mhauru opened 7 months ago

mhauru commented 7 months ago

For inserting many things into the database, like sensors or locations, we do a check of was there a conflict on some unique constraint. If so, the backend API returns a response equivalent to "this thing already exists". But we should differentiate between whether the thing that caused the conflict is exactly what the user tried to insert, in which case all is fine, or is different, and thus should be an error.

This came up in a case where @rmward61 was trying to insert a sensor, but a sensor with the same unique identifier but of different type already existed in the database. The backend just sent a response saying "all good, we've already got your sensor in the db", which was misleading.