Closed xmonader closed 5 years ago
I think in this case what should happen is that error is raised when the id does not correspond to the model.
Otherwise it just doesn't make sense and instead you should use get_by_name
@rkhamis problem is get
on model actually delegates the call to model.bcdb.get
which returns the object by auto incremented creation id
get
on model should return the object with respect to the model itself.
does get_by_name
assume that there's name
property on every model? or is created implicitly?
Fixed it by Raise error if we didn't have this id in our object model
Verified
1- Create any schema
schema_text = """@url = proj.human
name* = test-name """
2- bcdb = j.data.bcdb.get("test")
3- model = bcdb.model_get_by_schema(schema_text)
4- z = model.new()
, then z.save()
5- model.get(1)
--> this will get the model you just created
6- model.get(2)
this will throw an error since model with id=2 is not there
Branch: development commit: https://github.com/threefoldtech/jumpscaleX/commit/aec05fa188829dcc01f8d1fc1a69fe8c24a5f600
having multiple schemas and multiple objects from these schema
calling new gives the correct objct from schema proj.human while calling get(1) gets another object from another schema!
schemas