Re: [Sqlalchemy-tickets] [sqlalchemy] #2731: for_update=whatever always creates a "FOR UPDATE" quer
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-05-21 14:17:28
|
#2731: for_update=whatever always creates a "FOR UPDATE" query
----------------------------------+------------------------------------
Reporter: fayaz | Owner: zzzeek
Type: defect | Status: closed
Priority: medium | Milestone:
Component: sql | Severity: no triage selected yet
Resolution: worksforme | Keywords:
Progress State: awaiting triage |
----------------------------------+------------------------------------
Changes (by zzzeek):
* status: new => closed
* resolution: => worksforme
Comment:
the docs state here that these behaviors are dialect specific:
http://docs.sqlalchemy.org/en/rel_0_8/core/expression_api.html?highlight=for_update#sqlalchemy.sql.expression.select
for_update=False –
when True, applies FOR UPDATE to the end of the resulting statement.
Certain database dialects also support alternate values for this
parameter:
With the MySQL dialect, the value "read" translates to LOCK IN
SHARE MODE.
With the Oracle and Postgresql dialects, the value "nowait"
translates to FOR UPDATE NOWAIT.
With the Postgresql dialect, the values “read” and "read_nowait"
translate to FOR SHARE and FOR SHARE NOWAIT, respectively.
so here the behavior requires a mysql dialect:
{{{
#!python
from sqlalchemy import *
from sqlalchemy.dialects import mysql
def test():
table = Table('user', MetaData(), Column('id', Integer,
primary_key=True))
query = table.select(for_update='read')
assert "LOCK IN SHARE MODE" in
str(query.compile(dialect=mysql.dialect()))
if __name__ == '__main__':
test()
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2731#comment:1>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|