Skip to content
Snippets Groups Projects
Commit d7810f8a authored by Bastien Abadie's avatar Bastien Abadie
Browse files

Merge branch 'stale-read-create-element' into 'master'

Fix stale read for existing zones on CreateElement

See merge request !1056
parents 45ac28c1 7d578f0a
No related branches found
No related tags found
1 merge request!1056Fix stale read for existing zones on CreateElement
...@@ -399,10 +399,15 @@ class ElementCreateSerializer(ElementLightSerializer): ...@@ -399,10 +399,15 @@ class ElementCreateSerializer(ElementLightSerializer):
# - use .only('id') to load only the id # - use .only('id') to load only the id
# This works because of the unique constraint on image_id + polygon # This works because of the unique constraint on image_id + polygon
try: try:
zone = Zone.objects.filter( zone = Zone \
image_id=image.id, .objects \
polygon=polygon .using('default') \
).only('id').get() .filter(
image_id=image.id,
polygon=polygon
) \
.only('id') \
.get()
except Zone.DoesNotExist: except Zone.DoesNotExist:
zone = image.zones.create(polygon=polygon) zone = image.zones.create(polygon=polygon)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment