| Age | Commit message (Collapse) | Author |
|
functools.cached_property.
Since Python 3.12, `functools.cached_property` no longer takes a lock
(https://github.com/python/cpython/issues/87634), which was the main
objection to using it instead of Django's own implementation.
`Prefetch(to_attr=...)` and the admindocs model detail page now accept
`functools.cached_property` as well as Django's own `cached_property`.
Co-authored-by: Natalia <124304+nessita@users.noreply.github.com>
|
|
FKs.
These do not need to be looked up if the value is truthy.
|
|
Many attributes did not vary with the instance, so they did not need
to be calculated during __init__().
Thanks Tim Kedmenec for raising the issue at:
https://forum.djangoproject.com/t/46178
|
|
expressions.
Regression in 9b8e4c6d7d47f7b2e96817ba334e9fd53c10a0df.
|
|
a key is outside its integer range.
Oracle's JSON_EXISTS() rejects an array-subscript literal this long
with ORA-40598/JZN-00211.
|
|
is outside PostgreSQL's int4 range.
|
|
Refs #36689. 9b8e4c6d7d wrapped every Value() rhs param of a JSONIn lookup
in JSON_EXTRACT()/JSON_VALUE() assuming it was already JSON-serialized.
That only holds for Value(..., JSONField()); a bare Value("primitive") gets
an inferred non-JSON output_field (e.g. CharField), so its compiled param
was a raw primitive, not JSON text.
JSONIn.resolve_expression_parameter() now JSON-encodes the Value's raw
.value itself whenever its output_field isn't JSONField.
As a side effect, this also fixes Value(True)/Value(False) in __in, which
were previously compared as raw Python bools against the JSON-extracted
lhs and never matched.
Thanks Jacob Walls for the report.
Regression in 9b8e4c6d7d47f7b2e96817ba334e9fd53c10a0df.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
|
|
The underlying unsafety with iterating F() expressions will be handled
later (#37384), to allow time to consider backward compatibility.
The underlying query should also not raise a ValueError (#37383), but
that likely will not be backported.
Thanks Pravin Kamble for the review.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
|
|
get_prep_value() tested for ":" before coercing the value to a string,
which crashed with a TypeError for non-string values such as
ipaddress.IPv4Address and ipaddress.IPv6Address instances, even though
to_python() accepts them.
|
|
in GeneratedField.".
This reverts commit 6025eab3c509b4de922117e16866bbfe0ee99aa6, includes a
release note for 6.1.2, and keeps fields.W225 documented as removed.
Thanks to Michal Porteš for the report, and to Jacob Walls and
Simon Charette for reviews.
|
|
Updated references to RemovedInDjango70Warning to use the new warning,
and adjusted references to "Django 7.0" to "Django 2028".
RemovedInDjango70Warning remains importable as an alias of the same
class, so existing warning filters and except clauses in third-party
code keep working across the rename.
|
|
Thanks Simon Charette for the implementation idea.
|
|
Regression in 821619aa8771ef211c4c4922001efdf914201ca3.
Thanks Norbert Kwizera for the report.
|
|
Support for database-level delete options removed "on_delete" from
`Field.non_db_attrs` because changes to or from the new `DB_CASCADE`,
`DB_SET_DEFAULT`, and `DB_SET_NULL` options require schema changes. As a
consequence, an `AlterField` changing only a Python-level `on_delete` option
(such as `CASCADE` to `PROTECT`) performs unnecessary schema changes when it
was previously a no-op at the database level.
This commit makes `ForeignObject.non_db_attrs` a property that includes
`"on_delete"`only when the option is not a database-level one, so that:
- Python-level to Python-level changes skip DDL again,
- changes to, from, or between database-level options still alter the
field.
Regression in 0c487aa3a7b2417481bf48c1e5355c855873e210.
|
|
|
|
Thanks Jacob Walls and Sarah Boyce for reviews.
|
|
|
|
|
|
Added new constant django.db.models.fields.BLANK_CHOICE_LABEL for
an accessible and translatable blank choice label in forms.
Deprecated django.db.models.fields.BLANK_CHOICE_DASH constant.
Added the immediately deprecated transitional setting
USE_BLANK_CHOICE_DASH.
Co-Authored-By: Marijke Luttekes <mail@marijkeluttekes.dev>
|
|
|
|
managers and related_names.
Clashes were only detected for self-referential relationships, i.e. ForeignKey("self").
Refs #22977. Bug in 6888375c53476011754f778deabc6cdbfa327011.
Thanks JaeHyuckSa for the thorough review!
|
|
|
|
This avoids two isinstance() calls per UUID value.
|
|
|
|
get_placeholder_sql.
The lack of ability of the get_placeholder call chain to return SQL and
parameters separated so they can be mogrified by the backend at execution time
forced implementations to dangerously interpolate potentially user controlled
values.
The get_placeholder_sql name was chosen due to its proximity to the previous
method, but other options such as Field.as_sql were considered but ultimately
rejected due to its different input signature compared to Expression.as_sql
that might have lead to confusion.
There is a lot of overlap between what Field.get_db_prep_value and
get_placeholder_sql do but folding the latter in the former would require
changing its return signature to return expression which is a way more invasive
change than what is proposed here.
Given we always call get_db_prep_value it might still be an avenue worth
exploring in the future to offer a publicly documented interface to allow field
to take an active part in the compilation chain.
Thanks Jacob for the review.
|
|
provided.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
|
|
manager.get_queryset() always returns freshly instantiated per-instance
QuerySet which doesn't need subsequent cloning.
Based on work originally done by Anssi Kääriäinen and Tim Graham.
|
|
|
|
Create and share a single instance of `DatabaseDefault` instead of making a new
one each time the lambda is called. The quick benchmark on the ticket shows a
~12% speedup for a large `bulk_create()` operation.
|
|
Thanks Tim Graham for the suggestion.
|
|
Thanks Jacob Walls for the report.
|
|
The null argument has no effect on GeneratedField since the nullability
of the column depends on the database and expression used.
|
|
|
|
|
|
|
|
more consistent.
This also adds _add_base(), _clear_base(), and _remove_base() internal
hooks.
|
|
|
|
Oracle.
Added a JSONIn lookup to handle correct serialization and extraction
for JSONField top-level __in queries on backends without native JSON
support. KeyTransformIn now subclasses JSONIn.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
Thanks Jacob Walls for the report and review.
|
|
get_db_prep_save.
The validation in validate_autopk_value is specific to saving. Having it in
get_db_prep_value caused Value(0, AutoField()) to fail unexpectedly when used
in a filter on MySQL.
Thanks Jacob Walls for the review.
|
|
feature flags.
Needed on MongoDB.
Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
|
|
Co-authored-by: Karl Wooster <karl.wooster@alleima.com>
|
|
Thanks Lily for the review.
|
|
|
|
Key and index lookups are exempt from the deprecation.
Co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
|
|
Thanks Jacob Walls for the review.
|
|
|
|
Thanks Simon Charette for pair programming.
Co-authored-by: Nick Stefan <NickStefan12@gmail.com>
Co-authored-by: Akash Kumar Sen <71623442+Akash-Kumar-Sen@users.noreply.github.com>
Co-authored-by: Simon Charette <charette.s@gmail.com>
|
|
This change ensures that behavior and performance remain consistent when
traversing relationships.
|
|
Modify these methods to accept an instance parameter which is clearer and
allows us to set the instance hint earlier.
|
|
May your database queries be much reduced with minimal effort.
co-authored-by: Andreas Pelme <andreas@pelme.se>
co-authored-by: Simon Charette <charette.s@gmail.com>
co-authored-by: Jacob Walls <jacobtylerwalls@gmail.com>
|