mirror of https://github.com/django/django.git
Refs #20483 -- Cached Oracle references retrieval on sql_flush().
This commit is contained in:
parent
2b2ae4eeb7
commit
ec7bf6d826
|
@ -1,6 +1,7 @@
|
|||
import datetime
|
||||
import re
|
||||
import uuid
|
||||
from functools import lru_cache
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.backends.base.operations import BaseDatabaseOperations
|
||||
|
@ -315,7 +316,7 @@ END;
|
|||
def return_insert_id(self):
|
||||
return "RETURNING %s INTO %%s", (InsertIdVar(),)
|
||||
|
||||
def _foreign_key_constraints(self, table_name, recursive=False):
|
||||
def __foreign_key_constraints(self, table_name, recursive):
|
||||
with self.connection.cursor() as cursor:
|
||||
if recursive:
|
||||
cursor.execute("""
|
||||
|
@ -348,6 +349,12 @@ END;
|
|||
""", (table_name,))
|
||||
return cursor.fetchall()
|
||||
|
||||
@cached_property
|
||||
def _foreign_key_constraints(self):
|
||||
# 512 is large enough to fit the ~330 tables (as of this writing) in
|
||||
# Django's test suite.
|
||||
return lru_cache(maxsize=512)(self.__foreign_key_constraints)
|
||||
|
||||
def sql_flush(self, style, tables, sequences, allow_cascade=False):
|
||||
if tables:
|
||||
truncated_tables = {table.upper() for table in tables}
|
||||
|
|
Loading…
Reference in New Issue