You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in Versioned Mixin:
If versioned model instance is in transaction atomic(): and if setattr( instance, version_field, new_version) happens and ConcurrentUpdate is raised, python object is changed, but db is reverted. So: setattr should happen only if not raising ConcurrentUpdate
Maybe:
`
to_change = {}
for i, value_tuple in enumerate(values):
if isinstance(value_tuple[0], VersionField):
assert old_version == value_tuple[2]
values[i] = (
value_tuple[0],
value_tuple[1],
value_tuple[2] + 1,
)
to_change[ version_field.attname] = old_version + 1
#setattr(self, version_field.attname, old_version + 1)
updated = super(VersionedMixin, self)._do_update(
base_qs=base_qs.filter(**{version_field.attname: old_version}),
using=using,
pk_val=pk_val,
values=values,
update_fields=update_fields if values else None, # Make sure base_qs is always checked
forced_update=forced_update
)
if not updated and base_qs.filter(pk=pk_val).exists():
raise ConcurrentUpdate
for vf_attname, new_version in to_change.items():
setattr( self, vf_attname, new_version)
return updated
`
The text was updated successfully, but these errors were encountered:
YasenKalinin
changed the title
setattr should happen only if updated
setattr should happen only if ConcurentUpdate is not raised
Jan 22, 2019
in Versioned Mixin:
If versioned model instance is in transaction atomic(): and if setattr( instance, version_field, new_version) happens and ConcurrentUpdate is raised, python object is changed, but db is reverted. So: setattr should happen only if not raising ConcurrentUpdate
Maybe:
`
`
The text was updated successfully, but these errors were encountered: