2018-03-14 13:38:16 +00:00
|
|
|
from django.db import connection
|
2018-02-09 15:04:00 +00:00
|
|
|
from django.test import TestCase
|
2018-03-14 13:38:16 +00:00
|
|
|
|
|
|
|
|
2018-02-09 15:04:00 +00:00
|
|
|
class SchemaLoggerTests(TestCase):
|
2018-03-14 13:38:16 +00:00
|
|
|
|
|
|
|
def test_extra_args(self):
|
|
|
|
editor = connection.schema_editor(collect_sql=True)
|
|
|
|
sql = 'SELECT * FROM foo WHERE id in (%s, %s)'
|
|
|
|
params = [42, 1337]
|
2018-04-28 13:20:27 +00:00
|
|
|
with self.assertLogs('django.db.backends.schema', 'DEBUG') as cm:
|
2018-03-14 13:38:16 +00:00
|
|
|
editor.execute(sql, params)
|
2018-04-28 13:20:27 +00:00
|
|
|
self.assertEqual(cm.records[0].sql, sql)
|
|
|
|
self.assertEqual(cm.records[0].params, params)
|
2018-03-14 13:38:16 +00:00
|
|
|
self.assertEqual(
|
2018-04-28 13:20:27 +00:00
|
|
|
cm.records[0].getMessage(),
|
|
|
|
'SELECT * FROM foo WHERE id in (%s, %s); (params [42, 1337])',
|
2018-03-14 13:38:16 +00:00
|
|
|
)
|