Thanks, Tom. That does help.

On Wednesday, September 5, 2012 6:02:27 AM UTC-4, Tom Evans wrote:
>
> On Wed, Sep 5, 2012 at 1:45 AM, Yo-Yo Ma <baxters...@gmail.com<javascript:>> 
> wrote: 
> > restaurant = 
> > 
> Restaurant.objects.select_for_update().select_related('owner').get(name=u'Koala
>  
>
> > Kafe') 
> > 
> > Assuming the ``owner`` field points to a ``Person`` table, will the 
> > aforementioned query prevent the ``Person`` row returned for the Koala 
> > Kafe's owner from being saved in a separate transaction? 
> > 
> > (I will be using Postgres and using ``transaction.commit_on_success``) 
> > 
>
> select_for_update() … 
>
> "Returns a queryset that will lock rows until the end of the 
> transaction, generating a SELECT ... FOR UPDATE SQL statement on 
> supported databases." 
>
> Postgresql handles this … 
>
> "If specific tables are named in FOR UPDATE or FOR SHARE, then only 
> rows coming from those tables are locked; any other tables used in the 
> SELECT are simply read as usual. A FOR UPDATE or FOR SHARE clause 
> without a table list affects all tables used in the statement. If FOR 
> UPDATE or FOR SHARE is applied to a view or sub-query, it affects all 
> tables used in the view or sub-query." 
>
>
> http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE
>  
>
> Django doesn't specify any tables when it generates a SELECT … FOR UPDATE 
> query: 
>
>
> https://github.com/django/django/blob/master/django/db/backends/__init__.py#L585
>  
>
> Hope that helps 
>
> Tom 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EaUInBi9N0MJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to