Skip to content

support statement level hints #3206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlalchemy-bot opened this issue Sep 18, 2014 · 4 comments
Closed

support statement level hints #3206

sqlalchemy-bot opened this issue Sep 18, 2014 · 4 comments
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

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.

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

  • Added new method :meth:.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 support statement level hints #3206

f82f6d5

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Collaborator Author

Prabhath Nanisetty wrote:

This doesn't seem to work (both with_hint() and with_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 containing hint_text.

The issue is that this function creates the byfrom dictionary and for hint_text it calls get_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.

@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant