summaryrefslogtreecommitdiff
path: root/django/db/models/base.py
AgeCommit message (Collapse)Author
2021-02-04[3.2.x] Fixed #32332 -- Fixed loss of parent with non-numeric pk when saving ↵Hasan Ramezani
child after parent. Follow up to 519016e5f25d7c0a040015724f9920581551cab0. Backport of 7cba92ec55a5d05450261f375830619870ca84fa from master
2021-01-21[3.2.x] Fixed #32367 -- Fixed system check for specifying type of ↵Mariusz Felisiak
auto-created primary keys for inherited PKs. Regression in b5e12d490af3debca8c55ab3c1698189fdedbbdb. Thanks אורי for the report. Backport of a03a36121d22c8784985c7e45727eddef6a3ea7f from master
2021-01-14Fixed #32321 -- Added system checks for invalid model field names in ↵Hasan Ramezani
functional indexes.
2021-01-13Fixed #26167 -- Added support for functional indexes.Hannes Ljungberg
Thanks Simon Charette, Mads Jensen, and Mariusz Felisiak for reviews. Co-authored-by: Markus Holtermann <info@markusholtermann.eu>
2020-12-15Fixed #31007 -- Allowed specifying type of auto-created primary keys.Tom Forbes
This also changes the default type of auto-created primary keys for new apps and projects to BigAutoField.
2020-10-26Fixed #29497 -- Fixed loss of assigned parent when saving child with ↵Hannes Ljungberg
bulk_create() after parent.
2020-08-12Fixed #31382 -- Made Model.save(update_fields=...) raise ValueError on ↵Pat Garcia
non-concrete fields.
2020-08-12Fixed #31863 -- Prevented mutating model state by copies of model instances.Gert Burger
Regression in bfb746f983aa741afa3709794e70f1e0ab6040b5.
2020-08-05Fixed #26977 -- Made abstract models raise TypeError when instantiating.Jacob Walls
2020-07-06Fixed #31530 -- Added system checks for invalid model field names in ↵Hasan Ramezani
CheckConstraint.check and UniqueConstraint.condition.
2020-06-10Removed unnecessary list() call in ModelBase.__new__().SergBobrovsky
Unnecessary since 58ad030d05fa50cfed327368ab61defca3303e02.
2020-06-04Refs #30913 -- Added system checks for covering indexes and unique ↵Mariusz Felisiak
constraints support.
2020-06-04Fixed #30913 -- Added support for covering indexes on PostgreSQL 11+.Hannes Ljungberg
2020-05-20Fixed #31410 -- Added system checks for invalid model field names in ↵Hasan Ramezani
UniqueConstraint.
2020-05-11Optimized Model and QuerySet pickling version comparison.Adam Johnson
2020-05-05Fixed #31538 -- Fixed Meta.ordering validation lookups that are not transforms.Mariusz Felisiak
Regression in 440505cb2cadbe1a5b9fba246bcde6c04f51d07e. Thanks Simon Meers for the report.
2020-04-30Fixed #20581 -- Added support for deferrable unique constraints.Ian Foote
2020-04-10Fixed #31351 -- Added system checks for partial indexes and unique ↵Ichlasul Affan
constraints support.
2020-03-31Refs #31403 -- Made SQLInsertCompiler.execute_sql() always return an ↵Adam Johnson
iterable of rows. List of tuples.
2020-03-18Refs #31055 -- Made long column names checks support databases aware.Mariusz Felisiak
2020-03-05Fixed #29129 -- Skipped UPDATE when adding a model instance with inherited ↵Abhijeet Viswa
primary key that has a default.
2020-02-19Refs #31187 -- Added total_unique_constraints property to model's Options.Mariusz Felisiak
2020-02-07Fixed #31055 -- Made constraint checks support databases aware.Simon Charette
2020-01-16Fixed #29998 -- Allowed multiple OneToOneFields to the parent model.Mariusz Felisiak
We assumed that any OneToOneField's in a child model must be the parent link and raised an error when parent_link=True was not specified. This patch allows to specify multiple OneToOneField's to the parent model. OneToOneField's without a custom related_name will raise fields.E304 and fields.E305 so this should warn users when they try to override the auto-created OneToOneField.
2020-01-15Fixed #29871 -- Allowed setting pk=None on a child model to create a copy.chetan22
Thanks Simon Charette and Tim Graham for the initial patch.
2019-12-30Fixed #31071 -- Disabled insert optimization for primary keys with defaults ↵Simon Charette
when loading fixtures. Model.save_base() is called directly when loading fixtures and assumes existing rows will be updated. Branching of "raw" allows to maintain the optimization introduced in #29260 while supporting this edge case. Regression in 85458e94e38c20e57939947ee515a1a53689659f. Thanks Reupen Shah for the report.
2019-11-08Fixed #24858 -- Added support for get_FOO_display() to ArrayField and ↵Hasan Ramezani
RangeFields. _get_FIELD_display() crashed when Field.choices was unhashable.
2019-10-01Fixed #30651 -- Made __eq__() methods return NotImplemented for not ↵ElizabethU
implemented comparisons. Changed __eq__ to return NotImplemented instead of False if compared to an object of the same type, as is recommended by the Python data model reference. Now these models can be compared to ANY (or other objects with __eq__ overwritten) without returning False automatically.
2019-09-27Fixed #30798 -- Fixed Meta.ordering validation for pk of related fields.Hasan Ramezani
Regression in 440505cb2cadbe1a5b9fba246bcde6c04f51d07e.
2019-09-27Refs #30798 -- Prevented chaining fields from the same related model ↵Hasan Ramezani
multiple times in model Meta.ordering.
2019-09-23Fixed #13296 -- Fixed ordering by Options.order_with_respect_to after ↵Hasan Ramezani
deleting objects. Thanks Simon Meers for the original patch.
2019-09-09Refs #29444 -- Allowed returning multiple fields from INSERT statements on ↵Johannes Hoppe
PostgreSQL. Thanks Florian Apolloner, Tim Graham, Simon Charette, Nick Pope, and Mariusz Felisiak for reviews.
2019-08-19Fixed #29260 -- Skipped an UPDATE when adding a model instance with primary ↵Hasan Ramezani
key that has a default.
2019-08-12Refs #11964 -- Made constraint support check respect required_db_features.Simon Charette
This will notably silence the warnings issued when running the test suite on MySQL.
2019-07-23Removed unnecessary code in Model.__init__().Jon Dufresne
As is_related_object is True, the val variable is unused for the remainder of the method. Unnecessary since 53da1e47942f22a56e761d786ba89d05ca55a224.
2019-07-05Fixed #30613 -- Moved index name validation to system checks.can
2019-05-28Simplified Model.save() a bit.葛汉斌
2019-05-21Fixed #28147 -- Fixed loss of assigned parent when saving child after parent.Rob
Thanks Erwin Junge for the initial patch.
2019-05-01Fixed #30409 -- Allowed using foreign key's attnames in ↵zeyneloz
unique/index_together and Index's fields.
2019-04-18Fixed typos in docs, comments, and exception messages.Ville Skyttä
2019-03-22Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of lazy strings.Matthias Kestenholz
Reverted cc79c7ee637e65c8da27e56d746c87903d5ec901.
2019-03-14Fixed #30254 -- Allowed model metaclasses to access the attribute dict in ↵Matt Westcott
__init__(). Regression in a68ea231012434b522ce45c513d84add516afa60.
2019-03-01Refs #29408 -- Cosmetic edits for validation of related fields and lookups ↵Mariusz Felisiak
in model Meta.ordering. Follow up to 440505cb2cadbe1a5b9fba246bcde6c04f51d07e.
2019-03-01Fixed #29408 -- Added validation of related fields and lookups in model ↵Hasan Ramezani
Meta.ordering.
2019-01-21Fixed #30106 -- Made order_with_respect_to updates use QuerySet.bulk_update().Simon Charette
2019-01-12Fixed #30062 -- Added support for unique conditional constraints.Paveł Tyślacki
2018-12-22Fixed #29970, #30041 -- Made ModelBase.__new__() pass attrs without ↵Sergey Fedoseev
contribute_to_class() to type.__new__().
2018-11-13Fixed #29641 -- Added support for unique constraints in Meta.constraints.Simon Charette
This constraint is similar to Meta.unique_together but also allows specifying a name. Co-authored-by: Ian Foote <python@ian.feete.org>
2018-10-28Fixed #29896 -- Fixed incorrect Model.save() cache relation clearing for ↵Tim Graham
foreign keys that use to_field. Regression in ee49306176a2d2f1751cb890bd607d42c7c09196.
2018-10-17Fixed #21171 -- Avoided starting a transaction when a single (or atomic ↵Florian Apolloner
queries) are executed. Checked the following locations: * Model.save(): If there are parents involved, take the safe way and use transactions since this should be an all or nothing operation. If the model has no parents: * Signals are executed before and after the previous existing transaction -- they were never been part of the transaction. * if `force_insert` is set then only one query is executed -> atomic by definition and no transaction needed. * same applies to `force_update`. * If a primary key is set and no `force_*` is set Django will try an UPDATE and if that returns zero rows it tries an INSERT. The first case is completly save (single query). In the second case a transaction should not produce different results since the update query is basically a no-op then (might miss something though). * QuerySet.update(): no signals issued, single query -> no transaction needed. * Model/Collector.delete(): This one is fun due to the fact that is does many things at once. Most importantly though: It does send signals as part of the transaction, so for maximum backwards compatibility we need to be conservative. To ensure maximum compatibility the transaction here is removed only if the following holds true: * A single instance is being deleted. * There are no signal handlers attached to that instance. * There are no deletions/updates to cascade. * There are no parents which also need deletion.