Commit Graph

4431 Commits

Author SHA1 Message Date
John Bowen b6cbc88f26 [3.0.x] Fixed #27914 -- Fixed serialization of nested classes in migrations.
Backport of 29d8198841 from master
2019-11-25 11:27:15 +01:00
Mariusz Felisiak b6be0699b9 [3.0.x] Fixed #30986 -- Fixed queryset crash when filtering against boolean RawSQL expressions on Oracle.
Backport of 8685e764ef from master
2019-11-18 09:16:21 +01:00
George Marshall fa6076daf4 [3.0.x] Fixed #30971 -- Prevented Query.resolve_lookup_value() from coercing list values to tuples.
Regression in 8a281aa7fe.

Backport of 8be79984dc from master
2019-11-13 09:20:50 +01:00
Mariusz Felisiak 2cf5df1204 [3.0.x] Fixed DatabaseFeatures.has_select_for_update_nowait on MariaDB 10.3+.
Thanks Kola Erinoso for the report.
Backport of a20ea33ca6 from master
2019-11-05 10:19:23 +01:00
Carlton Gibson dd2ca8b0ea [3.0.x] Fixed #30931 -- Restored ability to override Model.get_FIELD_display().
Thanks Sergey Fedoseev for the implementation idea.

Regression in a68ea23101.

Backport of 2d38eb0ab9 from master
2019-11-04 08:15:03 +01:00
Carlton Gibson 8740ff334a [3.0.x] Fixed #30902 -- Added __str__() for model choice enums.
Allows expected behavior when cast to str, also matching behaviour of
created instances with those fetched from the DB.

Thanks to Simon Charette, Nick Pope, and Shai Berger for reviews.

Backport of dbcd7b064e from master
2019-10-25 09:38:41 +02:00
Hannes Ljungberg 318d186d7e [3.0.x] Fixed #30903 -- Fixed migrations crash on PostgreSQL when adding Index with opclasses and ordering.
Backport of fa5f3291e7 from master
2019-10-24 09:51:33 +02:00
Simon Charette bab3ad54ff [3.0.x] Fixed #30868 -- Prevented unnecessary AlterField when renaming a referenced pk.
Regression introduced by dcdd219ee1, refs #25817.

Thanks Carlos E. C. Leite for the report and Mariusz for the bisect.

Backport of 2839659b42 from master
2019-10-14 08:27:36 +02:00
Hasan Ramezani c1cfec6b50 [3.0.x] Fixed #30854 -- Fixed QuerySet.select_related() with multiple FilteredRelations.
Backport of 6a75cea76a from master.
2019-10-11 09:18:23 +02:00
Hasan Ramezani 30271a47da [3.0.x] Refs #27914 -- Fixed serialization of nested enum.Enum classes in migrations.
Backport of 6452112640 from master
2019-10-03 11:17:10 +02:00
Mariusz Felisiak 40efffafd9 [3.0.x] Fixed typo in BulkInsertMapper constant name.
Backport of 67e7dffe95 from master
2019-10-01 14:59:27 +02:00
Ahmet Kucuk 9dc13f41b5 [3.0.x] Fixed #30510 -- Fixed crash of QuerySet.bulk_create() with mixed-length texts on Oracle.
Text with more than 4000 characters must be set to as a CLOB on Oracle
what caused a mixed datatype error (ORA-01790) when shorter text
appeared in the same operation.

Backport of dc890bef5a from master
2019-10-01 13:11:19 +02:00
Hasan Ramezani df0c2ac358 [3.0.x] Fixed #30774 -- Made serialization in migrations use members names for Enums.
Backport of f0adf3b9b7 from master
2019-09-30 10:52:30 +02:00
Hasan Ramezani 0dc39ca867 [3.0.x] Fixed #30798 -- Fixed Meta.ordering validation for pk of related fields.
Regression in 440505cb2c.

Backport of 95a11578ce from master
2019-09-27 14:52:08 +02:00
Hasan Ramezani da8f85aa82 [3.0.x] Refs #30798 -- Prevented chaining fields from the same related model multiple times in model Meta.ordering.
Backport of c7944628a1 from master
2019-09-27 14:52:02 +02:00
Mariusz Felisiak 1adf85d168 [3.0.x] Fixed #30800 -- Fixed migrations crash when altering a field with custom db_type().
Regression in 1378d665a1.
Backport of 580e644f24 from master
2019-09-25 12:32:57 +02:00
Simon Charette 6b7bd079a6 [3.0.x] Fixed #30796 -- Prevented select_related() from mutating a queryset on chaining.
Thanks Darren Maki for the report.

Backport of 37f8f29377 from master
2019-09-24 09:47:21 +02:00
Hasan Ramezani 2362f27265 [3.0.x] Fixed #13296 -- Fixed ordering by Options.order_with_respect_to after deleting objects.
Thanks Simon Meers for the original patch.

