Commit Graph

1831 Commits

Author SHA1 Message Date
François Freitag bdbe50a491 Fixed #25546 -- Prevented duplicate queries with nested prefetch_related(). 2016-01-26 07:20:13 -05:00
userimack 60586dd737 Fixed #26125 -- Fixed E731 flake warnings. 2016-01-25 14:23:43 -05:00
Joshua Phillips 16baec5c8a Fixed #25910 -- Rejected read-only property names in model constructors. 2016-01-22 13:27:11 -05:00
Anssi Kääriäinen ee596888e1 Fixed #26092 -- Fixed QuerySet.order_by() regression with an M2M through model. 2016-01-20 19:13:05 -05:00
Simon Charette bc7d201bdb Fixed #25858 -- Bound abstract model application relative relationships.
Thanks to Karl Hobley for the report and Markus, Shai, Aymeric for their input
and Tim for the review.
2016-01-11 12:23:23 -05:00
Anderson Resende b5f8c81ce1 Fixed #26026 -- Fixed isinstance crash comparing EmptyQuerySet to non-QuerySet. 2016-01-07 10:57:05 -05:00
Simon Charette 7bb373e309 Refs #25746 -- Added a test utility to isolate inlined model registration.
Thanks to Tim for the review.
2016-01-06 20:00:07 -05:00
varunnaganathan 3eba9638ee Fixed #25316 -- Fixed a crash with order_by() and values() after annotate(). 2016-01-02 07:06:54 -05:00
Marten Kenbeek 16411b8400 Fixed #26013 -- Moved django.core.urlresolvers to django.urls.
Thanks to Tim Graham for the review.
2015-12-31 14:21:29 -05:00
Bryan Marty 62ca2dea04 Fixed #8065 -- Made id_list an optional argument for QuerySet.in_bulk(). 2015-12-26 17:57:19 -05:00
Alexander Sosnovskiy 2a7ce34600 Fixed #14286 -- Added models.BigAutoField. 2015-12-25 20:01:31 -05:00
Varun Sharma 692d055890 Fixed #25984 -- Corrected RuntimeError message in ModelBase.__new__(). 2015-12-24 16:44:58 -05:00
Chris Lamb 77b8d8cb6d Discouraged use of /tmp with predictable names.
The use of predictable filenames in /tmp often leads to symlink attacks
so remove the most obvious use of them in the docs.
2015-12-24 09:54:33 -05:00
Luis San Pablo a856555df2 Fixed #25981 -- Added need to update migrations to on_delete deprecation warning. 2015-12-24 08:08:22 -05:00
Tomo Otsuka 8b6974a685 Fixed #25972 -- Restored support for the isnull lookup with ForeignObject. 2015-12-24 07:33:55 -05:00
Ian Foote 86eccdc8b6 Fixed #25544 -- Removed duplicate ids in prefetch_related() queries. 2015-12-17 19:08:30 -05:00
Sergey Fedoseev ed1bcf0515 Refs #25894 -- Fixed evaluation of zero-length slices of QuerySet.values() on Oracle. 2015-12-17 17:07:10 -05:00
Sergey Fedoseev 69b69f6d60 Fixed #25894 -- Fixed evaluation of zero-length slices of QuerySet.values(). 2015-12-15 07:29:35 -05:00
Ed Bartosh 423b3afce4 Fixed #25939 -- Removed redundant transaction in QuerySet.update_or_create().
There is no need to wrap the save() call in transaction.atomic() as
it's already done down the call stack in Model.save_base().
2015-12-14 19:41:11 -05:00
Simon Charette 8035cee922 Fixed #25882 -- Prevented fast deletes matching no rows from crashing on MySQL.
Thanks to Trac aliases gerricom for the report, raphaelmerx for the
attempts to reproduce and Sergey Fedoseev and Tim for the review.

