On Jun 28, 2011, at 2:55 PM, Alexandre Conrad wrote:

> I must have it wrong, I admit I don't quite understand the arguments
> of .with_hint()
> 
> session.query(User).with_hint(User, 'WITH (nolock)').get(1)
> 
> if that makes any sense (I wonder why I'd need to pass the User object again).

well "HINT" is a construct that on some backends is given per table like 
sybase, so that's why it accepts the entity.  

SQL server dialect doesn't have hints implemented, this patch will do it, what 
version are you on ?

diff -r 223fc8419706 lib/sqlalchemy/dialects/mssql/base.py
--- a/lib/sqlalchemy/dialects/mssql/base.py     Mon Jun 27 19:25:35 2011 -0400
+++ b/lib/sqlalchemy/dialects/mssql/base.py     Tue Jun 28 15:18:54 2011 -0400
@@ -766,6 +766,9 @@
             return s
         return compiler.SQLCompiler.get_select_precolumns(self, select)
 
+    def get_from_hint_text(self, text):
+        return text
+
     def limit_clause(self, select):
         # Limit in mssql is after the select keyword
         return ""


I'm looking at some examples of WITH (nolock) and it appears to work the same 
way, the directive is given per table.   with_hint() doesn't necessarily know 
that the query is against just one entity, it is not sophisticated enough to 
check for that right now.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to