Mondego/spacetime

Primary keys being ignored and set to UUIDs

Opened this issue · 1 comments

diva commented

If I have this model:

@pcc_set
class OSMModelRequest(object):
    @primarykey(int)  <----------------------
    def ReqId(self):
        return self._ReqId

    @ReqId.setter
    def ReqId(self, value):
        self._ReqId = value

    def __init__(self, id, sender):
        self.ReqId = id

the objects at the store acquire a UUID as ReqId.

If I change the model to this, the primary key is fine:

@pcc_set
class OSMModelRequest(object):
    @primarykey(str)  <----------------------
    def ReqId(self):
        return self._ReqId

    @ReqId.setter
    def ReqId(self, value):
        self._ReqId = value

    def __init__(self, id, sender):
        self.ReqId = id


Only strings are allowed as primary keys for now. Since primary keys are used for dictionary checking and serializing dictionaries only works if keys are strings, it is necessary that all backend primary keys be strings. However it is perfectly possible to simply convert from any object to string and vice-versa to allow for other types.