MCPcopy
hub / github.com/django/django / sql_flush

Method sql_flush

django/db/backends/sqlite3/operations.py:206–225  ·  view source on GitHub ↗
(self, style, tables, *, reset_sequences=False, allow_cascade=False)

Source from the content-addressed store, hash-verified

204 return lru_cache(maxsize=512)(self.__references_graph)
205
206 def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
207 if tables and allow_cascade:
208 # Simulate TRUNCATE CASCADE by recursively collecting the tables
209 # referencing the tables to be flushed.
210 tables = set(
211 chain.from_iterable(self._references_graph(table) for table in tables)
212 )
213 sql = [
214 "%s %s %s;"
215 % (
216 style.SQL_KEYWORD("DELETE"),
217 style.SQL_KEYWORD("FROM"),
218 style.SQL_FIELD(self.quote_name(table)),
219 )
220 for table in tables
221 ]
222 if reset_sequences:
223 sequences = [{"table": table} for table in tables]
224 sql.extend(self.sequence_reset_by_name_sql(style, sequences))
225 return sql
226
227 def sequence_reset_by_name_sql(self, style, sequences):
228 if not sequences:

Callers

nothing calls this directly

Calls 4

_references_graphMethod · 0.95
quote_nameMethod · 0.95
extendMethod · 0.80

Tested by

no test coverage detected