def _literal_as_text(element):
if hasattr(element, '__clause_element__'):
return element.__clause_element__()
- elif not isinstance(element, Visitable):
+ elif isinstance(element, basestring):
return _TextClause(unicode(element))
+ elif not isinstance(element, Visitable):
+ raise exc.ArgumentError("SQL expression object or string expected.")
else:
return element
expected,
dialect=dialect
)
+
+ def test_literal_as_text_fromstring(self):
+ self.assert_compile(
+ and_("a", "b"),
+ "a AND b"
+ )
+
+ def test_literal_as_text_nonstring_raise(self):
+ assert_raises(exc.ArgumentError,
+ and_, ("a",), ("b",)
+ )
+
class CRUDTest(TestBase, AssertsCompiledSQL):
def test_insert(self):