On Dec 16, 2011, at 4:32 PM, bogun.dmit...@gmail.com wrote: > > > 2011/12/12 Michael Bayer <mike...@zzzcomputing.com> > we have select.prefix_with() which can stick it right after the SELECT, if > that works....otherwise if it really has to be the first thing would need to > work in some @compiles tricks..... > > then as far as Query I thought we had added something for this but apparently > not, you'd have to subclass that too for the moment... :/ > > Hello. I have related question. > I need add "sql_cache" keywords into select query. There is way to do this > on sql layer via "prefixes" keyword argument to "select" class or via method > .prefix_with of the same select class. But I have orm.Query object... And I > can't find way to add prefix on it.
yeah it's a missing feature so do this: from sqlalchemy.orm.query import Query, _generative class MyQuery(Query): _prefixes = () def prefix_with(self, prefixes): self._prefixes += prefixes def _compile_context(self, **kw): ctx = super(MyQuery, self)._compile_context(**kw) if self._prefixes: ctx.statement = ctx.statement.prefix_with(self._prefixes) return ctx Session = sessionmaker(query_cls=MyQuery) > > SA-0.6.7 > > > On Dec 12, 2011, at 3:56 AM, lestat wrote: > >> For our postgresql cluster we need sometime append comment before query >> statement. >> >> E.g. >> q = Comment.query.all() >> >> SELECT ... FROM comment >> >> How append comment like this? >> /*NO LOAD BALANCE*/ SELECT ... FROM comment >> >> I try change q.statement, but can't find right solution. > > > > > -- > 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. -- 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.