[Sqlalchemy-tickets] [sqlalchemy] #2882: literal binds for text()
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2013-12-08 19:18:00
|
#2882: literal binds for text()
--------------------+---------------------------------------
Reporter: zzzeek | Owner: zzzeek
Type: defect | Status: new
Priority: medium | Milestone: 0.9.0
Component: sql | Severity: minor - half an hour
Keywords: | Progress State: needs tests
--------------------+---------------------------------------
not sure if this is for 0.8 or not
{{{
#!python
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])
+ return self.process(textclause._bindparams[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),
}}}
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2882>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|