Refs #16891
2015-12-14 13:12:36 -05:00
Attila Tovt 6f229048dd Fixed #25547 -- Made Model.refresh_from_db() update FileField's instance. 2015-12-05 17:23:13 -05:00
Alexander Sosnovskiy b61eab18f7 Fixed #13774 -- Added models.Field.rel_db_type(). 2015-12-04 07:55:41 -05:00
Josh Soref 93452a70e8 Fixed many spelling mistakes in code, comments, and docs. 2015-12-03 12:48:24 -05:00
Claude Paroz 68554d1676 Fixed #13427 -- Made auto-m2m verbose names translatable 2015-11-21 18:09:57 +01:00
Tim Graham 54e2e688e1 Fixed #25715 -- Fixed Model.refresh_from_db() with ForeignKey w/on_delete=SET_NULL. 2015-11-21 10:34:01 -05:00
Dmitry Dygalo 92eced62cd Simplified lists creation in three places. 2015-11-17 07:58:49 -05:00
Patryk Zawadzki 7628f87e2b Fixed #25750 -- Made Options._expire_cache() faster
Avoided unnecessary list operations and delattr() calls that result
in an exception being raised as it causes call frame reconstruction
which is very costly, especially so in a function that is called
millions of times.
2015-11-14 16:43:46 -05:00
Simon Charette c550beb0cc Fixed #25723 -- Made related field checks lookup against their local apps. 2015-11-11 19:33:54 -05:00
Razzi Abuissa c819780d3f Removed gendered pronoun in a code comment. 2015-11-11 17:07:13 -05:00
Simon Charette 4a9c32f5ee Refs #25693 -- Avoided redundant calls to get_fields() in `to_attr` validation. 2015-11-11 12:25:10 -05:00
Simon Charette 4cd5d846d4 Fixed #25730 -- Made Model.__str__() always return str instances.
Thanks to Kevin Turner for the report and Tim for the review.
2015-11-11 12:18:52 -05:00
Ian Foote 4608573788 Fixed #25693 -- Prevented data loss with Prefetch and ManyToManyField.
Thanks to Jamie Matthews for finding and explaining the bug.
2015-11-10 12:12:07 -05:00
Laura Feier 7862cbda86 Fixed #24576 -- Made deletion of related objects deterministic. 2015-11-09 15:04:48 -05:00
Dmitry Dygalo 917100eed7 Simplified dict initialization in two places. 2015-11-07 21:46:46 +01:00
Sergey Fedoseev 0a26121797 Refs #25629 -- Added `arity` class attribute to `Func` expressions 2015-11-02 20:09:21 +01:00
Ian Foote 32ef48aa56 Fixed #25609 -- Fixed regression in related field nested lookup error. 2015-10-27 13:49:00 -04:00
Simon Charette 976bd519a8 Revert "Fixed #25417 -- Added a field check for invalid default values."
This reverts commit 71ebcb85b9.
2015-10-27 11:02:35 -04:00
Tim Graham 9c5e272860 Fixed #25550 -- Deprecated direct assignment to the reverse side of a related set. 2015-10-27 07:57:15 -04:00
Tim Graham 0b5d32faca Fixed #25611 -- Standardized descriptor signatures. 2015-10-26 11:31:16 -04:00
Simon Charette 3db3ab71e9 Fixed #25563 -- Cached deferred models in their proxied model's _meta.apps.
Thanks to Andriy Sokolovskiy for the report and Tim Graham for the review.
2015-10-19 20:11:32 -04:00
Josh Smeaton 6c95b134e9 Fixed #25517 -- Made Concat function idempotent on SQLite. 2015-10-17 15:51:04 -04:00
Simon Charette c1b6a8a98b Fixed #25560 -- Made empty string related_name invalid.
Thanks to Ali Lotfi for the initial report and patch
and Tim Graham for the review.
2015-10-16 14:22:15 -04:00
Antoine Catton b971c1cd78 Fixed #25506 -- Allowed filtering over a RawSQL annotation.
Co-Authored-By: Gavin Wahl <gwahl@fusionbox.com>
2015-10-14 11:13:58 -07:00
Tim Graham c7aff31397 Refs #25535 -- Minor edits to ForeignObject check changes. 2015-10-14 05:21:08 -07:00
Antoine Catton 80dac8c33e Fixed #25535 -- Made ForeignObject checks less strict.
Check that the foreign object `from_fields` are a subset of any unique
constraints on the foreign model.
2015-10-12 18:00:59 -04:00
Simon Charette a82e21b0f9 Refs #18012 -- Removed the now unused proxied_children model option.
Thanks to Tim for the review.
2015-10-12 12:14:27 -04:00
Simon Charette 5b980897f2 Refs #18012 -- Made proxy and concrete model reverse fields consistent.
Prior to this change proxy models reverse fields didn't include the
reverse fields pointing to their concrete model.
2015-10-12 12:14:27 -04:00
Simon Charette 211486f3ab Fixed #23076, #25505 -- Fixed deletion of intermediate proxy models.
Thanks to James Murty for his work on an alternate patch.
2015-10-12 12:14:26 -04:00
Simon Charette 8bdfabed65 Refs #18012 -- Removed special casing for proxy models deletion.
This isn't required anymore now that reverse foreign keys
from proxy models are propagated to their concrete model.
2015-10-12 12:14:26 -04:00
Simon Charette 6c9f37ea9e Fixed #18012 -- Propagated reverse foreign keys from proxy to concrete models.
Thanks to Anssi for the review.
2015-10-12 12:14:26 -04:00
Tim Graham 67732a9b18 Fixed #24687 -- Added select_related() validation for nested non-relational fields.
The removed test was added in the original select_related() validation
patch (45d4e43d2d), but there doesn't
seem to be any reason for it.

Thanks Claude Paroz for help and review.
2015-10-10 09:48:50 -04:00
Tim Graham 384ddbec1b Fixed #14368 -- Allowed setting a reverse OneToOne relation to None. 2015-10-09 10:20:53 -04:00
Mariusz Felisiak 914167abf1 Fixed #25503 -- Fixed system check crash on ForeignKey to abstract model. 2015-10-06 19:22:37 -04:00
Tim Graham e0837f2cb1 Fixed #25508 -- Modified QuerySet.__repr__() to disambiguate it from a list. 2015-10-06 12:38:34 -04:00
Tim Graham ea8e7fd989 Removed obsolete (since Python 2.3) __safe_for_unpickling__ attribute. 2015-10-05 08:07:27 -04:00
Tim Graham 9f6b704769 Fixed #21042 -- Allowed accessing FileDescriptor on the model class.
This is consistent with ability to reference other descriptors
on the model class (5ef0c03ae9).
2015-10-01 15:19:39 -04:00
Tim Graham 1f84721fac Removed unused Aggregate.input_field.
Obsolete since 4a66a69239.
2015-09-24 09:15:56 -04:00
Tim Graham a780505f3a Refs #14030 -- Removed more backwards compatiblity for old-style aggregates.
Per deprecation timeline.
2015-09-24 09:15:55 -04:00
Tim Graham 96317ad8de Refs #21414 -- Removed Field.related per deprecation timeline. 2015-09-23 19:31:10 -04:00
Tim Graham fd6a299cd0 Refs #14030 -- Removed backwards compatiblity for old-style aggregates.
Per deprecation timeline.
2015-09-23 19:31:10 -04:00
Tim Graham 1bb6ecf6d3 Refs #9893 -- Removed shims for lack of max_length support in file storage per deprecation timeline. 2015-09-23 19:31:10 -04:00
Tim Graham 3f50dc2be5 Removed SQLCompiler.__call__() per deprecation timeline. 2015-09-23 19:31:09 -04:00
Tim Graham c64dd646f5 Refs #12663 -- Removed deprecated Model._meta methods. 2015-09-23 19:31:09 -04:00
Tim Graham 08ab262649 Removed SubfieldBase per deprecation timeline. 2015-09-23 19:31:09 -04:00
Alex Hill 134ca4d438 Fixed #24509 -- Added Expression support to SQLInsertCompiler 2015-09-22 23:35:24 +10:00
Aymeric Augustin 361254810e Documented "rel objects".
Kept the docstring short because these objects aren't very well defined
and they're in the crosshairs of several refactorings.
2015-09-21 22:20:42 +02:00
Aymeric Augustin e542e81b39 Renamed descriptor classes for related objects.
The old names were downright confusing. Some seemed to mean the opposite
of what the class actually did.

The new names follow a consistent nomenclature:

    (Forward|Reverse)(ManyToOne|OneToOne|ManyToMany)Descriptor.

I mentioned combinations that do not exist in the docstring in order to
help people who would search for them in the code base.
2015-09-21 22:20:42 +02:00
Aymeric Augustin 2409a4241a Added comments in related instances descriptors. 2015-09-21 22:06:04 +02:00
Aymeric Augustin 497d915299 Documented related models descriptors.
Changed the poll / choices example to a more obvious parent / children.
I think that reduces the cognitive load.
2015-09-21 22:06:03 +02:00
Aymeric Augustin 005c9fc45f Fixed #22341 -- Split django.db.models.fields.related.
At 2800 lines it was the largest module in the django package. This
commit brings it down to a more manageable 1620 lines.

