summaryrefslogtreecommitdiff
path: root/django/db/models/fields
AgeCommit message (Collapse)Author
2025-02-18[5.2.x] Fixed #35167 -- Delegated to super() in JSONField.get_db_prep_save().Jacob Walls
Avoids reports of bulk_update() sending Cast expressions to JSONField.get_prep_value(). Co-authored-by: Simon Charette <charette.s@gmail.com> Backport of 0bf412111be686b6b23e00863f5d449d63557dbf from main.
2025-02-18[5.2.x] Fixed #36197 -- Fixed improper many-to-many count() and exists() for ↵Simon Charette
non-pk to_field. Regression in 66e47ac69a7e71cf32eee312d05668d8f1ba24bb. Thanks mfontana-elem for the report and Sarah for the tests. Backport of c3a23aa02faa1cf1d32e43d66858e793cd9ecac4 from main.
2025-02-15[5.2.x] Refs #36181 -- Removed the obsolete SubqueryConstraint machinery.Mariusz Felisiak
Adding proper support for subquery right-hand-sides to TupleIn made it obsolete. Backport of d386405e04dac50656af50d100a14efdf8c58e8f from main Co-authored-by: Simon Charette <charette.s@gmail.com>
2025-02-13[5.2.x] Fixed #36181 -- Allowed Subquery usage in __in lookups against ↵Simon Charette
composite pks. Thanks Jacob Walls for the report. Backport of 8561100425876bde3be4b2a22324655f74ff9609 from main.
2025-02-11[5.2.x] Fixed #36149 -- Allowed subquery values against tuple exact and in ↵Simon Charette
lookups. Non-tuple exact and in lookups have specialized logic for subqueries that can be adapted to properly assign select mask if unspecified and ensure the number of involved members are matching on both side of the operator. Backport of 41239fe34d64e801212dccaa4585e4802d0fac68 from main.
2025-02-11[5.2.x] Refs #36148 -- Relied on a feature switch to define tuple lookups ↵Simon Charette
support. This should allow backends more easily opt-in or out of native support and rely on the fallback if unavailable. Backport of a0a765ddeb5056c85e084773d3f6432e2a426638 from main.
2025-02-09[5.2.x] Refs #373 -- Delegated Tuple compilation to compiler.Simon Charette
This should allow third-party backends to define Tuple.as_vendor() overrides that are taken into consideration which calling as_sql() directly prevents. Backport of c326cfe3b1683e6c205f53a4ad11feba6623a399 from main
2025-02-06[5.2.x] Fixed #36061 -- Added migration support for ↵brian
ManyToManyField.through_fields. Added through_fields support to ManyToManyField.deconstruct. Thanks to Simon Charette for pointers and the review. Backport of b13b8684a04d0bc1081104c5973c62c27dc673b0 from main.
2025-02-06[5.2.x] Fixed #35677 -- Avoided non-sticky filtering of prefetched many-to-many.Simon Charette
The original queryset._next_is_sticky() call never had the intended effect as no further filtering was applied internally after the pk__in lookup making it a noop. In order to be coherent with how related filters are applied when retrieving objects from a related manager the effects of what calling _next_is_sticky() prior to applying annotations and filters to the queryset provided for prefetching are emulated by allowing the reuse of all pre-existing JOINs. Thanks David Glenck and Thiago Bellini Ribeiro for the detailed reports and tests. Backport of 2598b371a93e21d84b7a2a99b2329535c8c0c138 from main.
2025-02-03[5.2.x] Fixed #36135 -- Fixed reverse GenericRelation prefetching.Simon Charette
The get_(local|foreign)_related_value methods of GenericRelation must be reversed because it defines (from|to)_fields and associated related_fields in the reversed order as it's effectively a reverse GenericForeignKey itself. The related value methods must also account for the fact that referenced primary key values might be stored as a string on the model defining the GenericForeignKey but as integer on the model defining the GenericRelation. This is achieved by calling the to_python method of the involved content type in get_foreign_related_value just like GenericRelatedObjectManager does. Lastly reverse many-to-one manager's prefetch_related_querysets should use set_cached_value instead of direct attribute assignment as direct assignment might are disallowed on ReverseManyToOneDescriptor descriptors. This is likely something that was missed in f5233dc (refs #32511) when the is_cached guard was added. Thanks 1xinghuan for the report. Backport of 198b30168d4e94af42e0dc7967bd3259b5c5790b from main.
2025-01-21[5.2.x] Fixed #36116 -- Optimized multi-column ForwardManyToOne prefetching.Simon Charette
Rely on ColPairs and TupleIn which support a single column to be specified to avoid special casing ForwardManyToOne.get_prefetch_querysets(). Thanks Jacob Walls for the report. Backport of 626d77e52a3f247358514bcf51c761283968099c from main.
2025-01-14Fixed CVE-2024-56374 -- Mitigated potential DoS in IPv6 validation.Michael Manfre
Thanks Saravana Kumar for the report, and Sarah Boyce and Mariusz Felisiak for the reviews. Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2025-01-13Refs #36050 -- Fixed OuterRef support for CompositePrimaryKey on Oracle.Simon Charette
Oracle doesn't support native tuple comparison so each as_oracle implementation of tuple lookups must also perform right-hand-side sanitization.
2025-01-10Fixed #36050 -- Added OuterRef support to CompositePrimaryKey.Bendeguz Csirmaz
2025-01-10Refs #36064 -- Added Model.has_db_default() to encapsulate NOT_PROVIDED checks.Simon Charette
This avoids many awkward checks against NOT_PROVIDED and provides symmetry with Field.has_default() which is also the reason why it wasn't made a property.
2025-01-08Fixed #36062 -- Handled serialization of CompositePrimaryKeys.Sarah Boyce
2025-01-07Refs #36042 -- Raised ValueError when providing composite expressions to ↵Jacob Walls
aggregates.
2025-01-06Fixed #36048 -- Preferred ValueError to NotSupportedError for composite pk ↵Jacob Walls
sanity checks. These checks are not backend-dependent.
2025-01-02Fixed typo in django/db/models/fields/related_descriptors.py.Jacob Walls
2025-01-02Fixed #36034 -- Added system check for ↵Mariusz Felisiak
ForeignKey/ForeignObject/ManyToManyField to CompositePrimaryKeys.
2025-01-02Refs #373 -- Errored when providing db_column to CompositePrimaryKey.Jacob Walls
2024-12-09Fixed #35982 -- Made DecimalField.get_db_prep_value() call ↵Tim Graham
DatabaseOperations.adapt_decimalfield_value(). Regression in e9814029f570bd0866dc859147bca90340bcc913. Thanks Simon Charette for advice and review.
2024-12-04Fixed CVE-2024-53908 -- Prevented SQL injections in direct HasKeyLookup ↵Simon Charette
usage on Oracle. Thanks Seokchan Yoon for the report, and Mariusz Felisiak and Sarah Boyce for the reviews.
2024-12-03Refs #35842 -- Fixed handling of quotes in JSONField key lookups on Oracle.Sage Abdullah
2024-11-29Fixed #373 -- Added CompositePrimaryKey.Bendeguz Csirmaz
Thanks Lily Foote and Simon Charette for reviews and mentoring this Google Summer of Code 2024 project. Co-authored-by: Simon Charette <charette.s@gmail.com> Co-authored-by: Lily Foote <code@lilyf.org>
2024-11-11Fixed #35815 -- Made system check accept db_default literals when ↵Tim Graham
DatabaseFeatures.supports_expression_defaults = False.
2024-11-04Refs #373 -- Added TupleIn subqueries.Bendeguz Csirmaz
2024-10-14Refs #373 -- Added additional validations to tuple lookups.Bendeguz Csirmaz
2024-09-26Refs #373 -- Added support for using tuple lookups in filters.Bendeguz Csirmaz
2024-09-20Refs #373 -- Updated TupleIsNull lookup to check if any is NULL rather than all.Bendeguz Csirmaz
Regression in 1eac690d25dd49088256954d4046813daa37dc95.
2024-09-11Refs #373 -- Removed outdated comment in RelatedIn lookup.Csirmaz Bendegúz
2024-09-11Refs #373 -- Refactored variable assignments in ColPairs and tuple lookups.Bendeguz Csirmaz
2024-09-11Refs #373 -- Improved test coverage of tuple lookup checks.Bendeguz Csirmaz
This also removed unreachable checks.
2024-09-09Refs #373 -- Added Model._is_pk_set() abstraction to check if a Model's PK ↵Csirmaz Bendegúz
is set.
2024-08-28Refs #35405 -- Adjusted deprecation warning stacklevel in ↵Simon Charette
FieldCacheMixin.get_cache_name().
2024-08-28Refs #16055 -- Adjusted deprecation warning stacklevel in ↵Simon Charette
get_joining_columns()/get_reverse_joining_columns().
2024-08-05Fixed #35657 -- Made FileField handle db_default values.Sarah Boyce
2024-08-05Fixed #35638 -- Updated validate_constraints to consider db_default.David Sanders
2024-08-01Refs #373 -- Added tuple lookups.Bendeguz Csirmaz
2024-07-09Fixed #35580 -- Allowed related fields referencing auto-created through models.jason_bruce
2024-07-04Fixed #35569 -- Improved wording of invalid ForeignKey error message.Jacob Walls
2024-05-22Fixed #35139 -- Prevented file read after ImageField is saved to storage.John Parton
2024-05-21Fixed #35405 -- Converted get_cache_name into a cached property in ↵Adam Johnson
FieldCacheMixin. FieldCacheMixin is used by related fields to track their cached values. This work migrates get_cache_name() to be a cached property to optimize performance by reducing unnecessary function calls when working with related fields, given that its value remains constant. Co-authored-by: Simon Charette <charette.s@gmail.com> Co-authored-by: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-05-15Fixed #35384 -- Raised FieldError when saving a file without a name to ↵Jonny Park
FileField.
2024-04-01Fixed #35344, Refs #34838 -- Corrected output_field of resolved columns for ↵Johannes Westphal
GeneratedFields in aliased tables. Thanks Simon Charette for the review.
2024-03-20Fixed #35309 -- Made prefetch clear ordering for single-valued relationships.Laurent Lyaudet
2024-03-11Fixed #35285 -- Optimized ForeignObject._check_unique_target().Adam Johnson
2024-03-04Fixed #35266 -- Deferred formatting in RelatedField._check_clashes().Adam Johnson
2024-02-26Fixed #35246 -- Made Field.unique a cached property.Adam Johnson
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
2024-02-19Refs #28011 -- Removed ForeignObjectRel.is_hidden().Adam Johnson