such as "literal binds" into a CAST expression.
- Fixed bug whereby binary type would fail in some cases
if used with a "test" dialect, such as a DefaultDialect or other
dialect with no DBAPI.
- Fixed bug where "literal binds" wouldn't work with a bound parameter
that's a binary type. A similar, but different, issue is fixed
in 0.8.
.. changelog::
:version: 0.9.2
+ .. change::
+ :tags: bug, sqlite
+
+ Fixed bug whereby SQLite compiler failed to propagate compiler arguments
+ such as "literal binds" into a CAST expression.
+
+ .. change::
+ :tags: bug, sql
+
+ Fixed bug whereby binary type would fail in some cases
+ if used with a "test" dialect, such as a DefaultDialect or other
+ dialect with no DBAPI.
+
+ .. change::
+ :tags: bug, sql, py3k
+
+ Fixed bug where "literal binds" wouldn't work with a bound parameter
+ that's a binary type. A similar, but different, issue is fixed
+ in 0.8.
+
.. change::
:tags: bug, sql
:tickets: 2927
def visit_cast(self, cast, **kwargs):
if self.dialect.supports_cast:
- return super(SQLiteCompiler, self).visit_cast(cast)
+ return super(SQLiteCompiler, self).visit_cast(cast, **kwargs)
else:
- return self.process(cast.clause)
+ return self.process(cast.clause, **kwargs)
def visit_extract(self, extract, **kw):
try:
literal_binds=False,
skip_bind_expression=False,
**kwargs):
-
if not skip_bind_expression and bindparam.type._has_bind_expression:
bind_expression = bindparam.type.bind_expression(bindparam)
return self.process(bind_expression,
def literal_processor(self, dialect):
def process(value):
- value = value.decode(self.dialect.encoding).replace("'", "''")
+ value = value.decode(dialect.encoding).replace("'", "''")
return "'%s'" % value
return process
# Python 3 - sqlite3 doesn't need the `Binary` conversion
# here, though pg8000 does to indicate "bytea"
def bind_processor(self, dialect):
+ if dialect.dbapi is None:
+ return None
+
DBAPIBinary = dialect.dbapi.Binary
def process(value):
dialect=dialect
)
+ self.assert_compile(
+ select([literal(util.b("foo"))]),
+ "SELECT 'foo' AS anon_1",
+ dialect=dialect
+ )
+
assert_raises_message(
exc.CompileError,
"Bind parameter 'foo' without a renderable value not allowed here.",
count().scalar(), 1)
+ def test_literal_roundtrip(self):
+ compiled = select([cast(literal(util.b("foo")), LargeBinary)]).compile(
+ dialect=testing.db.dialect,
+ compile_kwargs={"literal_binds": True})
+ result = testing.db.execute(compiled)
+ eq_(result.scalar(), util.b("foo"))
+
+ def test_bind_processor_no_dbapi(self):
+ b = LargeBinary()
+ eq_(b.bind_processor(default.DefaultDialect()), None)
+
def load_stream(self, name):
f = os.path.join(os.path.dirname(__file__), "..", name)
return open(f, mode='rb').read()