MCPcopy
hub / github.com/django/django / _insert

Method _insert

django/db/models/query.py:2093–2118  ·  view source on GitHub ↗

Insert a new record for the given model. This provides an interface to the InsertQuery class and is how Model.save() is implemented.

(
        self,
        objs,
        fields,
        returning_fields=None,
        raw=False,
        using=None,
        on_conflict=None,
        update_fields=None,
        unique_fields=None,
    )

Source from the content-addressed store, hash-verified

2091 ###################
2092
2093 def _insert(
2094 self,
2095 objs,
2096 fields,
2097 returning_fields=None,
2098 raw=False,
2099 using=None,
2100 on_conflict=None,
2101 update_fields=None,
2102 unique_fields=None,
2103 ):
2104 """
2105 Insert a new record for the given model. This provides an interface to
2106 the InsertQuery class and is how Model.save() is implemented.
2107 """
2108 self._for_write = True
2109 if using is None:
2110 using = self.db
2111 query = sql.InsertQuery(
2112 self.model,
2113 on_conflict=on_conflict,
2114 update_fields=update_fields,
2115 unique_fields=unique_fields,
2116 )
2117 query.insert_values(fields, objs, raw=raw)
2118 return query.get_compiler(using=using).execute_sql(returning_fields)
2119
2120 _insert.alters_data = True
2121 _insert.queryset_only = False

Callers 2

_batched_insertMethod · 0.95
_do_insertMethod · 0.80

Calls 3

insert_valuesMethod · 0.95
get_compilerMethod · 0.80
execute_sqlMethod · 0.45

Tested by

no test coverage detected