Open sveneberth opened 2 months ago
Maybe we can check this in getUniquePropertyIndexValues
like:
def getUniquePropertyIndexValues(self, skel: 'viur.core.skeleton.SkeletonInstance', name: str) -> list[str]:
val = skel[name]
if self.compute:
match self.compute.interval.method:
case ComputeMethod.OnWrite:
val = self._compute(skel, name)
case ComputeMethod.Lifetime:
now = utils.utcNow()
last_update = \
skel.accessedValues.get(f"_viur_compute_{name}_") \
or skel.dbEntity.get(f"_viur_compute_{name}_")
if not last_update or last_update + self.compute.interval.lifetime < now:
val = self._compute(skel, name)
case ComputeMethod.Once:
if name not in skel.dbEntity:
val = self._compute(skel, name)
if val is None:
return []
return self._hashValueForUniquePropertyIndex(val)
I have these bones in a Skeleton:
Now I want to ensure there's at least one skeleton per permutation of the values:
for example
can exist together. But you should not able to add
because there's already an entry (
ìd: 1
) with{name: "foo", module: "file"}
.I tried to create a composition of these bones with a compute bone.
But this doesn't cause a client-error in
fromClient
and fails only in the skeleton toDB transaction:Does anyone has an idea how I can simplify this / enforce a client error?