mirror of
https://github.com/django/django.git
synced 2025-06-05 11:39:13 +00:00
Fixed #33626 -- Cleared cache when unregistering a lookup.
This commit is contained in:
parent
884b4c27f5
commit
06ebaa9e28
@ -217,6 +217,7 @@ class RegisterLookupMixin:
|
|||||||
if lookup_name is None:
|
if lookup_name is None:
|
||||||
lookup_name = lookup.lookup_name
|
lookup_name = lookup.lookup_name
|
||||||
del cls.class_lookups[lookup_name]
|
del cls.class_lookups[lookup_name]
|
||||||
|
cls._clear_cached_lookups()
|
||||||
|
|
||||||
|
|
||||||
def select_related_descend(field, restricted, requested, load_fields, reverse=False):
|
def select_related_descend(field, restricted, requested, load_fields, reverse=False):
|
||||||
|
@ -323,6 +323,8 @@ class LookupTests(TestCase):
|
|||||||
with register_lookup(models.ForeignObject, Exactly):
|
with register_lookup(models.ForeignObject, Exactly):
|
||||||
# getting the lookups again should re-cache
|
# getting the lookups again should re-cache
|
||||||
self.assertIn("exactly", field.get_lookups())
|
self.assertIn("exactly", field.get_lookups())
|
||||||
|
# Unregistration should bust the cache.
|
||||||
|
self.assertNotIn("exactly", field.get_lookups())
|
||||||
|
|
||||||
|
|
||||||
class BilateralTransformTests(TestCase):
|
class BilateralTransformTests(TestCase):
|
||||||
|
@ -88,7 +88,6 @@ class TestMethods(SimpleTestCase):
|
|||||||
transform = field.get_transform("my_transform")
|
transform = field.get_transform("my_transform")
|
||||||
self.assertIs(transform, MyTransform)
|
self.assertIs(transform, MyTransform)
|
||||||
models.JSONField._unregister_lookup(MyTransform)
|
models.JSONField._unregister_lookup(MyTransform)
|
||||||
models.JSONField._clear_cached_lookups()
|
|
||||||
transform = field.get_transform("my_transform")
|
transform = field.get_transform("my_transform")
|
||||||
self.assertIsInstance(transform, KeyTransformFactory)
|
self.assertIsInstance(transform, KeyTransformFactory)
|
||||||
|
|
||||||
|
@ -2770,16 +2770,16 @@ class SchemaTests(TransactionTestCase):
|
|||||||
with connection.schema_editor() as editor:
|
with connection.schema_editor() as editor:
|
||||||
editor.add_constraint(Author, constraint)
|
editor.add_constraint(Author, constraint)
|
||||||
sql = constraint.create_sql(Author, editor)
|
sql = constraint.create_sql(Author, editor)
|
||||||
table = Author._meta.db_table
|
table = Author._meta.db_table
|
||||||
constraints = self.get_constraints(table)
|
constraints = self.get_constraints(table)
|
||||||
self.assertIn(constraint.name, constraints)
|
self.assertIn(constraint.name, constraints)
|
||||||
self.assertIs(constraints[constraint.name]["unique"], True)
|
self.assertIs(constraints[constraint.name]["unique"], True)
|
||||||
# SQL contains columns.
|
# SQL contains columns.
|
||||||
self.assertIs(sql.references_column(table, "name"), True)
|
self.assertIs(sql.references_column(table, "name"), True)
|
||||||
self.assertIs(sql.references_column(table, "weight"), True)
|
self.assertIs(sql.references_column(table, "weight"), True)
|
||||||
# Remove constraint.
|
# Remove constraint.
|
||||||
with connection.schema_editor() as editor:
|
with connection.schema_editor() as editor:
|
||||||
editor.remove_constraint(Author, constraint)
|
editor.remove_constraint(Author, constraint)
|
||||||
self.assertNotIn(constraint.name, self.get_constraints(table))
|
self.assertNotIn(constraint.name, self.get_constraints(table))
|
||||||
|
|
||||||
@skipUnlessDBFeature("supports_expression_indexes")
|
@skipUnlessDBFeature("supports_expression_indexes")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user