--- /dev/null
+.. change::
+ :tags: bug, sql
+ :tickets: 7721
+
+ Fixed type-related error messages that would fail for values that were
+ tuples, due to string formatting syntax, including compile of unsupported
+ literal values and invalid boolean values.
def _strict_as_bool(self, value):
if value not in self._strict_bools:
if not isinstance(value, int):
- raise TypeError("Not a boolean value: %r" % value)
+ raise TypeError("Not a boolean value: %r" % (value,))
else:
raise ValueError(
- "Value %r is not None, True, or False" % value
+ "Value %r is not None, True, or False" % (value,)
)
return value
def literal_processor(self, dialect):
def process(value):
raise exc.CompileError(
- "Don't know how to render literal SQL value: %r" % value
+ "Don't know how to render literal SQL value: %r" % (value,)
)
return process
insp.__class__ in inspection._registrars
):
raise exc.ArgumentError(
- "Object %r is not legal as a SQL literal value" % value
+ "Object %r is not legal as a SQL literal value" % (value,)
)
return NULLTYPE
else:
class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
__dialect__ = "default"
+ def test_compile_err_formatting(self):
+ with expect_raises_message(
+ exc.CompileError,
+ r"Don't know how to render literal SQL value: \(1, 2, 3\)",
+ ):
+ func.foo((1, 2, 3)).compile(compile_kwargs={"literal_binds": True})
+
+ def test_strict_bool_err_formatting(self):
+ typ = Boolean()
+
+ dialect = default.DefaultDialect()
+ with expect_raises_message(
+ TypeError,
+ r"Not a boolean value: \(5,\)",
+ ):
+ typ.bind_processor(dialect)((5,))
+
@testing.requires.unbounded_varchar
def test_string_plain(self):
self.assert_compile(String(), "VARCHAR")