2022-01-12 15:16:45 +01:00
|
|
|
From 402ed030933ffa1af74db50f737872d48f0152bb Mon Sep 17 00:00:00 2001
|
|
|
|
From: Mariusz Felisiak <felisiak.mariusz@gmail.com>
|
|
|
|
Date: Thu, 9 Dec 2021 13:21:36 +0100
|
|
|
|
Subject: [PATCH] Fixed inspectdb.tests.InspectDBTestCase.test_custom_fields()
|
|
|
|
on SQLite 3.37+.
|
|
|
|
|
|
|
|
Use FlexibleFieldLookupDict which is case-insensitive mapping because
|
|
|
|
SQLite 3.37+ returns some data type names uppercased e.g. TEXT.
|
|
|
|
---
|
|
|
|
tests/inspectdb/tests.py | 11 +++++------
|
|
|
|
1 file changed, 5 insertions(+), 6 deletions(-)
|
|
|
|
|
2022-03-01 12:24:38 +01:00
|
|
|
Index: Django-4.0.3/tests/inspectdb/tests.py
|
|
|
|
===================================================================
|
|
|
|
--- Django-4.0.3.orig/tests/inspectdb/tests.py
|
|
|
|
+++ Django-4.0.3/tests/inspectdb/tests.py
|
|
|
|
@@ -387,18 +387,18 @@ class InspectDBTestCase(TestCase):
|
2022-01-12 15:16:45 +01:00
|
|
|
Introspection of columns with a custom field (#21090)
|
|
|
|
"""
|
|
|
|
out = StringIO()
|
|
|
|
- orig_data_types_reverse = connection.introspection.data_types_reverse
|
|
|
|
- try:
|
|
|
|
- connection.introspection.data_types_reverse = {
|
|
|
|
+ with mock.patch(
|
2022-03-01 12:24:38 +01:00
|
|
|
+ "django.db.connection.introspection.data_types_reverse."
|
|
|
|
+ "base_data_types_reverse",
|
2022-01-12 15:16:45 +01:00
|
|
|
+ {
|
2022-03-01 12:24:38 +01:00
|
|
|
"text": "myfields.TextField",
|
|
|
|
"bigint": "BigIntegerField",
|
2022-01-12 15:16:45 +01:00
|
|
|
- }
|
|
|
|
+ },
|
|
|
|
+ ):
|
2022-03-01 12:24:38 +01:00
|
|
|
call_command("inspectdb", "inspectdb_columntypes", stdout=out)
|
2022-01-12 15:16:45 +01:00
|
|
|
output = out.getvalue()
|
|
|
|
self.assertIn("text_field = myfields.TextField()", output)
|
|
|
|
self.assertIn("big_int_field = models.BigIntegerField()", output)
|
|
|
|
- finally:
|
|
|
|
- connection.introspection.data_types_reverse = orig_data_types_reverse
|
|
|
|
|
|
|
|
def test_introspection_errors(self):
|
|
|
|
"""
|