Kaydet (Commit) ec7bf6d8 authored tarafından Simon Charette's avatar Simon Charette Kaydeden (comit) Tim Graham

Refs #20483 -- Cached Oracle references retrieval on sql_flush().

üst 2b2ae4ee
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}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment