Thanks! For the response.

In that scenario, what would explain old_copy (in the code example) having 
updated values and not the stale ones from the DB.

Postgres Doc Reference: 
https://www.postgresql.org/docs/current/static/sql-set-transaction.html




On Wednesday, 31 January 2018 16:41:16 UTC+5:30, Jason wrote:
>
> It seems that your inference is correct
>
> https://stackoverflow.com/a/41522066/214892 
> <https://www.google.com/url?q=https%3A%2F%2Fstackoverflow.com%2Fa%2F41522066%2F214892&sa=D&sntz=1&usg=AFQjCNH5G1ZX5ELAIgVANGA39tXOTaMogA>
>
> On Wednesday, January 31, 2018 at 12:54:29 AM UTC-5, Me Sulphur wrote:
>>
>> When ATOMIC_REQUESTS=True is set, are ORM signals - post_save and 
>> pre_save - also executed within the transaction?  Per my inference, they 
>> seem be to a part of the transaction. 
>>
>> Assuming my inference is correct, then consider the following code 
>>
>>
>> @receiver(post_save, sender=MyModel) 
>> def log_and_notify_change(sender, instance, created, **kwargs): 
>>      if not created: 
>>          old_copy = MyModel.objects.get(id=instance.id) 
>>          diff_fn(old_copy, new_copy) 
>>
>>
>> Since Postgresql only supports READ COMMITTED, implying that reading a 
>> row inside a transaction should always return the older value. However, 
>> in the code above, old_copy always has updated values meaning that the 
>> signal was executed outside transaction (after it was committed.) 
>>
>> Is this the correct behavior? I tried to reason by looking at the code 
>> but again not sure. 
>>
>> Thanks! 
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1a4ca355-be4a-441e-a858-6ab478be9766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to