Very small changes were performed to uniformize import style.
2015-09-21 22:05:30 +02:00
Josh Smeaton 534aaf56f4 Fixed #24629 -- Unified Transform and Expression APIs 2015-09-21 19:56:24 +10:00
Raphael Merx f5a33e4840 Fixed #25296 -- Prevented model related object cache pollution when create() fails due to an unsaved object. 2015-09-19 20:49:13 -04:00
Aymeric Augustin c3904deb91 Fixed #25160 (again) -- Moved data loss check on reverse relations.
Moved data loss check when assigning to a reverse one-to-one relation on
an unsaved instance to Model.save(). This is exactly the same change as
e4b813c but for reverse relations.
2015-09-19 20:27:53 +02:00
Simon Charette 71ebcb85b9 Fixed #25417 -- Added a field check for invalid default values. 2015-09-18 14:31:36 -04:00
Iulia Chiriac 75ed590032 Fixed #24636 -- Added model field validation for decimal places and max digits. 2015-09-18 14:30:20 -04:00
Simon Charette 4d886db078 Removed the unused JoinPromoter.outer_votes attribute. 2015-09-17 13:47:06 -04:00
Adam Chainz 3fe3887a2e Fixed #25377 -- Changed Count queries to execute COUNT(*) instead of COUNT('*'). 2015-09-14 13:41:35 -04:00
Dražen Odobašić b1e33ceced Fixed #23395 -- Limited line lengths to 119 characters. 2015-09-12 11:40:50 -04:00
Nick Pope 1743efbe62 Fixed typos in django/db/models/query.py docstrings. 2015-09-07 15:47:02 -04:00
Tim Graham 2dc9ec5616 Fixed #24525 -- Fixed AssertionError in some complex queries.
Thanks Anssi Kääriäinen for providing the solution.
2015-09-05 07:51:17 -04:00
Tim Graham 233b46f931 Fixed #19263 -- Fixed crash when filtering using __in and an empty QuerySet.
Thanks Marcin Biernat for the initial patch and tests.
2015-09-04 07:44:36 -04:00
sarthakmeh 40bf18e702 Fixed #25058 -- Added GenericRelations with related_query_name to the admin's delete confirmation page. 2015-09-03 10:08:51 -04:00
Gavin Wahl 627c7eb7bf Fixed #25335 -- Fixed regression where QuerySet.iterator() didn't return an iterator. 2015-09-03 07:35:22 -04:00
Tim Graham 0e925de245 Removed obsolete TODO about moving CommaSeparatedIntegerField into contrib. 2015-09-01 09:13:20 -04:00
Tim Graham 064d4b1cb0 Fixed #25320 -- Reverted ManyToManyField.null to False for backwards compatibility.
Thanks Tom Christie for the report and review.
2015-09-01 07:59:39 -04:00
Maxime Lorant 5153a3bfdc Fixed #25331 -- Removed trailing blank lines in docstrings. 2015-08-31 17:37:21 -04:00
Y3K cbcf78fa94 Fixed #25252 -- Added friendly error message on incorrect .select_related() use
Using select_related() after .values() or .values_list() is not possible
because .values() or .values_list() already got the values they need.
2015-08-31 15:13:59 +10:00
Alex Hill 7bec480fe2 Fixed #24201 -- Added order_with_respect_to support to GenericForeignKey. 2015-08-27 09:20:17 -04:00
Markus Holtermann e1427cc609 Fixed #24590 -- Cached calls to swappable_setting.
Moved the lookup in Field.swappable_setting to Apps, and added
an lru_cache to cache the results.

Refs #24743

Thanks Marten Kenbeek for the initial work on the patch. Thanks Aymeric
Augustin and Tim Graham for the review.
2015-08-27 17:06:21 +10:00
sarthakmeh 4bc00defd0 Fixed #14217 -- Added validation for field name collision when using model inheritance. 2015-08-25 16:16:54 -04:00
Tim Graham 333cbdcd2d Fixed #24951 -- Fixed AssertionError in delete queries involving a foreign/primary key.
Thanks Anssi Kääriäinen for help.
2015-08-20 08:14:16 -04:00
Valentina Mukhamedzhanova 1f7b25c1a7 Fixed #24986 -- Added support for annotations in DISTINCT queries. 2015-08-15 08:23:32 -04:00
Alex Hill 98bcdfa8bd Fixed #25064 -- Allowed empty join columns. 2015-08-15 07:26:44 -04:00
Valentina Mukhamedzhanova 6bd7ee4eab Made Options.get_base_chain() always return a list. 2015-08-14 13:15:31 -04:00
Ion Scerbatiuc 0cc059cd10 Fixed #25172 -- Fixed check framework to work with multiple databases. 2015-08-12 18:00:26 -04:00
Tim Graham 5980b05c1f Fixed #25160 -- Moved unsaved model instance data loss check to Model.save()
This mostly reverts 5643a3b51b and
81e1a35c36.

Thanks Carl Meyer for review.
2015-08-10 08:51:32 -04:00
Tim Graham 770449e24b Removed unused Field.get_flatchoices() method.
Unused since c2ba59fc1d (Django 1.0).

Thanks Andy Baker for the report.
2015-08-03 13:08:24 -04:00
risicle 5d60d2b457 Adjusted SQLCompiler.get_order_by()'s docstring return value. 2015-07-28 10:49:26 -04:00
Tim Graham adc0c4fbac Fixed #18556 -- Allowed RelatedManager.add() to execute 1 query where possible.
Thanks Loic Bistuer for review.
2015-07-28 09:28:25 +07:00
Flavio Curella c2e70f0265 Fixed #21127 -- Started deprecation toward requiring on_delete for ForeignKey/OneToOneField 2015-07-27 18:28:13 -04:00