I apologize for such a late reply. I am new to mail groups and all.

Thank you very much for pointing this out. Guess it's easy to forget 
querysets are lazy ;)

On Saturday, 16 February 2019 00:49:19 UTC+5:30, Simon Charette wrote:
>
> I meant, and *not* "Building a queryset" in my previous reply.
>
> Le vendredi 15 février 2019 14:18:27 UTC-5, Simon Charette a écrit :
>>
>> Hello Philoj,
>>
>> > Does this mean that the above code example will raise 
>> TransactionManagementError...
>>
>> It won't cause a TransactionManagementError because of the lazy nature of 
>> queryset.
>>
>> Even if the QuerySet.select_for_update() call is made outside of the 
>> atomic block the query
>> is really only executed when entries are iterated over.
>>
>> Given the documentation clearly mentions "*Evaluating* a queryset" and 
>> "Building a queryset"
>> I don't think it's worth amending it.
>>
>> Cheers,
>> Simon
>>
>> Le vendredi 15 février 2019 07:40:51 UTC-5, Philoj Johny a écrit :
>>>
>>> In the documentation for select_for_update 
>>> <https://docs.djangoproject.com/en/2.1/ref/models/querysets/#select-for-update>,
>>>  
>>> given code example is:
>>>
>>> from django.db import transaction
>>> entries = Entry.objects.select_for_update().filter(author=request.user)with 
>>> transaction.atomic():
>>>     for entry in entries:
>>>         ...
>>>
>>> At the same time, below in the description it says that:
>>>
>>> *Evaluating a queryset with select_for_update() in autocommit mode on
>>> backends which support SELECT ... FOR UPDATE is a
>>> TransactionManagementError 
>>> <https://docs.djangoproject.com/en/2.1/ref/exceptions/#django.db.transaction.TransactionManagementError>
>>>  error because the
>>> rows are not locked in that case.*
>>>
>>> *Does this mean that the above code example will raise 
>>> **TransactionManagementError , since the select_for_update_query is 
>>> evaluated outside atomic block?*
>>>
>>>
>>> *(I have'nt actually tried this out yet, will soon. I think may be a 
>>> correction is required in the code example)*
>>>
>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
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/f0f584df-f9a5-42a9-a798-9f712ee1d07f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to