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)
|
2022-12-01 19:23:43 +00:00
|
|
|
if connection.features.schema_editor_uses_clientside_param_binding:
|
|
|
|
sql = "SELECT * FROM foo WHERE id in (42, 1337)"
|
|
|
|
params = None
|
2018-04-28 13:20:27 +00:00
|
|
|
self.assertEqual(cm.records[0].sql, sql)
|
|
|
|
self.assertEqual(cm.records[0].params, params)
|
2022-12-01 19:23:43 +00:00
|
|
|
self.assertEqual(cm.records[0].getMessage(), f"{sql}; (params {params})")
|