- attached test.py
for_update=whatever always creates a "FOR UPDATE" query
Issue #2731
resolved
When using
table.select(for_update='read')
The query string representation is still
SELECT "user".id
FROM "user" FOR UPDATE
Comments (2)
-
reporter -
repo owner - changed status to wontfix
the docs state here that these behaviors are dialect specific:
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:
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()
- Log in to comment
Test file