Skip to content

Commit a2022da

Browse files
committed
Removed escaping test of query content
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.
1 parent 86c20e3 commit a2022da

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

tests/regressiontests/backends/tests.py

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -127,28 +127,12 @@ def test_django_extract(self):
127127

128128

129129
class LastExecutedQueryTest(TestCase):
130-
# There are no escaping tests for the sqlite backend because it does not
131-
# implement paramater escaping. See #14091.
132-
133-
@unittest.skipUnless(connection.vendor in ('oracle', 'postgresql'),
134-
"These backends use the standard parameter escaping rules")
135-
@override_settings(DEBUG=True)
136-
def test_parameter_escaping(self):
137-
# check that both numbers and string are properly quoted
138-
list(models.Tag.objects.filter(name="special:\\\"':", object_id=12))
139-
sql = connection.queries[-1]['sql']
140-
self.assertTrue("= 'special:\\\"'':' " in sql)
141-
self.assertTrue("= 12 " in sql)
142-
143-
@unittest.skipUnless(connection.vendor == 'mysql',
144-
"MySQL uses backslashes to escape parameters.")
145130
@override_settings(DEBUG=True)
146-
def test_parameter_escaping(self):
147-
list(models.Tag.objects.filter(name="special:\\\"':", object_id=12))
148-
sql = connection.queries[-1]['sql']
149-
# only this line is different from the test above
150-
self.assertTrue("= 'special:\\\\\\\"\\':' " in sql)
151-
self.assertTrue("= 12 " in sql)
131+
def test_debug_sql(self):
132+
list(models.Tag.objects.filter(name="test"))
133+
sql = connection.queries[-1]['sql'].lower()
134+
self.assertTrue(sql.startswith("select"))
135+
self.assertIn(models.Tag._meta.db_table, sql)
152136

153137
def test_query_encoding(self):
154138
"""

0 commit comments

Comments
 (0)