Skip to content

Commit

Permalink
Removed escaping test of query content
Browse files Browse the repository at this point in the history
As the content of last_executed_query() is not under Django's control
for most backends, it is useless to test too specific aspects of it.
  • Loading branch information
claudep committed Jun 13, 2012
1 parent 86c20e3 commit a2022da
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions tests/regressiontests/backends/tests.py
Expand Up @@ -127,28 +127,12 @@ def test_django_extract(self):


class LastExecutedQueryTest(TestCase):
# There are no escaping tests for the sqlite backend because it does not
# implement paramater escaping. See #14091.

@unittest.skipUnless(connection.vendor in ('oracle', 'postgresql'),
"These backends use the standard parameter escaping rules")
@override_settings(DEBUG=True)
def test_parameter_escaping(self):
# check that both numbers and string are properly quoted
list(models.Tag.objects.filter(name="special:\\\"':", object_id=12))
sql = connection.queries[-1]['sql']
self.assertTrue("= 'special:\\\"'':' " in sql)
self.assertTrue("= 12 " in sql)

@unittest.skipUnless(connection.vendor == 'mysql',
"MySQL uses backslashes to escape parameters.")
@override_settings(DEBUG=True)
def test_parameter_escaping(self):
list(models.Tag.objects.filter(name="special:\\\"':", object_id=12))
sql = connection.queries[-1]['sql']
# only this line is different from the test above
self.assertTrue("= 'special:\\\\\\\"\\':' " in sql)
self.assertTrue("= 12 " in sql)
def test_debug_sql(self):
list(models.Tag.objects.filter(name="test"))
sql = connection.queries[-1]['sql'].lower()
self.assertTrue(sql.startswith("select"))
self.assertIn(models.Tag._meta.db_table, sql)

def test_query_encoding(self):
"""
Expand Down

0 comments on commit a2022da

Please sign in to comment.