Added test for sql percents treatment

This commit is contained in:
Daniele Varrazzo 2017-01-01 06:37:09 +01:00
parent 828415d476
commit 41b9bfe401

View File

@ -60,6 +60,15 @@ class ComposeTests(ConnectingTestCase):
s1 = s.as_string(self.conn)
self.assertEqual(s1, "select foo;")
def test_percent_escape(self):
s = sql.compose("42 %% %s", [sql.Literal(7)])
s1 = s.as_string(self.conn)
self.assertEqual(s1, "42 % 7")
s = sql.compose("42 %% 7")
s1 = s.as_string(self.conn)
self.assertEqual(s1, "42 % 7")
def test_compose_badnargs(self):
self.assertRaises(ValueError, sql.compose, "select foo;", [10])
self.assertRaises(ValueError, sql.compose, "select %s;")