Commit Graph

2697 Commits

Author SHA1 Message Date
Simon Charette f19a4945e1 Fixed #21703 -- Fixed a crash when excluding a related field with a F(). 2019-03-23 09:48:28 -04:00
Matthias Kestenholz ea071870f9 Fixed #30280 -- Restored Model.get_FIELD_display()'s coercion of lazy strings.
Reverted cc79c7ee63.
2019-03-22 12:30:10 -04:00
Nick Pope d26b242443
Fixed #30271 -- Added the Sign database function. 2019-03-22 12:52:39 +01:00
Simon Charette 5935a9aead Removed obsolete Lookup hook to prepare rhs expressions.
After 3a505c70e7, all _prepare() methods
return self.
2019-03-21 20:54:21 -04:00
Simon Charette 3a505c70e7 Refs #27149, #29542 -- Simplified subquery parentheses wrapping logic. 2019-03-21 20:42:26 -04:00
Simon Charette 3543129822 Refs #27149 -- Moved subquery expression resolving to Query.
This makes Subquery a thin wrapper over Query and makes sure it respects
the Expression source expression API by accepting the same number of
expressions as it returns. Refs #30188.

It also makes OuterRef usable in Query without Subquery wrapping. This
should allow Query's internals to more easily perform subquery push downs
during split_exclude(). Refs #21703.
2019-03-21 20:36:31 -04:00
Simon Charette 96b6ad94d9 Refs #27149 -- Made Subquery store Query instead of Queryset.
Subquery only uses Query.
2019-03-21 20:02:51 -04:00
Simon Charette fb3f034f1c Fixed #30158 -- Avoided unnecessary subquery group by on aggregation.
Subquery annotations can be omitted from the GROUP BY clause on aggregation
as long as they are not explicitly grouped against.

