Uniqueness of IDs
See original GitHub issueI’m submitting a
- bug report.
- feature request.
Current Behaviour:
For the purpose of the hydra-agent to identify every node in its graph uniquely and make it point to the right hydrus resource, it cannot rely on database’s primary keys as they may change as pk are dropped and substituted. So possibly we need a way to identify every resource instance uniquely in hydrus adn the agent. For example:
{
"@context": "/api/contexts/Drone.jsonld",
"@id": "/api/DroneCollection/2",
"@type": "Drone",
"DroneID": "2",
"MaxSpeed": "300",
"Sensor": "Temperature",
"State": {
"@type": "State",
"Battery": "81",
"Direction": "W",
"Position": "0.856901647439813,14.05823948684688",
"Speed": "100",
"Status": "Confirming"
},
"model": "xyz",
"name": "Drone 1"
}
If it happens that this instance is deleted and substituted by another drone (that is a different model or with different maxSpeed for example), it may happen that the same id “2” could be assigned to this new drone creating inconsistency between the data stored in the server and the referenced pk “2” stored in the agent.
Expected Behaviour:
Every instance has to be referenced by a unique id, possibly generated by hashing the values of certain properties in the instance
Discussed solution
We may need to add "hydra:required": true
for every properties in the Resource that may be considered part of a UniqueConstraint
, then make the model to create a UniqueConstraint on the properties specified as required. So the server and the client can generate the same checksum by using the values like md5(str({"@id": "...", "@type": "", "prop1": "value1", "prop2": "value2"}))
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (5 by maintainers)
Top GitHub Comments
@xadahiya Just my two cents! How about simply using the Python’s
uuid
module. It generates a unique ID everytime.Not every object will have a name property. You can see State or Area data for example. The properties can highly vary and the best way to tackle this is to use some of the object properties (“Required ones”) to generate the checksum.
Also, note that we have “required”, “writeonly” and “readonly” properties for each class in the APIDoc so it makes sense to implement that mechanism and use it to generate unique IDs or checksums.