Backport of f97bbad908 from master
2019-09-23 11:45:33 +02:00
James Timmins 3697ddbf75 [3.0.x] Fixed #30771 -- Fixed exact lookup against queries with selected columns.
Use pre-existing select fields (and thereby GROUP BY fields) from
subquery if they were specified, instead of always defaulting to pk.

Thanks Aur Saraf for the report and Simon Charette for guidance.

Backport of 0719edcd5f from master
2019-09-20 11:14:39 +02:00
Andrew def1857d9b [3.0.x] Fixed #30786 -- Used CONVERT_TZ to check if the time zone definitions are installed on MySQL.
Replaced a timezone check in the MySQL backend with one that doesn't
require access to the mysql.time_zone database.

Backport of 3346b78a8a from master
2019-09-20 08:57:13 +02:00
Adnan Umer acb11725f8 [3.0.x] Fixed #30591 -- Fixed recreation of foreign key constraints on MySQL when altering type of referenced unique field.
Thanks Mariusz Felisiak for tests and Matthijs Kooijman for
investigation and initial patch.

Backport of 241deed259 from master
2019-09-11 11:43:55 +02:00
Simon Charette 34decdebf1 Fixed #30754 -- Prevented inclusion of aliases in partial index conditions.
SQLite doesn't repoint table aliases in partial index conditions on table
rename which breaks the documented table alteration procedure.

Thanks Pēteris Caune for the report.
2019-09-10 10:03:16 +02:00
Vojtech Bocek b1d37fea8f Fixed #28107 -- Added DatabaseFeatures.allows_group_by_selected_pks_on_model() to allow enabling optimization for unmanaged models. 2019-09-09 14:04:46 +02:00
Johannes Hoppe 7254f1138d Refs #29444 -- Allowed returning multiple fields from INSERT statements on PostgreSQL.
Thanks Florian Apolloner, Tim Graham, Simon Charette, Nick Pope, and
Mariusz Felisiak for reviews.
2019-09-09 10:51:14 +02:00
Johannes Hoppe 736e7d44de Refs #29444 -- Fixed DateField constructor in db.backends.oracle.utils.InsertVar. 2019-09-09 10:51:07 +02:00
Nick Pope b6251956b6 Fixed #30757 -- Added a system check to ensure max_length fits the longest choice. 2019-09-09 10:28:18 +02:00
Mariusz Felisiak addabc492b
Fixed DatabaseFeatures.can_introspect_check_constraints on MariaDB < 10.2.22, 10.3.0 - 10.3.9.
Regression in e2c6a0858d.
2019-09-06 11:53:54 +02:00
Mariusz Felisiak e2c6a0858d Fixed #30750 -- Added support for check constraints on MySQL 8.0.16+. 2019-09-05 09:18:34 +02:00
Shai Berger 72ebe85a26 Fixed #27910 -- Added enumeration helpers for use in Field.choices.
These classes can serve as a base class for user enums, supporting
translatable human-readable names, or names automatically inferred
from the enum member name.

Additional properties make it easy to access the list of names, values
and display labels.

Thanks to the following for ideas and reviews:

Carlton Gibson, Fran Hrženjak, Ian Foote, Mariusz Felisiak, Shai Berger.

Co-authored-by: Shai Berger <shai@platonix.com>
Co-authored-by: Nick Pope <nick.pope@flightdataservices.com>
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-09-04 14:42:49 +02:00
Viktor Lomakin 5931d2e96a Fixed #30691 -- Made migrations autodetector find dependencies for foreign keys altering. 2019-09-03 14:45:49 +02:00
Johannes Hoppe 003bb34b21 Refs #29444 -- Made db.backends.oracle.utils.InsertVar use str as default. 2019-09-03 10:34:55 +02:00
Simon Charette 13a8884a08 Fixed #30739 -- Fixed exclusion of multi-valued lookup against outer rhs.
OuterRef right hand sides have to be nested, just like F rhs have to,
during the subquery pushdown split_exclude performs to ensure they are
resolved against the outer query aliases.
2019-09-02 10:52:36 +02:00
Simon Charette 600628f8f0 Refs #28442 -- Adjusted related lookups handling of expression rhs.
Expressions should never be prepared as other Lookup.get_prep_lookup
implementations hint at by returning early on the presence of the
resolve_expression attribute.

The previous solution was only handling lookups against related fields
pointing at AutoFields and would break for foreign keys to other fields.