Thanks Jonny Fuller for the report.
2019-03-21 18:48:41 -04:00
Simon Charette 9dc367dc10 Refs #30158 -- Added alias argument to Expression.get_group_by_cols(). 2019-03-21 18:47:46 -04:00
Nick Pope 0b70985f42 Fixed #30240 -- Added SHA1, SHA224, SHA256, SHA384, and SHA512 database functions.
Thanks Mariusz Felisiak and Tim Graham for reviews.
2019-03-20 19:30:43 +01:00
Matt Westcott 58ad030d05 Fixed #30254 -- Allowed model metaclasses to access the attribute dict in __init__().
Regression in a68ea23101.
2019-03-14 21:05:23 -04:00
ahbk d527639804 Fixed #29754 -- Added is_dst parameter to Trunc database functions. 2019-03-07 10:02:18 -05:00
avas9366 9681e968eb Fixed #30232 -- Corrected expected format in invalid DurationField error message. 2019-03-04 19:25:27 -05:00
Mariusz Felisiak f69c7bbdce
Refs #29408 -- Cosmetic edits for validation of related fields and lookups in model Meta.ordering.
Follow up to 440505cb2c.
2019-03-01 19:38:21 +01:00
Hasan Ramezani 440505cb2c Fixed #29408 -- Added validation of related fields and lookups in model Meta.ordering. 2019-03-01 17:09:33 +01:00
Simon Charette de7f6b51b2 Refs #19544 -- Added a fast path for through additions if supported.
The single query insertion path is taken if the backend supports inserts
that ignore conflicts and m2m_changed signals don't have to be sent.
2019-02-21 10:20:47 -05:00
Simon Charette 28712d8acf Refs #19544 -- Ignored auto-created through additions conflicts if supported.
This prevents IntegrityError caused by race conditions between missing ids
retrieval and bulk insertions.
2019-02-21 10:20:47 -05:00
Simon Charette dd32f9a3a2 Refs #19544 -- Extracted ManyRelatedManager.add() missing ids logic to a method. 2019-02-21 10:20:47 -05:00
Mariusz Felisiak 9ff18c08c3
Refs #28643 -- Added MD5 database function.
Thanks Tim Graham, Nick Pope and Simon Charette for reviews.
2019-02-21 10:52:51 +01:00
Hasan Ramezani 741ce81a42 Fixed #29619 -- Added field names to some FieldErrors. 2019-02-14 18:58:08 -05:00
Dan Davis 2bd8df243a Fixed #30184 -- Removed ellipsis characters from shell output strings.
Partially reverted 50b8493581 (refs #29654)
to avoid a crash when the user shell doesn't support non-ASCII characters.
2019-02-13 13:59:44 -05:00
Simon Charette 64d5bafbc6 Fixed #30027 -- Errored out on Window function usage if unsupported. 2019-02-09 08:47:41 -05:00
Sergey Fedoseev eefc9550fd Simplified Window.as_sql(). 2019-02-09 08:41:35 -05:00
Nick Pope 24b82cd201 Fixed #30159 -- Removed unneeded use of OrderedDict.
Dicts preserve order since Python 3.6.
2019-02-06 13:48:39 -05:00
Tim Graham d47498c5df Fixed #30156 -- Dropped support for SpatiaLite 4.1 and 4.2. 2019-02-04 13:16:38 -05:00
Johannes Hoppe b131f9c79f Refs #29444 -- Renamed DatabaseFeatures.can_return_id* to be generic for other columns. 2019-01-30 15:31:56 -05:00
Joshua Cannon 16a5a2a2c8 Fixed #30076 -- Added Model.get_FOO_display() even if field's choices are empty. 2019-01-30 13:44:10 -05:00
Mariusz Felisiak 5a5c77d55d
Fixed E117 and F405 flake8 warnings. 2019-01-30 13:06:09 +01:00
Jon Dufresne 7e3bf2662b Removed default mode='r' argument from calls to open(). 2019-01-27 17:41:43 -05:00
Simon Charette 8d2dcc47cd Fixed #30106 -- Made order_with_respect_to updates use QuerySet.bulk_update(). 2019-01-21 17:02:20 -05:00
Simon Charette 65858119d2 Fixed #30120 -- Fixed invalid SQL in distinct aggregate.
Regression in bc05547cd8 (refs #28658).
2019-01-21 09:24:32 -05:00
Tim Graham da1de1615c Refs #28750 -- Removed suppport for model Meta.manager_inheritance_from_future. 2019-01-17 11:15:27 -05:00
Tim Graham 1fecde6be9 Refs #11557 -- Removed the field_name keyword argument to QuerySet.earliest() and latest().
Per deprecation timeline.
2019-01-17 10:52:19 -05:00
Tim Graham da5eb3d56c Refs #28370 -- Removed support for the context arg of Field.from_db_value() and Expression.convert_value().
Per deprecation timeline.
2019-01-17 10:52:19 -05:00
Simon Charette 9e5e5a657b Fixed #30044 -- Raised a FieldError on inherited field update attempts. 2019-01-16 14:09:51 -05:00
Simon Charette dbcf2ffa77 Refs #9475 -- Simplified dictionary unpacking. 2019-01-16 09:20:15 -05:00
Nick Pope d212bc03ba Refs #9475 -- Fixed typo, used unpacking generalization, and made through_defaults kwarg-only. 2019-01-15 13:03:08 -05:00
Collin Anderson 769355c765 Fixed #9475 -- Allowed RelatedManager.add(), create(), etc. for m2m with a through model. 2019-01-15 11:12:17 -05:00
Nasir Hussain f021c110d0 Fixed #30099 -- Fixed invalid SQL when filtering a Subquery by an aggregate. 2019-01-15 07:22:59 -05:00
Jon Dufresne ad7aa02c1d Removed unnecessary string formatting of strings. 2019-01-14 21:04:00 -05:00
Nick Pope 846624ed08 Refs #28643 -- Extracted DurationField logic for Avg() and Sum() into mixin.
Also addresses Sum() not handling the filter option correctly.
2019-01-14 14:39:57 -05:00
Nick Pope 6d4efa8e6a Refs #28643 -- Changed Variance() to use NumericOutputFieldMixin.
Keeps precision instead of forcing DecimalField to FloatField.
2019-01-14 14:39:46 -05:00
Nick Pope e85afa5943 Refs #28643 -- Changed StdDev() to use NumericOutputFieldMixin.
Keeps precision instead of forcing DecimalField to FloatField.
2019-01-14 14:38:00 -05:00
Nick Pope c690afb873 Refs #28643 -- Changed Avg() to use NumericOutputFieldMixin.
Keeps precision instead of forcing DecimalField to FloatField.
2019-01-14 14:35:41 -05:00
Nick Pope 3d5e0f8394 Refs #28643 -- Moved db function mixins to a separate module. 2019-01-14 14:26:46 -05:00
Nick Pope 7f1577d1ef Avoided calling as_oracle() for SQLite in Left database function. 2019-01-14 13:02:58 -05:00
Nick Pope ae65eed68d Corrected comment in TruncTime database function. 2019-01-14 13:02:58 -05:00
Nick Pope 0d7ba0ff8b Simplified overriding source expressions in some database functions. 2019-01-14 13:02:58 -05:00
Sergey Fedoseev b86bb47818 Fixed #30093 -- Fixed ordering of combined queryset ordered by F expressions. 2019-01-14 10:28:11 -05:00
Nick Pope abf8e390a4 Refs #28643 -- Added Reverse database function.
Thanks Mariusz Felisiak for Oracle advice and review.
2019-01-12 10:45:48 -05:00
Paveł Tyślacki b69f8eb04c Fixed #30062 -- Added support for unique conditional constraints. 2019-01-12 09:50:20 -05:00
Paveł Tyślacki 1e837c4b23 Used None as the empty value for condition in Index's SQL construction. 2019-01-12 09:34:10 -05:00
Tim Graham 8f4eee1777
Moved django.db.migrations.writer.SettingsReference to django.conf.
Reduces the possibility of circular imports.
2019-01-11 15:28:22 -05:00
Mads Jensen 4b9d72210f Refs #28643 -- Added NullIf database function.
Thanks Nick Pope, Mariusz Felisiak, and Tim Graham for reviews.
2019-01-10 12:10:12 -05:00
Simon Charette bc05547cd8 Fixed #28658 -- Added DISTINCT handling to the Aggregate class. 2019-01-09 17:52:36 -05:00
Nick Pope 99b3ab2781 Simplified some imports for database functions.
Used more specific modules to reduce the risk of circular imports.
2019-01-08 19:21:31 -05:00
Tim Graham 0004daa536
Used 4 space hanging indent for dictionaries.
Thanks Mariusz Felisiak for auditing.
2019-01-02 18:18:19 -05:00
Paveł Tyślacki 0123b67f6b Fixed #30060 -- Moved SQL generation for indexes and constraints to SchemaEditor. 2019-01-01 09:39:58 -05:00
Tim Graham 100b8dd163
Renamed QuerySet.earliest()/latest() helper method. 2018-12-30 11:43:39 -05:00
Mariusz Felisiak dd8ed64113
Fixed #29851 -- Fixed crash of annotations with window expressions in Subquery. 2018-12-27 20:21:57 +01:00
Sergey Fedoseev a68ea23101 Fixed #29970, #30041 -- Made ModelBase.__new__() pass attrs without contribute_to_class() to type.__new__(). 2018-12-22 18:11:24 -05:00
Mariusz Felisiak f9a33e3c3f Fixed #29932 -- Fixed combining compound queries with sub-compound queries on SQLite and Oracle. 2018-12-06 15:31:33 -05:00
Simon Charette 53269bcaaf Fixed #30011 -- Fixed queries that reuse filtered aggregates.
Thanks Taqi Abbas and Raphael Kimmig for the report.
2018-12-06 14:55:35 -05:00
Nick Pope c3bbf1fd4c Refs #28643 -- Skipped ATan2() workaround on SpatiaLite 5+. 2018-11-30 13:59:05 -05:00
Prabakaran Kumaresshan 0d724ce916 Fixed #30001 -- Marked UUIDField.description for translation. 2018-11-30 11:23:17 -05:00
Nick Pope c512912463 Refs #23801 -- Made integer field max_length warning show correct field type. 2018-11-23 14:40:46 -05:00
Nick Pope 856ba1ec86 Removed redundant BigIntegerField.empty_strings_allowed (already inherited). 2018-11-23 14:22:58 -05:00
Tom Forbes 31408446b3 Fixed #29974 -- Fixed non-truthy primary key values for QuerySet.bulk_update(). 2018-11-21 22:58:43 -05:00
Mariusz Felisiak d5f4ce9849
Fixed #29949 -- Refactored db introspection identifier converters.
Removed DatabaseIntrospection.table_name_converter()/column_name_converter()
and use instead DatabaseIntrospection.identifier_converter().

Removed DatabaseFeatures.uppercases_column_names.

Thanks Tim Graham for the initial patch and review and Simon Charette
for the review.
2018-11-21 09:06:50 +01:00
Simon Charette 0cf85e6b07 Refs #29908 -- Optimized known related objects assignment.
Since CPython implements a C level attrgetter(*attrs) it even outperforms the
most common case of a single known related object since the resulting attribute
values tuple is built in C.
2018-11-17 18:56:11 -05:00
Ian Foote e1fc07c047 Fixed #17930 -- Allowed ORing (|) with sliced QuerySets. 2018-11-15 09:43:58 -05:00
Hasan Ramezani 6d4e5feb79 Fixed #29835 -- Made RelatedFieldListFilter respect ModelAdmin.ordering. 2018-11-14 14:29:39 -05:00
Simon Charette db13bca60a Fixed #29641 -- Added support for unique constraints in Meta.constraints.
This constraint is similar to Meta.unique_together but also allows
specifying a name.

Co-authored-by: Ian Foote <python@ian.feete.org>
2018-11-13 17:57:27 -05:00
Simon Charette dba4a634ba Refs #29641 -- Refactored database schema constraint creation.
Added a test for constraint names in the database.

Updated SQLite introspection to use sqlparse to allow reading the
constraint name for table check and unique constraints.

Co-authored-by: Ian Foote <python@ian.feete.org>
2018-11-13 15:25:44 -05:00
Simon Charette 75dfa92a05 Fixed #29908 -- Fixed setting of foreign key after related set access if ForeignKey uses to_field.
Adjusted known related objects handling of target fields which relies on
from and to_fields and has the side effect of fixing a bug bug causing
N+1 queries when using reverse foreign objects.

Thanks Carsten Fuchs for the report.
2018-11-08 19:51:15 -05:00
Mads Jensen a906c98982 Fixed #29547 -- Added support for partial indexes.
Thanks to Ian Foote, Mariusz Felisiak, Simon Charettes, and
Markus Holtermann for comments and feedback.
2018-10-29 19:34:54 -04:00
Tim Graham f77fc56c96
Fixed #29896 -- Fixed incorrect Model.save() cache relation clearing for foreign keys that use to_field.
Regression in ee49306176.
2018-10-28 22:54:02 -04:00
Sanyam Khurana 83c7096f2a Fixed #29869 -- Made UUIDField.to_python() convert integers. 2018-10-24 20:26:57 -04:00
Simon Charette 5e3463f6bc Fixed #27595 -- Made ForeignKey.get_col() follow target chains.
Previously, foreign relationships were followed only one level deep which
prevents foreign keys to foreign keys from being resolved appropriately.
This was causing issues such as improper database value conversion for
UUIDField on SQLite because the resolved expression's output field's
internal type wasn't correct. Added tests to make sure unlikely foreign
reference cycles don't cause recursion errors.

Refs #24343.

Thanks oyooyo for the report and Wayne Merry for the investigation.
2018-10-22 09:49:34 -04:00
aspalding 834c4ec8e4 Moved make_hashable() to django.utils and added tests. 2018-10-17 11:17:23 -04:00
Florian Apolloner bc7dd8490b Fixed #21171 -- Avoided starting a transaction when a single (or atomic 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.
2018-10-17 12:19:02 +02:00
oliver 1299421cad Fixed #29725 -- Removed unnecessary join in QuerySet.count() and exists() on a many-to-many relation. 2018-10-15 11:01:57 -04:00
Jon Dufresne 1e87c9fe71 Replaced kwargs.pop() with keyword-only arguments. 2018-10-08 15:06:02 -04:00
Jon Dufresne 2ba588e773 Refs #27795 -- Removed force_text() usage in db/models/sql/query.py. 2018-10-08 14:47:01 -04:00
Simon Charette bc7e288ca9 Fixed #29745 -- Based Expression equality on detailed initialization signature.
The old implementation considered objects initialized with an equivalent
signature different if some arguments were provided positionally instead of
as keyword arguments.

Refs #11964, #26167.
2018-10-02 19:15:20 -04:00
Simon Charette 24dc7d8940 Refs #29641 -- Extracted reusable CheckConstraint logic into a base class. 2018-10-02 13:11:18 -04:00
Simon Charette 9142bebff2 Refs #11964 -- Changed CheckConstraint() signature to use keyword-only arguments.
Also renamed the `constraint` argument to `check` to better represent which
part of the constraint the provided `Q` object represents.
2018-10-02 10:53:04 -04:00
Jon Dufresne 0bf7b25f8f Added django.db.backends.utils.names_digest() to remove redundant code. 2018-10-02 10:41:43 -04:00
Abhinav Patil bf01994a5c Fixed #29804 -- Added 'did you mean' suggestions for unsupported lookup error. 2018-10-01 19:03:10 -04:00
Claude Paroz fc3a463048 Fixed #29767 -- Made date-related casts work on SQLite
Thanks Rémy Hubscher for the report and Tim Graham and Simon Charette for the reviews.
2018-10-01 13:27:30 +02:00
Sergey Fedoseev 8ef8bc0f64 Refs #28909 -- Simplifed code using unpacking generalizations. 2018-09-28 09:57:12 -04:00
Jon Dufresne 8c3e0eb1c1 Normalized spelling of "lowercase" and "lowercased". 2018-09-25 10:30:18 -04:00
Tom Forbes 9cbdb44014 Fixed #23646 -- Added QuerySet.bulk_update() to efficiently update many models. 2018-09-18 16:14:44 -04:00
Ramiro Morales 1b1f64ee5a Refs #14357 -- Deprecated Meta.ordering affecting GROUP BY queries.
Thanks Ramiro Morales for contributing to the patch.
2018-09-13 12:29:48 -04:00
Srinivas Reddy Thatiparthy 34d6bceec4 Fixed #29500 -- Fixed SQLite function crashes on null values.
Co-authored-by: Srinivas Reddy Thatiparthy <thatiparthysreenivas@gmail.com>
Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
2018-09-10 15:08:55 -04:00
Alexander Holmbäck f315d0423a Fixed #29727 -- Made nonexistent joins in F() raise FieldError.
Regression in 2162f0983d.
2018-09-08 09:40:33 -04:00
Jon Dufresne cc79c7ee63 Refs #27795 -- Removed force_text() in Model._get_FIELD_display(). 2018-08-31 10:59:57 -04:00
Mariusz Felisiak 39461a83c3
Fixed #29694 -- Fixed column mismatch crash with QuerySet.values() or values_list() after combining querysets with extra() with union(), difference(), or intersection().
Regression in 0b66c3b442.
2018-08-29 10:00:15 +02:00
Jon Dufresne 90f3ef332b Refs #27795 -- Removed force_bytes()/smart_text() from model fields. 2018-08-28 07:56:18 -04:00
priyanshsaxena 83b04d4f88 Fixed #29048 -- Added **extra_context to database function as_vendor() methods. 2018-08-23 11:52:09 -04:00
Simon Willison 586a9dc429 Fixed #26352 -- Made system check allow ManyToManyField to target the same model if through_fields differs. 2018-08-22 12:07:29 -04:00
Franck Michea 7def8bed58 Fixed #29698 -- Fixed Field._check_choices() crash on invalid choices. 2018-08-22 09:15:19 -04:00
Claude Paroz 50b8493581 Refs #29654 -- Replaced three dots with ellipsis character in output strings. 2018-08-22 09:13:58 -04:00
Mariusz Felisiak ac29fec111
Removed unused function argument from Window.as_sql().
Unused since its introduction in d549b88050.
2018-08-20 22:16:27 +02:00
Ming Qin cfb4845f06 Fixed #29625 -- Made Model.refresh_from_db() clear prefetch related caches. 2018-08-20 12:01:42 -04:00
Sigurd Ljødal 3e09b37f80 Fixed #28649 -- Added ExtractIsoYear database function and iso_year lookup. 2018-08-18 13:09:15 -04:00
Srinivas Reddy Thatiparthy (శ్రీనివాస్ రెడ్డి తాటిపర్తి) 7eb556a6c2 Removed unused enumerate in django/db/models/sql/datastructures.py. 2018-08-13 18:41:24 -04:00
Ramiro Morales b5c7cb4d33 Fixed #29653 -- Fixed missing related_query_name reverse accessor if GenericRelation is declared on an abstract base model.
Regression in 4ab027b944.

Thanks Lauri Kainulainen for the report.
2018-08-10 12:17:26 -04:00
Raphael Michel 155b31d4ec Fixed #29648 -- Fixed crash when using subqueries inside datetime truncation functions. 2018-08-07 16:47:54 -04:00
Tom f1fbef6cd1 Fixed #28668 -- Allowed QuerySet.bulk_create() to ignore insert conflicts. 2018-08-03 17:40:46 -04:00
Michael Sanders 271542dad1 Fixed #29499 -- Fixed race condition in QuerySet.update_or_create().
A race condition happened when the object didn't already exist and
another process/thread created the object before update_or_create()
did and then attempted to update the object, also before update_or_create()
saved the object. The update by the other process/thread could be lost.
2018-08-02 17:07:48 -04:00
luz.paz 97e637a87f Fixed typos in comments and docs. 2018-08-01 16:09:22 -04:00
Tim Graham 4263cd0e09 Simplified comment in BooleanField.to_python(). 2018-08-01 11:52:02 -04:00
Andrew Brown 55810d94d0 Refs #29563 -- Fixed SQLCompiler.execute_sql() to respect DatabaseFeatures.can_use_chunked_reads. 2018-07-25 18:08:57 -04:00
François Dupayrat 861638a307 Fixed #29568 -- Prevented unnecessary UPDATE queries creating child models. 2018-07-20 08:59:15 -04:00
Mariusz Felisiak a73cf8110e Removed duplicate words in various comments. 2018-07-18 11:54:15 -04:00
Viktor Danyliuk 6ae7aaa7d6 Fixed #29413 -- Prevented evaluation of QuerySet.get_or_create()/update_or_create() defaults unless needed.
Removed the logic added in 81e05a418d which
was obsolete since dbffffa7dc.
2018-07-16 22:08:43 -04:00
Josh Schneier 4d48ddd8f9 Fixed #28917 -- Prevented Paginator's unordered warning on EmptyQuerySet.
Thanks carltongibson for the idea and weijunji for the initial patch.
2018-07-16 14:28:47 -04:00
Mariusz Felisiak dd3b470719
Fixed #29542 -- Fixed invalid SQL if a Subquery from the HAVING clause is used in the GROUP BY clause.
Thanks Tim Graham for the review.
2018-07-14 12:03:22 +02:00
Ian Foote 952f05a6db Fixed #11964 -- Added support for database check constraints. 2018-07-10 15:32:33 -04:00
Mads Jensen 8e4a75e5d5 Deleted unused variable in SQLCompiler.get_related_selections().
Unused since 01d440fa1e.
2018-07-10 09:15:19 -04:00
Mads Jensen f1fc7d6b78 Refs #26608 -- Removed unneeded name attribute in window functions. 2018-07-05 11:38:07 -04:00
Junyi Jiao a0b19a0f5b Refs #28643 -- Added math database functions.
Thanks Nick Pope for much review.
2018-07-05 11:02:12 -04:00
Mariusz Felisiak 0e64e046a4
Fixed #29530 -- Fixed aliases ordering when chaining annotate() and filter(). 2018-07-02 21:09:29 +02:00
Ian Foote 38cada7c94 Fixed #28077 -- Added support for PostgreSQL opclasses in Index.
Thanks Vinay Karanam for the initial patch.
2018-06-29 17:00:28 -04:00
Alexandr Tatarinov 7410618528 Fixed #29447 -- Made RelatedManager.set() pass bulk argument to clear(). 2018-06-25 13:04:46 -04:00
Tim Graham e7185a6514 Refs #29516 -- Reverted inadvertent change in Model.__init__(). 2018-06-25 09:39:16 -04:00
Federico Bond 4c36414323 Fixed #29517 -- Rephrased error message when passing incorrect kwarg to model constructor 2018-06-25 09:30:58 +02:00
Nick Pope b0fbfae093 Fixed #29503 -- Made __in lookup keep order of values in query.
Regression in 86eccdc8b6.
2018-06-20 09:29:06 -04:00
Tim Graham c03e41712b
Refs #28748 -- Reallowed lazy model field choices.
Regression in 3aa9ab39cc.
2018-05-29 21:43:38 -04:00
Paulo 6104875a2c Fixed #29230 -- Fixed nested prefetches that clash with descriptors. 2018-05-27 21:45:51 -04:00
Mariusz Felisiak 4ab1f559e8 Fixed #29416 -- Removed unnecesary subquery from GROUP BY clause on MySQL when using a RawSQL annotation.
Regression in 1d070d027c.
2018-05-27 18:25:19 -04:00
olivierdalang 825f0beda8 Fixed #8936 -- Added a view permission and a read-only admin.
Co-authored-by: Petr Dlouhy <petr.dlouhy@email.cz>
Co-authored-by: Olivier Dalang <olivier.dalang@gmail.com>
2018-05-16 06:44:55 -04:00
Paulo 265506bbc3 Refs #28834 -- Moved ancestor field cached value fallback to related fields descriptor. 2018-05-14 21:17:02 -04:00
Stefan R. Filipek a5a2ceeb45 Fixed #27629 -- Added router.allow_relation() calls for assignments between unsaved model instances. 2018-05-10 20:42:44 -04:00
Carlton Gibson 21fd8041c1
Refs #29358 -- Corrected wording in primary key check message. 2018-05-03 15:28:37 +02:00
Hasan Ramezani 816b8d9518 Fixed #29358 -- Added a system check to prohibit models with more than one primary_key field. 2018-05-03 09:08:29 +02:00
Oscar Esgalha 6d1f576945 Fixed #29367 -- Fixed model state on objects with a primary key created with QuerySet.bulk_create(). 2018-04-27 17:57:38 -04:00
orlnub123 21420096c4 Fixed #29247 -- Allowed blank model field choice to be defined in nested choices. 2018-04-20 11:06:14 -04:00
Adnan Umer 534d8d875e Fixed #28600 -- Added prefetch_related() support to RawQuerySet. 2018-04-19 13:48:27 -04:00
Adnan Umer f2026ca5e2 Fixed #29337 -- Added __len__() & __bool__() to RawQuerySet. 2018-04-19 12:46:31 -04:00
Adnan Umer ec0319ff82 Fixed #29339 -- Added result caching to RawQuerySet. 2018-04-19 11:35:49 -04:00
Tom c1c163b427 Fixed #28574 -- Added QuerySet.explain(). 2018-04-19 10:52:19 -04:00
Brett Cannon 64b74804c5 Fixed #29334 -- Updated pypi.python.org URLs to pypi.org. 2018-04-17 20:24:27 -04:00
Daniel Miller 60156750f6 Fixed #29330 -- Fixed crash when pickling BaseExpression.
Regression in cfff2af02b.
2018-04-16 10:15:13 -04:00
Mariusz Felisiak 0b66c3b442
Fixed #29286 -- Fixed column mismatch crash with QuerySet.values() or values_list() after combining an annotated and unannotated queryset with union(), difference(), or intersection().
Regression in a0c03c62a8.

Thanks Tim Graham and Carlton Gibson for reviews.
2018-04-13 12:15:52 +02:00
Flávio Juvenal e1f13f1551 Fixed #29320 -- Added an exception when an annotation alias matches a ForeignKey attname. 2018-04-12 21:15:40 -04:00
Dmitry Dygalo c979c0a2b8 Fixed #25718 -- Made a JSONField lookup value of None match keys that have a null value. 2018-04-04 10:53:46 -04:00
Mariusz Felisiak 55cc26941a
Refs #28643 -- Added Repeat database function.
Thanks Tim Graham and Nick Pope for reviews.
2018-04-03 19:36:12 +02:00
Mariusz Felisiak 6141c752fe
Fixed #29251 -- Added bytes to str conversion in LPad/RPad database functions on MySQL.
Thanks Tim Graham for the review.
2018-04-03 18:24:04 +02:00
Nick Pope 281c0223b3 Refs #29227 -- Simplified NullBooleanField by making it subclass BooleanField. 2018-03-20 12:10:10 -04:00
Tim Graham 5fa4f40f45 Fixed #29227 -- Allowed BooleanField to be null=True.
Thanks Lynn Cyrin for contributing to the patch, and Nick Pope for review.
2018-03-20 12:10:10 -04:00
Astral a0c03c62a8 Fixed #29229 -- Fixed column mismatch crash when combining two annotated values_list() querysets with union(), difference(), or intersection().
Regression in 7316720603821ebb64dfe8fa592ba6edcef5f3e.
2018-03-19 21:05:43 -04:00
Mariusz Felisiak cede5111bb
Refs #28643 -- Added LPad and RPad database functions.
Thanks Tim Graham for the review.
2018-03-19 17:35:16 +01:00
Mads Jensen 77609f922e Removed unused args in Index.clone(). 2018-03-17 15:42:09 -04:00
Mariusz Felisiak 9421aee35e
Refs #28643 -- Added LTrim, RTrim, and Trim database functions.
Thanks Tim Graham and Mads Jensen for reviews.
2018-03-15 20:57:23 +01:00
Mariusz Felisiak feb683c4c2
Fixed #29155 -- Fixed crash when database functions are used with pattern lookups.
Thanks Tim Graham and Sergey Fedoseev for reviews.
2018-03-14 10:00:07 +01:00
robwa 4ab027b944 Fixed #28988 -- Fixed queries when a GenericRelation is used with multi-table inheritance. 2018-03-12 22:42:48 -04:00
Simon Charette 3c71fb3909 Added PatternLookup.prepare_rhs to simplify subclasses. 2018-03-12 12:12:46 -04:00
Simon Charette 277ed07209 Fixed #29195 -- Fixed Exists.output_field resolution on single-valued queries.
The Subquery class which Exists inherits from defaulted to using single-valued
querie's field if no output_field was explicitly specified on initialization
which was bypassing the Exists.output_field defined at the class level.

Moving Subquery's dynamic output_field resolution to _resolve_output_field
should make sure the fallback logic is only performed if required.

Regression in 08654a99bb.

Thanks Oli Warner for the detailed report.
2018-03-08 13:30:41 -05:00
Fabrizio Ettore Messina 10c0fe528a Fixed #29178 -- Allowed Index.fields to accept a tuple. 2018-03-08 10:56:55 -05:00
Mariusz Felisiak 8b25d546b6 Simplified Contains, StartsWith, and EndsWith lookups. 2018-03-07 14:04:17 -05:00
Almad 3d8fadad0f Added model name to AutoField error message. 2018-03-03 13:22:00 -05:00
Tomáš Ehrlich fa352626c2 Fixed #29172 -- Fixed crash with Window expression in a subquery. 2018-03-01 10:24:14 -05:00
Mariusz Felisiak 54f80430be
Fixed #29166 -- Fixed crash in When() expression with a list argument.
Thanks Matthew Pava for the report and Tim Graham and Carlton Gibson for
reviews.
Regression in 19b2dfd1bf.
2018-02-28 18:05:23 +01:00
Mariusz Felisiak 074a2f7f58
Refs #28909 -- Simplifed code using unpacking generalizations. 2018-02-26 18:23:31 +01:00
bobort f82de6bfb1 Refs #28643 -- Added Ord, Chr, Left, and Right database functions. 2018-02-23 10:23:22 -05:00
Matthew Schinckel c412926a2e Fixed #29142 -- Fixed crash when OuterRef is used with an operator. 2018-02-23 09:38:16 -05:00
Oliver Sauder 6f0b8c1c9e Fixed #28442 -- Fixed crash with nested OuterRefs that reference AutoField. 2018-02-20 21:58:43 -05:00
Tim Graham 9ba3df8240 Refs #29125 -- Made Q.deconstruct() omit 'query_utils' in the path and _connector='AND' since it's a default value. 2018-02-12 15:23:41 -05:00
Tim Graham b95c49c954 Fixed #29125 -- Made Q.deconstruct() deterministic with multiple keyword arguments. 2018-02-12 14:52:32 -05:00
Matthew Wilkes 2162f0983d Fixed #24747 -- Allowed transforms in QuerySet.order_by() and distinct(*fields). 2018-02-10 19:08:55 -05:00
Raphael Gaschignard bf26f66029 Fixed #29118 -- Fixed crash with QuerySet.order_by(Exists(...)). 2018-02-10 18:35:57 -05:00
Simon Charette d61fe24601 Fixed #29108 -- Fixed crash in aggregation of distinct+ordered+sliced querysets.
Regression in 4acae21846.
Thanks Stephen Brooks for the report.
2018-02-08 09:59:25 -05:00
Raymond Hettinger aba9763b51 Refs #28814 -- Imported from collections.abc to fix Python 3.7 deprecation warnings.
https://bugs.python.org/issue25988
2018-02-05 11:42:47 -05:00
Jon Dufresne 8b21878357 Refs #28723 -- Fixed stale prefetch_related cache after add/remove.
Regression in 514b2c989a.
2018-02-05 11:02:57 -05:00
Tim Graham d0a42a14c0 Fixed imports per isort 4.3.1.
Partially reverted 9bcf73d788.
2018-02-02 14:44:07 -05:00
Mariusz Felisiak 9bcf73d788 Fixed imports per isort 4.3.0. 2018-02-01 09:29:46 +01:00
priyanshsaxena 617d5f410f Fixed #29066 -- Allowed negating query expressions. 2018-01-31 10:54:19 -05:00
Дилян Палаузов f427ffcccb Fixed #29093 -- Simplified a few lines in ModelBase.__new__(). 2018-01-31 10:22:56 -05:00
Jon Dufresne 136bf5c214 Fixed #29076 -- Made Model.refresh_from_db() clear cached relationships even if the related id doesn't change. 2018-01-30 10:43:53 -05:00
Sigurd Ljødal a455e732a0 Fixed #28650 -- Added TruncWeek database function. 2018-01-27 09:59:13 -05:00
François Freitag 3aa9ab39cc Refs #28748 -- Reallowed lazy values in model field choices.
Regression in f9844f4841.

Thanks Matthias Kestenholz for the report and suggestions.
2018-01-27 09:19:56 -05:00
Jon Dufresne 3187c89d6f Fixed #29067 -- Fixed regression in QuerySet.values_list(..., flat=True) followed by annotate(). 2018-01-26 09:35:50 -05:00
shanghui 8dc675d90f Fixed #28838 -- Fixed Model.save() crash if the base manager annotates with a related field. 2018-01-25 10:12:04 -05:00
François Freitag f9844f4841 Fixed #28748 -- Made model field choices check more strict for named groups. 2018-01-24 10:34:24 -05:00
Mads Jensen 65728550bd Refs #28643 -- Added Replace database function. 2018-01-17 20:46:15 -05:00
hayashi 27557a7a99 Fixed #28857 -- Fixed invalid SQL when using Cast with complex expressions on PostgreSQL. 2018-01-17 09:28:03 -05:00
Étienne Loks 9a621edf62 Fixed #29016 -- Fixed incorrect foreign key nullification on related instance deletion. 2018-01-13 10:31:00 -05:00
Mariusz Felisiak 385e6fb352 Removed Query.split_exclude()'s unused prefix argument.
Unused since b4492a8ca4.
2018-01-12 19:06:15 -05:00
Дилян Палаузов a38ae914d8 Fixed #28996 -- Simplified some boolean constructs and removed trivial continue statements. 2018-01-12 12:44:50 -05:00
Дилян Палаузов d7b2aa24f7 Fixed #28982 -- Simplified code with and/or. 2018-01-03 20:12:23 -05:00
Tim Graham acc8dd4142
Fixed #28984 -- Made assorted code simplifications. 2018-01-03 13:24:02 -05:00
Дилян Палаузов d79cf1e9e2 Fixed #28985 -- Removed unneeded None checks before hasattr(). 2018-01-03 11:37:06 -05:00
shanghui cc6bcc6ff5 Fixed #28867 -- Added system check for a model property that clashes with a related field accessor. 2018-01-03 10:34:31 -05:00
Robin Ramael fbf647287e Fixed #28811 -- Fixed crash when combining regular and group by annotations. 2018-01-03 08:24:16 -05:00
Mariusz Felisiak c86e9b5847 Removed DeferredAttribute.__init__()'s unused model argument.
Unused since a8a81aae20.
2018-01-02 17:54:10 -05:00
Simon Charette f5a989e603 Fixed #28974 -- Made refresh_from_db() hint routers about its instance. 2018-01-02 09:42:24 -05:00
Tim Graham d065c92678
Fixed #28918 -- Fixed Model.refresh_from_db() for instances hidden by the default manager. 2017-12-30 18:00:36 -05:00
Sergey Fedoseev ae6fa914aa Fixed #28926 -- Fixed loss of precision of big DurationField values on SQLite and MySQL. 2017-12-28 17:35:41 -05:00
Sergey Fedoseev 44908d4d93 Fixed #28967 -- Prevented Cast to FloatField from rounding to integer on MySQL. 2017-12-27 19:16:37 -05:00
hui shang f1aa58479c Fixed #28714 -- Added system checks for invalid model field names in Meta.indexes.
Thanks Gabriel for the report and Adam Johnson for the review.
2017-12-27 18:56:24 -05:00
Sergey Fedoseev ae1baa7d1d Refs #28459 -- Improved performance of loading DurationField on SQLite and MySQL. 2017-12-27 12:23:08 -05:00
Mads Jensen ef6c680f60 Removed unused variable in QuerySet._earliest_or_latest(). 2017-12-27 09:04:46 -05:00
Sergey Fedoseev d0f569b350 Refs #28459 -- Improved performance of loading DecimalField on SQLite. 2017-12-26 18:12:37 -05:00
Дилян Палаузов 4c599ece57 Fixed #28930 -- Simplified code with any() and all(). 2017-12-26 17:11:15 -05:00
Ran Benita c21f158295 Fixed #28944 -- Fixed crash when chaining values()/values_list() after QuerySet.select_for_update(of=()). 2017-12-26 11:41:17 -05:00
Tim Martin 5778b5701d Fixed #28731 -- Added an error message when using an empty Q() in a When expression.
Otherwise it generates invalid SQL.
2017-12-26 10:39:47 -05:00
Cameron Curry 622ead6aaf Fixed #28937 -- Allowed BinaryField to be editable=True. 2017-12-22 16:31:46 -05:00
Sergey Fedoseev 10bfa876be Refs #27985 -- Reallowed using __exact=None as an alias for __isnull=True if a custom lookup class with lookup_name != None is registered as the exact lookup.
Regression in 58da81a5a3 and prerequisite
for refs #28896.
2017-12-12 17:11:58 -10:00
Nick Pope d13a9e44de Fixed #28909 -- Simplified code using tuple/list/set/dict unpacking. 2017-12-11 07:08:45 -05:00
Simon Charette b43acf22df Refs #27849 -- Removed empty Q() hack in filtered Aggregate.as_sql().
This required allowing WhereNode to be provided as When(condition).

This was made possible by cf12257db2.
2017-12-08 10:59:49 -05:00
Tim Graham 2b81faab25
Fixed #28906 -- Removed unnecessary bool() calls. 2017-12-07 17:13:07 -05:00
Tim Graham 02d9419fe3
Fixed #28907 -- Removed unnecessary if statements. 2017-12-07 17:12:00 -05:00
Tim Graham a862af3839
Fixed #28893 -- Removed unnecessary dict.items() calls. 2017-12-06 17:17:59 -05:00
Mariusz Felisiak f79d9a322c
Refs #28876 -- Fixed incorrect class-based model index name generation for models with quoted db_table.
Thanks Simon Charette and Tim Graham for the review and Carlos E. C.
Leite for the report.
2017-12-05 21:05:10 +01:00
Дилян Палаузов 87c76aa116 Fixed #28873 -- Used dict.setdefault() to set model and form field defaults. 2017-12-04 13:28:48 -05:00
Дилян Палаузов d2afa5eb23 Fixed #28860 -- Removed unnecessary len() calls. 2017-12-04 10:35:23 -05:00
Sergey Fedoseev cf12257db2 Fixed #28863 -- Fixed filter on annotation that contains Q. 2017-12-01 21:48:49 -05:00
Simon Charette e50add6ca1 Fixed #28856 -- Fixed a regression in caching of a GenericForeignKey pointing to a MTI model.
Regression in b9f8635f58.
2017-11-30 09:28:44 -05:00
Simon Charette 78c5e7b90e Fixed #28834 -- Followed ancestor links on field cache lookup failure.
Thanks Tim for the review.
2017-11-29 01:28:39 -05:00
Nicolas Delaby 746caf3ef8 Fixed #28837 -- Fixed test client crash if an exception with more than one arg is raised.
Also removed usage of the problematic pattern elsewhere.

Regression in 6e55e1d88a.
2017-11-28 18:55:23 -05:00
Raphael Michel 616f468760 Fixed #28848 -- Fixed SQLite/MySQL crash when ordering by a filtered subquery that uses nulls_first/nulls_last. 2017-11-27 11:35:44 -05:00
Yan Mitrofanov 54e5c4a00e Fixed #28820 -- Eliminated an extra query with QuerySet.update() on proxy models. 2017-11-21 12:11:47 -05:00
Dražen Odobašić d97f026a7a Fixed #28817 -- Made QuerySet.iterator() use server-side cursors after values() and values_list(). 2017-11-21 10:33:56 -05:00
Krzysztof Nazarewski 244cc40155 Fixed #26184 -- Allowed using any lookups in ModelAdmin.search_fields.
Thanks Krzysztof Nazarewski for the initial patch.
2017-11-18 19:33:52 -05:00
Дилян Палаузов 23bf4ad87f Fixed #28795 -- Removed 'not in' checks and used dict.setdefault(). 2017-11-14 10:52:52 -05:00
Mariusz Felisiak 2d3cc94284
Fixed #28781 -- Added QuerySet.values()/values_list() support for union(), difference(), and intersection().
Thanks Tim Graham for the review.
2017-11-12 14:28:11 +01:00
Sergey Fedoseev bdb747a5f2 Simplified Field.get_choices(). 2017-11-11 19:38:29 -05:00
Paulo ee49306176 Fixed #27710 -- Made Model.save() invalidate cached, stale relations after a primary key assignment. 2017-11-09 11:40:34 -05:00
Дилян Палаузов c69e4bc691 Fixed #28769 -- Replaced 'x if x else y' with 'x or y'. 2017-11-07 09:08:46 -05:00
Дилян Палаузов 6c0042430e Fixed #28776 -- Fixed a/an/and typos in docs and comments. 2017-11-06 22:41:03 -05:00
Mike Hansen 514b2c989a Fixed #28723 -- Fixed RelatedManager's prefetch_related() cache name. 2017-11-02 10:06:00 -04:00
Charlie Denton cbe334918a Fixed #28750 -- Allowed models to define Meta.manager_inheritance_from_future for backwards compatibility.
Refs 631f4ab061.
2017-10-31 13:22:27 -04:00
Paulo fcfcf8aae4 Fixed #28742 -- Fixed AttributeError crash when assigning None to cached reverse relations. 2017-10-30 14:02:03 -04:00
Ran Benita 03049fb8d9 Refs #28010 -- Allowed reverse related fields in SELECT FOR UPDATE .. OF.
Thanks Adam Chidlow for polishing the patch.
2017-10-28 20:33:42 -04:00
Mariusz Felisiak 81e357a7e1 Fixed #28689 -- Fixed unquoted table names in Subquery SQL when using OuterRef.
Regression in f48bc7c3db.
2017-10-25 21:52:38 +02:00
Tomer Chachamu 21a3a29dc9 Fixed #28722 -- Made QuerySet.reverse() affect nulls_first/nulls_last. 2017-10-21 20:55:45 -04:00
Simon Charette d4fb742094 Refs #28575 -- Made RelatedObjectDoesNotExist classes pickable.
Thanks to Rachel Tobin for the initial __qualname__ work and tests.
2017-10-18 21:43:53 -04:00
Simon Charette 0a69479b6c Fixed outdated comment in RelatedObjectDoesNotExist. 2017-10-18 20:31:47 -04:00
Tim Graham 1b73ccc4bf Fixed #28497 -- Restored the ability to use sliced QuerySets with __exact.
Regression in ec50937bcb.

Thanks Simon Charette for review.
2017-10-16 13:56:38 -04:00
k 399a8db33b Fixed #28695 -- Allowed models to use __init_subclass__(). 2017-10-13 21:29:12 -04:00
Simon Charette 9dd405973c Corrected examples in related field descriptor docstrings.
Using lowercased model class names suggested that accessing the attribute
from instances of the class returned an instance of the descriptor, but
this is only the case when accessed from the model class.
2017-10-13 16:06:08 -04:00
Simon Charette 216eda103b Refs #28575 -- Removed unnecessary code for model exception pickling.
Setting __qualname__ is sufficient for pickling of DoesNotExist and
and MultipleObjectsReturned to work correctly.
2017-10-13 15:45:12 -04:00
Mariusz Felisiak 4f27e475b3 Refs #28643 -- Reorganized database functions.
Thanks Tim Graham for the review.
2017-10-13 21:23:00 +02:00
Rachel Tobin 6c92f711ea Refs #28575 -- Allowed pickling Model.DoesNotExist and MultipleObjectsReturned classes. 2017-10-13 09:16:09 -04:00
Paulo a7b5ad8b19 Fixed #27846 -- Made Model.refresh_from_db() clear cached relations. 2017-10-12 17:04:10 -04:00
Mariusz Felisiak 0899d583bd Fixed #28670 -- Added FETCH/OFFSET support on Oracle.
Thanks Tim Graham for the review.
2017-10-09 18:07:03 +02:00
Mariusz Felisiak 11ade8eefd Refs #24254 -- Removed unnecessary SQL AS clause in SQLCompiler.as_sql().
Incorrect on Oracle.
2017-10-06 12:47:41 -04:00
Simon Charette 9d93dff333 Fixed #28665 -- Change some database exceptions to NotImplementedError per PEP 249. 2017-10-06 12:47:08 -04:00
Mariusz Felisiak 03da070f5c Refs #28670 -- Moved LIMIT/OFFSET SQL to DatabaseOperations.limit_offset_sql().
Thanks Tim Graham for the review.
2017-10-04 20:24:38 +02:00
Tim Graham a2626cb3fe Fixed #28674 -- Removed unused check in QuerySet._batched_insert(). 2017-10-03 19:56:44 -04:00
Tim Graham 51d230e00b Fixed #28675 -- Removed always True variable in SQLInsertCompiler.execute_sql() check.
Unused since 7deb25b8dd.
2017-10-03 10:32:11 -04:00
Дилян Палаузов 5d9b736fd8 Fixed #28652 -- Fixed a few comments in django/db/models/*. 2017-10-02 11:15:26 -04:00
Mariusz Felisiak d896809a3a Refs #23919 -- Removed unneeded float()/int() calls. 2017-10-02 08:49:26 -04:00
Simon Charette f1b713024e Refs #28492 -- Defined aggregates' output_field at the class level.
Missed in 08654a99bb.
2017-09-29 07:44:27 -04:00
Mariusz Felisiak 2b5a511bd9 Merged hash() calls.
Thanks Simon Charette for the review.
2017-09-28 12:12:47 -04:00
Mads Jensen 4508fafe16 Simplified various __eq__() methods. 2017-09-28 09:18:37 -04:00
Tim Graham cfff2af02b Fixed #27857 -- Dropped support for Python 3.4. 2017-09-25 17:11:03 -04:00
Tim Graham 5bcca2a056 Refs #27532 -- Removed Model._meta.has_auto_field per deprecation timeline. 2017-09-22 12:51:18 -04:00
Tim Graham 4502489a46 Refs #18974 -- Removed @models.permalink() decorator per deprecation timeline. 2017-09-22 12:51:18 -04:00
Nicolas Delaby 01d440fa1e Fixed #27332 -- Added FilteredRelation API for conditional join (ON clause) support.
Thanks Anssi Kääriäinen for contributing to the patch.
2017-09-22 11:53:17 -04:00
Nicolas Delaby a30ef353e2 Removed unused list in Query.resolve_lookup_value().
Unneeded since its introduction in 4f138fe5a4.
2017-09-20 09:50:14 -04:00
Mariusz Felisiak fb02ebe889 Fixed #28597 -- Fixed crash with the name of a model's autogenerated primary key in an Index's fields. 2017-09-18 14:06:00 -04:00
Mads Jensen d549b88050 Fixed #26608 -- Added support for window expressions (OVER clause).
Thanks Josh Smeaton, Mariusz Felisiak, Sergey Fedoseev, Simon Charettes,
Adam Chainz/Johnson and Tim Graham for comments and reviews and Jamie
Cockburn for initial patch.
2017-09-18 09:42:29 -04:00
Sergey Fedoseev 8f947730ca Removed unneeded StdDev.convert_value() and Variance.convert_value().
Seems unneeded since its introduction in
f59fd15c49.
2017-09-16 15:05:31 -04:00
Sergey Fedoseev 873858009c Simplified Count.convert_value() and RegrCount.convert_value(). 2017-09-16 14:31:51 +05:00
Tim Graham cb362a6750 Removed unnecessary check in SQLCompiler.get_related_selections(). 2017-09-15 08:37:46 -04:00
Simon Charette 08654a99bb Fixed #28492 -- Defined default output_field of expressions at the class level.
This wasn't possible when settings were accessed during Field initialization
time as our test suite setup script was triggering imports of expressions
before settings were configured.
2017-09-11 12:22:39 -04:00
Simon Charette 13be453080 Refs #28492 -- Stopped accessing settings at Field.db_tablespace initialization.
Deferring accesses to settings allows database fields to be initialized before
settings are loaded.
2017-09-11 12:21:49 -04:00
Tim Graham 6e4c6281db Reverted "Fixed #27818 -- Replaced try/except/pass with contextlib.suppress()."
This reverts commit 550cb3a365
because try/except performs better.
2017-09-07 08:16:21 -04:00
Sergey Fedoseev 8b2515a450 Removed unneeded __init__() methods. 2017-09-07 08:10:49 -04:00
Sergey Fedoseev f3c9562143 Fixed #15648 -- Allowed QuerySet.values_list() to return a namedtuple. 2017-09-06 15:32:32 -04:00
Sergey Fedoseev 5b1c389603 Refs #23919 -- Replaced usage of django.utils.functional.curry() with functools.partial()/partialmethod(). 2017-09-06 13:11:18 -04:00
Sergey Fedoseev 379caf397e Replaced deque() with list() in prefetch_related_objects().
deque() isn't needed since algorithm doesn't require FIFO.
2017-09-06 08:13:18 -04:00
François Freitag ad4a8acdb5 Fixed #11557 -- Added support for a list of fields in Meta.get_latest_by and QuerySet.earliest()/latest(). 2017-09-05 20:14:54 -04:00
Dima Kudosh 093fd479d6 Fixed #28335 -- Allowed query expressions in Meta.ordering. 2017-09-05 19:10:20 -04:00
Boris Burkov d67cce4da8 Fixed typo in django/db/models/query.py docstring. 2017-09-05 15:28:37 -04:00
Srinivas Reddy Thatiparthy 0d3f567a7a Corrected YearComparisonLookup.get_bound() signature. 2017-09-04 10:17:51 -04:00
Mariusz Felisiak fe0184b412 Updated EmpytResultSet import not to use the alias. 2017-09-03 11:06:06 -04:00
Mariusz Felisiak 2470756de0 Moved select_sql in SQLCompiler.get_extra_select() to improve performance. 2017-09-02 16:39:51 -04:00
Jeremy Kerr 84b7cb7df0 Fixed #28549 -- Fixed QuerySet.defer() with super and subclass fields.
Previously, deferring fields in different classes didn't omit the
superclass' deferred field.

Thanks Simon Charette for the suggested fix.
2017-08-31 09:35:05 -04:00
Tim Graham e5bd585c6e Fixed #28543 -- Prevented ManyToManyField.value_from_object() from being lazy.
Previously, it was a QuerySet which could reevaluate to a new value if the
model's data changes. This is inconsistent with other Field.value_from_object()
methods.

This allows reverting the fix in the admin for refs #27998.
2017-08-31 09:34:44 -04:00
Sergey Fedoseev ab3e3658cc Simplified model's Options._get_fields() a bit. 2017-08-31 07:11:30 -04:00
Sergey Fedoseev f2b93b509c Removed unneeded iter() calls.
A few of these were unnecessarily added in 2b281cc35e.
2017-08-23 16:48:29 -04:00
Sergey Fedoseev dca67bb2c2 Refs #28459 -- Improved performance of SQLCompiler.apply_converters(). 2017-08-23 16:26:24 -04:00
Sergey Fedoseev 4dfd6b88d5 Refs #28459 -- Improved performance of FlatValuesListIterable. 2017-08-22 11:26:07 -04:00
Paulo fea9cb46aa Fixed #28375 -- Fixed KeyError crash on reverse prefetch of a model with OneToOneField primary key to a non-pk field. 2017-08-21 16:14:13 -04:00
Sergey Fedoseev 41640760df Simplified generation of result in Query.get_aggregation(). 2017-08-15 09:59:31 -04:00
Sergey Fedoseev 8a99a7d2d5 Simplified RelatedPopulator.populate(). 2017-08-15 09:48:07 -04:00
Sergey Fedoseev 6542999c54 Removed redundant condition in QuerySet.resolve_expression(). 2017-08-15 09:44:27 -04:00
Sergey Fedoseev 6141040813 Avoided creation of temporary set in Query.append_annotation_mask(). 2017-08-15 09:43:47 -04:00
Tom b78d100fa6 Fixed #27849 -- Added filtering support to aggregates. 2017-08-12 17:58:28 -04:00
Sergey Fedoseev 47ccefeada Refs #28459 -- Improved performance of BaseExpression.convert_value(). 2017-08-11 18:34:50 -04:00
Sergey Fedoseev 5cc7462067 Refs #28459 -- Optimized ModelState instantiation. 2017-08-11 15:41:04 -04:00
Nerl~ 97cb3bd16d Fixed #28456 -- Allowed customizing Model pickling by overriding __getstate__(). 2017-08-11 15:27:25 -04:00
Sergey Fedoseev 0ec134e340 Simplified calculation of used joins in Query.build_filter(). 2017-08-11 10:46:11 -04:00
Sergey Fedoseev 9ecf280394 Removed obsolete DecimalComparisonLookup.
Unneeded since c3c6c92d76.
2017-08-11 09:32:32 -04:00
Sergey Fedoseev f3e350d631 Replaced typecast_decimal() with decimal.Decimal(). 2017-08-11 09:22:40 -04:00
Sergey Fedoseev 7fa92daa99 Removed outdated comment in Query.build_filter(). 2017-08-11 09:19:19 -04:00