1 | | Hi Carlton. |
2 | | I have opened the PR https://github.com/django/django/pull/15569, and have also modified the test that was supposed to throw error(schema.tests.SchemaTests.test_func_unique_constraint_lookups). |
3 | | |
4 | | There is no test that checks if the lookup stays in cache after unregistering it. In my PR, I have added an assert statement to check it in **custom_lookups.tests.LookupTests.test_lookups_caching** test. Running the test without clearing cache from _unregister_lookup will fail. |
5 | | |
6 | | The cache stays between tests, so you are likely to get different results running tests independently and running all tests in a module. (PS: I faced this problem earlier running tests individually and together gave different results.) |
| 1 | In current source code, in the **_unregister_lookup** method, |
| 2 | [https://github.com/django/django/blame/main/django/db/models/query_utils.py#L212], |
| 3 | the cache is not cleared, which should be done, as it is done in |
| 4 | **register_lookup**, |
| 5 | https://github.com/django/django/blame/main/django/db/models/query_utils.py#L202. |
| 6 | Corresponding to this change, minor changes need to be brought in the |
| 7 | **schema.tests.SchemaTests.test_func_unique_constraint_lookups** test. |
| 8 | The PR generated is https://github.com/django/django/pull/15569 |