threefoldtecharchive / jumpscaleX_archived

Apache License 2.0
1 stars 6 forks source link

fix #797

Closed zgorizzo69 closed 4 years ago

zgorizzo69 commented 4 years ago

Resolves: https://github.com/threefoldtech/jumpscaleX/issues/{TICKET_ID}

Description

Summary of the changes.

Checklists

Before asking for approval

zgorizzo69 commented 4 years ago

Zgo Rizzo: working on the unique data bug it seems that when we save a model with unique data it retrieve a previous model ...

I don't get it I am trying to save a new object with a unique property "name" equal to a previous object (this save test should fail as it is unique) so i don't have an id but then in the save fucntion (from jsxobject) we assign the id from the previous object that matches the name ???

so i end up with the same object

schema=""" &name* = "" (S) """

schema_obj = model.new() schema_obj.name = name schema_obj.save() # id=8 schema_obj2 = model.new() schema_obj2.name = schema_obj.name # id=None schema_obj2.save() # id=8 ! ?

I prefer to discuss it with you before changing anything in JSXObject as this can have some serious side effects

in the save fucntion this line " self._ddict_hr # to trigger right serialization" will replace the self data with the data from the object id 8

my proposition is as follow

else: self.id = r[0].id self._ddict_hr # to trigger right serialization if self._data == r[0]._data: return self # means data was not changed else: # means data is not the same raise j.exceptions.Input(msg)