MCPcopy
hub / github.com/django/django / execute_sql

Method execute_sql

django/db/models/sql/compiler.py:2113–2132  ·  view source on GitHub ↗

Execute the specified update. Return the number of rows affected by the primary update query. The "primary update query" is the first non-empty query that is executed. Row counts for any subsequent, related queries are not available.

(self, result_type)

Source from the content-addressed store, hash-verified

2111 return " ".join(result), tuple(update_params + params)
2112
2113 def execute_sql(self, result_type):
2114 """
2115 Execute the specified update. Return the number of rows affected by
2116 the primary update query. The "primary update query" is the first
2117 non-empty query that is executed. Row counts for any subsequent,
2118 related queries are not available.
2119 """
2120 row_count = super().execute_sql(result_type)
2121 is_empty = row_count is None
2122 row_count = row_count or 0
2123
2124 for query in self.query.get_related_updates():
2125 # If the result_type is NO_RESULTS then the aux_row_count is None.
2126 aux_row_count = query.get_compiler(self.using).execute_sql(result_type)
2127 if is_empty and aux_row_count:
2128 # Returns the row count for any related updates as the number
2129 # of rows updated.
2130 row_count = aux_row_count
2131 is_empty = False
2132 return row_count
2133
2134 def execute_returning_sql(self, returning_fields):
2135 """

Callers 1

execute_returning_sqlMethod · 0.95

Calls 3

get_related_updatesMethod · 0.80
get_compilerMethod · 0.80
execute_sqlMethod · 0.45

Tested by

no test coverage detected