It was also causing bidirectional coupling between model fields and
expressions which the method level import of OuterRef was a symptom of.
2019-09-02 10:52:36 +02:00
Mariusz Felisiak d275fd04f3
Refs #25367 -- Simplified OrderBy and Lookup by using Case() instead of RawSQL() on Oracle.
Follow up to efa1908f66.
2019-08-29 11:56:12 +02:00
Matthew Schinckel 4137fc2efc Fixed #25367 -- Allowed boolean expressions in QuerySet.filter() and exclude().
This allows using expressions that have an output_field that is a
BooleanField to be used directly in a queryset filters, or in the
When() clauses of a Case() expression.

Thanks Josh Smeaton, Tim Graham, Simon Charette, Mariusz Felisiak, and
Adam Johnson for reviews.

Co-Authored-By: NyanKiyoshi <hello@vanille.bid>
2019-08-29 09:45:29 +02:00
Andrew Brown 691def10a0 Fixed #30727 -- Made Subquery pickle without evaluating their QuerySet.
Subquery expression objects, when pickled, were evaluating the QuerySet
objects saved in its _constructor_args attribute.
2019-08-27 13:05:20 +02:00
Mariusz Felisiak 579909a13f
Refs #30591 -- Fixed introspection of check and unique column constraints on MariaDB.
Unnamed unique and check columns constraints have the same name as
a column. Ensure uniqueness by using custom names.

Thanks Adnan Umer for the report.
2019-08-26 09:15:37 +02:00
Claude Paroz 9386586f31 Replaced subprocess commands by run() wherever possible. 2019-08-23 10:53:36 +02:00
Nasir Hussain 6b16c91157 Fixed #30712 -- Allowed BLOB/TEXT defaults on MySQL 8.0.13+. 2019-08-22 12:23:10 +02:00
Mads Jensen 85ac838d9e Fixed #21039 -- Added AddIndexConcurrently/RemoveIndexConcurrently operations for PostgreSQL.
Thanks to Simon Charettes for review.

Co-Authored-By: Daniel Tao <daniel.tao@gmail.com>
2019-08-21 13:10:06 +02:00
Nick Pope 21e559495b Fixed #29979, Refs #17337 -- Extracted AutoField field logic into a mixin and refactored AutoFields.
This reduces duplication by allowing AutoField, BigAutoField and
SmallAutoField to inherit from IntegerField, BigIntegerField and
SmallIntegerField respectively. Doing so also allows for enabling the
max_length warning check and minimum/maximum value validation for auto
fields, as well as providing a mixin that can be used for other possible
future auto field types such as a theoretical UUIDAutoField.
2019-08-20 09:22:25 +02:00
Hasan Ramezani 85458e94e3 Fixed #29260 -- Skipped an UPDATE when adding a model instance with primary key that has a default. 2019-08-19 13:28:35 +02:00
Claude Paroz d1c2e6dd04 Refs #28428 -- Made FileField.upload_to support pathlib.Path. 2019-08-18 20:34:58 +02:00
Simon Charette 8b4a43dda7 Fixed #29545 -- Fixed using filter lookups againts nested subquery expressions.
Made sql.Where resolve lhs of its child nodes. This is necessary to
allow filter lookups against nested subquery expressions to properly
resolve their OuterRefs to Cols.

Thanks Oskar Persson for the simplified test case.
2019-08-17 11:24:35 +02:00
Adam Johnson 7da6a28a44 Fixed #27676 -- Allowed BLOB/TEXT defaults on MariaDB 10.2.1+. 2019-08-16 11:39:37 +02:00
Andrew Brown 8a281aa7fe Fixed #30687 -- Fixed using of OuterRef() expressions in distance lookups. 2019-08-16 06:50:33 +02:00
zeyneloz 00035672a4 Fixed #30449 -- Fixed RelatedFieldListFilter/RelatedOnlyFieldListFilter to respect model's Meta.ordering.
Regression in 6d4e5feb79.

Co-Authored-By: Mariusz Felisiak <felisiak.mariusz@gmail.com>
2019-08-15 10:29:05 +02:00
Mads Jensen 0b8d911d28 Optimized Field.deconstruct() by using elif. 2019-08-14 10:50:31 +02:00
Simon Charette efa1908f66 Refs #25367 -- Moved Oracle Exists() handling to contextual methods.
Oracle requires the EXISTS expression to be wrapped in a CASE WHEN in
the following cases.

1. When part of a SELECT clause.
2. When part of a ORDER BY clause.
3. When compared against another expression in the WHERE clause.

This commit moves the systematic CASE WHEN wrapping of Exists.as_oracle
to contextual .select_format, Lookup.as_oracle, and OrderBy.as_oracle
methods in order to avoid unnecessary wrapping.
2019-08-13 06:48:14 +02:00
Simon Charette fff5186d32 Refs #25367 -- Moved select_format hook to BaseExpression.
This will expose an intermediary hook for expressions that need special
formatting when used in a SELECT clause.
2019-08-13 06:48:14 +02:00