- changed status to resolved
support statement level hints
stmt = select([...]).with_statement_hint("some statement hint", "mysql")
this will send None into with_hint(), which will collect statement-level hints separately and render them by default at the end of the SELECT.
Comments (3)
-
reporter -
This doesn't seem to work (both
with_hint()
andwith_statement_hint()
)... In compile.py (https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/sql/compiler.py#L1667) you call_setup_select_hints
... which returns a tuple containinghint_text
.The issue is that this function creates the
byfrom
dictionary and forhint_text
it callsget_select_hint_text
(located here: https://github.com/zzzeek/sqlalchemy/blob/master/lib/sqlalchemy/sql/compiler.py#L1468) which returns None... So , no hints ever get added (at least when I'm running it) to my statements. -
reporter Hi there -
with_statement_hint() does not make use of the _setup_select_hints method in the default dialect, it uses the get_statement_hint_text() method.
If you are observing a bug, please post an issue with complete test cases which, when run, illustrate a failing assertion (e.g. an mcve. These features are unit tested (see https://bitbucket.org/zzzeek/sqlalchemy/src/ce62fa2eed1d93c9b6e383e48dcfaf5380b86915/test/sql/test_compiler.py?at=master&fileviewer=file-view-default#test_compiler.py-2631 ) so "doesn't seem to work" is unfortunately not specific enough for us to respond. thanks!
- Log in to comment
.Select.with_statement_hint
and ORM method :meth:.Query.with_statement_hint
to support statement-level hints that are not specific to a table. fixes#3206→ <<cset f82f6d55dc05>>