literal binds for text()

Issue #2882 resolved
Mike Bayer repo owner created an issue

not sure if this is for 0.8 or not

from sqlalchemy import *
from sqlalchemy.dialects import sqlite


t = text("select * where x = :bind").bindparams(bind='x')

print t.compile(dialect=sqlite.dialect(), compile_kwargs={"literal_binds": True})

should print:

select * where x = 'x'



#!diff
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 0c25208..3c8d713 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -585,13 +585,13 @@ class SQLCompiler(Compiled):
     def post_process_text(self, text):
         return text

-    def visit_textclause(self, textclause, **kwargs):
+    def visit_textclause(self, textclause, **kw):
         def do_bindparam(m):
             name = m.group(1)
             if name in textclause._bindparams:
-                return self.process(textclause._bindparams[name](name))
+                return self.process(textclause._bindparams[name](name), **kw)
             else:
-                return self.bindparam_string(name, **kwargs)
+                return self.bindparam_string(name, **kw)

         # un-escape any \:params
         return BIND_PARAMS_ESC.sub(lambda m: m.group(1),

Comments (3)

  1. Log in to comment