From 7dc411dc63faf59b4e28fa0dea805887821d0d99 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 27 May 2020 10:18:33 -0400 Subject: Render table hints in generic SQL Added :meth:`.Select.with_hint` output to the generic SQL string that is produced when calling ``str()`` on a statement. Previously, this clause would be omitted under the assumption that it was dialect specific. The hint text is presented within brackets to indicate the rendering of such hints varies among backends. Fixes: #5353 References: #4667 Change-Id: I01d97d6baa993e495519036ec7ecd5ae62856c16 --- lib/sqlalchemy/sql/compiler.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 8eae0ab7d..fc66ca517 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -3491,6 +3491,9 @@ class StrSQLCompiler(SQLCompiler): def visit_empty_set_expr(self, type_): return "SELECT 1 WHERE 1!=1" + def get_from_hint_text(self, table, text): + return "[%s]" % text + class DDLCompiler(Compiled): @util.memoized_property -- cgit v1.2.1