2018-03-14 21:38:16 +08:00
|
|
|
from django.db import connection
|
2018-02-09 23:04:00 +08:00
|
|
|
from django.test import TestCase
|
2018-03-14 21:38:16 +08:00
|
|
|
|
|
|
|
|
2018-02-09 23:04:00 +08:00
|
|
|
class SchemaLoggerTests(TestCase):
|
2018-03-14 21:38:16 +08: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 21:20:27 +08:00
|
|
|
with self.assertLogs('django.db.backends.schema', 'DEBUG') as cm:
|
2018-03-14 21:38:16 +08:00
|
|
|
editor.execute(sql, params)
|
2018-04-28 21:20:27 +08:00
|
|
|
self.assertEqual(cm.records[0].sql, sql)
|
|
|
|
self.assertEqual(cm.records[0].params, params)
|
2018-03-14 21:38:16 +08:00
|
|
|
self.assertEqual(
|
2018-04-28 21:20:27 +08:00
|
|
|
cm.records[0].getMessage(),
|
|
|
|
'SELECT * FROM foo WHERE id in (%s, %s); (params [42, 1337])',
|
2018-03-14 21:38:16 +08:00
|
|
|
)
|