Right now, the documentation for session.refresh() mentions:

lockmode – Passed to the Query 
<http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query>
 
as used by with_lockmode() 
<http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.with_lockmode>
.

Where clicking on with_lockmode() links to the following note:

Deprecated since version 0.9.0: superseded by Query.with_for_update() 
<http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.with_for_update>
.

My questions are:
1. How should I use refresh with specific update modes? Should I just 
discard that depreciation note?

2. Are there plans to support all 4 update modes of recent PostgreSQL's? 
https://www.postgresql.org/docs/9.6/static/explicit-locking.html
In which case, would it be simpler to just use the DB supplied names 
instead of trying to encode and decode it into boolean parameters to a 
general function? I find that the documentation of PostgreSQL's mode is 
already quite complicated and definitely needs to be properly read by 
anyone trying to use one, so trying to hide it behind a generic function 
might just lead to confusion, in my opinion.

Why not just make those specific modes an imports like other specifics 
already are. 

from sqlalchemy.dialects.postgresql import lock_key_no_update
q = sess.query(User).with_for_update(lock_key_no_update)
and
session.refresh(instance, lockmode= lock_key_no_update))

Just my idea

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to