summaryrefslogtreecommitdiff
path: root/tests/model_fields
AgeCommit message (Collapse)Author
2025-03-01[5.2.x] Applied Black's 2025 stable style.Mariusz Felisiak
https://github.com/psf/black/releases/tag/25.1.0 Backport of ff3aaf036f0cb66cd8f404cd51c603e68aaa7676 from main
2025-02-20[5.2.x] Refs #35167 -- Fixed test_bulk_update_custom_get_prep_value() crash ↵Mariusz Felisiak
on databases that don't support primitives in JSONFields. For example on Oracle < 21c. Backport of 7500044a825b3e6695f4f0f9e56d5bdc0c5d7988 from main.
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-06[5.2.x] Fixed #36025 -- Fixed re-aliasing of iterable (in/range) lookups rhs.Simon Charette
In order for Expression.relabeled_clone to work appropriately its get_source_expressions method must return all resolvable which wasn't the case for Lookup when its right-hand-side is "direct" (not a compilable). While refs #22288 added support for non-literals iterable right-hand-side lookups it predated the subclassing of Lookup(Expression) refs #27021 which could have been an opportunity to ensure right-hand-sides are always resolvable (ValueList and ExpressionList). Addressing all edge case with non-resolvable right-hand-sides would require a significant refactor and deprecation of some parts of the Lookup interface so this patch only focuses on FieldGetDbPrepValueIterableMixin (In and Range lookups) by making sure that a right-hand-side containing resolvables are dealt with appropriately during the resolving phase. Thanks Aashay Amballi for the report. Backport of 089deb82b9ac2d002af36fd36f288368cdac4b53 from main.
2025-01-13Fixed #36086 -- Fixed crash when using GeneratedField with non-AutoField pk.Simon Charette
The previous logic was systematically attempting to retrieve last_insert_id even for models without an AutoField primary key when they had a GeneratedField on backends that can't return columns from INSERT. The issue affected MySQL, SQLite < 3.35, and Oracle when the use_returning_into option was disabled and could result in either crashes when the non-auto primary key wasn't an IntegerField subclass or silent misassignment of bogus insert ids (0 or the previous auto primary key insert value) to the first defined generated field value.
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-09-18Fixed #35766 -- Handled slices in BaseChoiceIterator.Sarah Boyce
2024-08-28Refs #35405 -- Adjusted deprecation warning stacklevel in ↵Simon Charette
FieldCacheMixin.get_cache_name().
2024-08-21Fixed #35695 -- Ensured FileFields use a storage pointing to a temp ↵Hisham Mahmood
directory in model_fields tests.
2024-07-15Refs #35560 -- Corrected required feature flags in ↵Mariusz Felisiak
GeneratedModelUniqueConstraint.
2024-07-04Fixed #35560 -- Made Model.full_clean() ignore GeneratedFields for constraints.Mark Gensler
Accessing generated field values on unsaved models caused a crash when validating CheckConstraints and UniqueConstraints with expressions.
2024-05-22Fixed #35472 -- Used temporary directory in test_imagefield.NoReadTests.Sarah Boyce
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-10Fixed #35350 -- Fixed save() with pk set on models with GeneratedFields.Sarah Boyce
Thanks Matt Hegarty for the report and Simon Charette and Natalia Bidart for the reviews. Regression in f333e35.
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-02-16Refs #34060 -- Fixed crash when filtering against literal JSON with psycopg2.Simon Charette
2024-01-19Fixed #35127 -- Made Model.full_clean() ignore GeneratedFields.Mariusz Felisiak
Thanks Claude Paroz for the report. Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
2023-12-31Used addCleanup() in tests where appropriate.Mariusz Felisiak
2023-12-08Fixed #35019 -- Fixed save() on models with both GeneratedFields and ↵Sarah Boyce
ForeignKeys. Thanks Deb Kumar Das for the report. Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
2023-12-07Fixed #35024 -- Fixed model instance creation crash on ↵Mariusz Felisiak
GeneratedField.output_field with backend converters. Regression in d9de74141e8a920940f1b91ed0a3ccb835b55729. This is a long standing issue, however it caused a crash of GeneratedFields for all output fields that have backend-specific converters when the RETURNING clause is not supported (MySQL and SQLite < 3.35). That's why severity was exacerbated.
2023-11-22Fixed #34985 -- Fixed GeneratedFields.contribute_to_class() crash when apps ↵Mariusz Felisiak
are not populated. Thanks Paolo Melchiorre for the report. Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
2023-11-14Fixed #34944 -- Made GeneratedField.output_field required.Mariusz Felisiak
Regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
2023-11-02Refs #31300 -- Allowed testing GeneratedField without collation.Tim Graham
CockroachDB and Snowflake don't support it.
2023-09-28Fixed #34877 -- Fixed migrations crash when adding GeneratedField with ↵Paolo Melchiorre
output_field with params.
2023-09-22Fixed JSONField's test_deep_distinct for ↵Tim Graham
DatabaseFeatures.nulls_order_largest=False. Failure observed on CockroachDB.
2023-09-19Isolated test models for GeneratedFields.Mariusz Felisiak
Test regression in f333e3513e8bdf5ffeb6eeb63021c230082e6f95.
2023-09-18Refs #33308 -- Removed support for passing encoded JSON string literals to ↵Mariusz Felisiak
JSONField & co. Per deprecation timeline.
2023-09-16Fixed #34842 -- Fixed ModelAdmin.readonly_fields crash with GeneratedFields.Paolo Melchiorre
2023-09-14Fixed #34838 -- Corrected output_field of resolved columns for GeneratedFields.Paolo Melchiorre
Thanks Simon Charette for the implementation idea.
2023-09-14Fixed #24561 -- Added support for callables on model fields' choices.Natalia
2023-09-07Fixed #31300 -- Added GeneratedField model field.Jeremy Nauta
Thanks Adam Johnson and Paolo Melchiorre for reviews. Co-Authored-By: Lily Foote <code@lilyf.org> Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2023-08-30 Fixed #31262 -- Added support for mappings on model fields and ↵Nick Pope
ChoiceField's choices.
2023-08-22Added tests for model field's choices iterator/iterable values.Natalia
2023-06-19Refs #34517 -- Restored skipping ImageFileField.update_dimension_fields ↵François Freitag
without width/height fields. This avoids reading the image size when the dimensions fields (image_width, image_height) do not exist, as that operation may be expensive. Partially reverts ea53e7c09f1b8864c20c65976bbeaeab77abdaec, that dropped the check for the dimension fields in update_dimension_fields(), because the post_init signal was no longer registered without dimension fields. However, another code path to that function exists: when the ImageFileField is save()d, the name from the storage is setattr()ed on the field, and ImageFileDescriptor calls update_dimension_fields() because the image size might have changed. Keep bailing out early when dimensions are unused. Besides, computing the image dimensions causes to close() the file, resulting in a backward-incompatible change. The test protects against that change.
2023-05-24Fixed #34590 -- Reverted "Refs #33308 -- Improved adapting DecimalField ↵David Sanders
values to decimal." This reverts 7990d254b0af158baf827fafbd90fe8e890f23bd. Thanks Marc Odermatt for the report.
2023-05-16Fixed #34539 -- Restored get_prep_value() call when adapting JSONFields.Julie Rymer
Regression in 5c23d9f0c32f166c81ecb6f3f01d5077a6084318.
2023-05-03Fixed #34517 -- Avoided connection post_init signal to ImageField without ↵Orhan Hirsch
width/height fields.
2023-03-21Fixed #34388 -- Allowed using choice enumeration types directly on model and ↵T. Franzel
form fields.
2023-03-09Fixed #27397 -- Prevented integer overflows on integer field lookups.Simon Charette
This prevents a sqlite3 crash and address a potential DDoS vector on PostgreSQL caused by full-table-scans on overflows.
2023-02-01Refs #33476 -- Applied Black's 2023 stable style.David Smith
Black 23.1.0 is released which, as the first release of the year, introduces the 2023 stable style. This incorporates most of last year's preview style. https://github.com/psf/black/releases/tag/23.1.0
2022-12-30Refs #34100 -- Made file upload tests use Storage.exists() where appropriate.Francesco Panico
2022-12-15Fixed #33308 -- Added support for psycopg version 3.Daniele Varrazzo
Thanks Simon Charette, Tim Graham, and Adam Johnson for reviews. Co-authored-by: Florian Apolloner <florian@apolloner.eu> Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2022-12-01Refs #33308 -- Deprecated support for passing encoded JSON string literals ↵Simon Charette
to JSONField & co. JSON should be provided as literal Python objects an not in their encoded string literal forms.
2022-10-08Refs #33990 -- Renamed TransactionTestCase.assertQuerysetEqual() to ↵Gregor Gärtner
assertQuerySetEqual(). Co-Authored-By: Michael Howitz <mh@gocept.com>
2022-09-16Fixed #33966 -- Added support for using KeyTextTransform from lookup.Allen Jonathan David
2022-08-27Fixed #33954 -- Prevented models.DecimalField from accepting NaN, Inf, and ↵Mohamed Karam
-Inf values.