Commit Graph

1739 Commits

Author SHA1 Message Date
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
Mitchell Kotler 6024fd5dc2 Fixed #25095 -- Fixed annotate() + values() group by bug
Thanks Josh Smeaton for help on the tests.
2015-07-27 07:44:48 -04:00
Matt Johnson e063ac2fae Fixed #12768 -- Fixed QuerySet.raw() regression on FK with custom db_column. 2015-07-23 18:07:38 -04:00
Edward Henderson f8cc464452 Fixed #16501 -- Added an allow_unicode parameter to SlugField.
Thanks Flavio Curella and Berker Peksag for the initial patch.
2015-07-17 13:48:58 -04:00
Thomas Stephenson 035b0fa60d Fixed #24716 -- Deprecated Field._get_val_from_obj()
The method duplicates the functionality of Field.value_from_object()
and has the additional downside of being a privately named public
API method.
2015-07-14 09:13:22 -04:00
Anssi Kääriäinen 6f403056f0 Fixed #24923 -- errored out nicely when using aggregates in order_by() 2015-07-13 08:36:25 -04:00
Simon Charette 07577a2d05 Fixed #25081 -- Prevented DISTINCT ON ordering from being cleared in get().
Thanks to pdewacht for the patch.
2015-07-09 16:00:52 -04:00
Chris Lamb 61f3e22e38 Fixed #25054 -- Added app_label to swapped model AttributeError 2015-07-02 14:18:10 -04:00
William Schwartz 9a5cfa05a0 Fixed #24997 -- Enabled bulk_create() on proxy models 2015-07-02 13:53:51 -04:00
Michael Tänzer 3bbaf84d65 Fixed #18247 -- Added cast to NUMERIC for Decimals on sqlite
On sqlite the SUM() of a decimal column doesn't have a NUMERIC type so
when comparing it to a string literal (which a Decimal gets converted to
in Django) it is not compared as expected.
2015-06-30 18:27:42 -04:00
Jonas Degrave 4352e865a7 Fixed #24911 -- Made BaseManager.get_queryset() allow custom queryset args. 2015-06-30 13:48:30 -04:00
Andriy Sokolovskiy 7866968eb3 Removed unused condition for the abstract model in ensure_default_manager() 2015-06-29 21:17:19 -04:00
Anssi Kääriäinen 9ed82154bd Fixed #23791 -- Corrected object type check for pk__in=qs
When the pk was a relation field, qs.filter(pk__in=qs) didn't work.

In addition, fixed Restaurant.objects.filter(place=restaurant_instance),
where place is an OneToOneField and the primary key of Restaurant.

A big thank you to Josh for review and to Tim for review and cosmetic
edits.

Thanks to Beauhurst for commissioning the work on this ticket.
2015-06-29 07:49:31 -04:00
Tim Graham 7da3923ba0 Sorted imports in __init__.py files. 2015-06-27 11:53:33 -04:00
Greg Chapple 4a66a69239 Fixed #24887 -- Removed one-arg limit from models.aggregate 2015-06-27 11:44:33 -04:00
薛丞宏 d3e12c9017 Fixed #25016 -- Reallowed non-ASCII values for ForeignKey.related_name on Python 3. 2015-06-26 08:30:05 -04:00
Tim Graham aaacaeb096 Renamed RemovedInDjangoXYWarnings for new roadmap.
Forwardport of ae1d663b79
from stable/1.8.x plus more.
2015-06-24 16:08:20 -04:00
Markus Holtermann d3d66d4722 Fixed #24940 -- Made model managers hashable
Thanks Federico Jaramillo Martínez for the report and Tim Graham for the
test and review.
2015-06-19 19:02:01 +02:00
Gagaro 74261bc593 Fixed #24873 -- Prevented nested Prefetch objects from being overwritten. 2015-06-18 15:42:47 -04:00
Tim Graham 3872a33132 Fixed #24979 -- Removed usage of inspect.getargspec(). 2015-06-15 13:43:22 -04:00
Tim Graham 4b600ed244 Removed django.utils.functional.total_ordering() 2015-06-15 13:15:24 -04:00
Brian King bfb5b7150f Fixed #24912 -- Fixed prefetch_related failure for UUIDField primary keys
This resolves a problem on databases besides PostgreSQL when using
prefetch_related with a source model that uses a UUID primary key.
2015-06-15 09:37:38 -04:00
Cole Maclean 20ff296cb1 Fixed #24859 -- Made QuerySet.get() with UUIDField raise TypeError on bad value.
For consistency with AutoField.
2015-06-06 19:46:05 -04:00
Andriy Sokolovskiy 08232ef84d Fixed #24744 - Fixed relabeled_clone for the Transform 2015-06-06 09:04:53 -04:00
Mark Lavin 541f4ea546 Fixed #24924 -- Join promotion for multiple Case expressions 2015-06-05 12:22:43 -04:00
Tim Graham 6b41834855 Minor edits to Greatest/Least docs; refs #24767. 2015-06-05 11:40:10 -04:00
Andriy Sokolovskiy 286d0e6ab1 Refs #24833 -- Forwardported some of "Fixed Case expressions with exclude()."
Partial forwardport of 469f1e362b from stable/1.8.x
as the issue was already fixed in master.
2015-06-05 11:21:31 -04:00
Ian Foote 4ab53a558a Fixed #24767 -- Added Greatest and Least expressions
Greatest and Least are row-level Function versions of Min and Max.
2015-06-05 11:15:33 +01:00
Matthew Somerville 2dc93bb10a Fixed #22316 -- Added time filters to TimeField on SQLite.
This was implemented for non-SQLite backends in 1.7 (as a
side effect of #16187).
2015-06-04 22:27:13 -04:00
Rolo 19e67c6cd1 Fixed #24677 -- Made TextField.to_python() return a string.
This is consistent with CharField.
2015-06-04 09:02:54 -04:00
Adam Chainz 23048d186c Fixed #24866 -- Added Now() database function 2015-06-02 17:59:01 -04:00
Andriy Sokolovskiy 2913d6b77d Fixed #24831 -- Fixed pickling queryset with prefetch_related() after deleting objects. 2015-06-02 09:54:53 -04:00
Jon Dufresne 44f3ee7716 Fixed #9596 -- Added date transform for DateTimeField. 2015-06-02 08:49:10 -04:00
Josh Smeaton c7805ee214 Fixed #24699 -- Added aggregate support for DurationField on Oracle 2015-05-30 20:41:33 -04:00
Paweł Marczewski 801a84ae32 Fixed #24835 -- Fixed QuerySet.exists() after an annotation with Count()
QuerySet.exists() incorrectly handled query.group_by = True
case (grouping by all select fields), causing GROUP BY
expressions to be wiped along with select fields.
2015-05-25 20:46:20 -04:00
Alexander Sosnovskiy 04e8d890ae Fixed #16891 -- Made Model/QuerySet.delete() return the number of deleted objects. 2015-05-22 13:27:16 -04:00
Anssi Kääriäinen bc87061a3c Fixed #24705 -- Fixed negated Q objects in expressions.
Avoided split_exclude() for Q when used as an expression.
2015-05-20 09:41:04 -04:00
Alasdair Nicol d091b75eef Fixed #24818 -- Prevented models.CharField from accepting a string as max_length 2015-05-19 08:06:39 -04:00
Aymeric Augustin 54026f1e8d Renamed value_to_db_xxx to adapt_xxxfield_value.
This mirrors convert_xxxfield_value nicely, taking advantage of the
adapter/converter terminology which is commonly used by DB-API modules.
2015-05-17 09:39:34 +02:00
Aymeric Augustin d9521f66b1 Removed global timezone-aware datetime adapters.
Refs #23820.

Fixed #19738.

Refs #17755. In order not to introduce a regression for raw queries,
parameters are passed through the connection.ops.value_to_db_* methods,
depending on their type.
2015-05-17 09:38:48 +02:00
Tim Graham eda12ceef1 Removed redundant list() calls. 2015-05-16 10:44:07 -04:00
Piotr Jakimiak 4157c502a5 Removed unnecessary arguments in .get method calls 2015-05-13 20:51:18 +02:00
Abhaya Agarwal 9de9c24017 Fixed #24105 -- Called Storage.get_valid_name() when upload_to is callable 2015-05-12 20:08:22 -04:00
Andriy Sokolovskiy f7b2978158 Fixed #24156 -- Fixed inherited related name of ManyToManyField.
Fixed situation when parent abstract model declares related_name='+',
and child models had an invalid queryset.
2015-05-12 19:14:55 -04:00
Anssi Kääriäinen adc57632bc Fixed #24748 -- Fixed incorrect GROUP BY on MySQL in some queries
When the query's model had a self-referential foreign key, the
compiler.get_group_by() code incorrectly used the self-referential
foreign key's column (for example parent_id) as GROUP BY clause
when it should have used the model's primary key column (id).
2015-05-11 11:42:27 -04:00
Anssi Kääriäinen be9d645346 Fixed #24766 -- Added join promotion for Case expressions 2015-05-11 11:16:16 -04:00
Matt Robenolt 8a54526592 Removed redundant removal of hyphens in UUIDField. 2015-05-11 07:11:50 -04:00
Tim Graham b99114f67f Fixed #24758 -- Corrected Options.get_fields() docstring. 2015-05-08 13:18:48 -04:00
Pradeek 6123e6134f Fixed #24708 -- Handled non-string values in GenericIPAddressField.to_python() 2015-05-06 07:03:31 -04:00
Anssi Kääriäinen 7b05d2fdae Fixed #24752 -- query crash when reusing Case expressions
Case expressions weren't copied deep enough (self.cases list was
reused resulting in an error).
2015-05-05 11:38:12 -04:00
Luis Del Giudice 69ddc1b3da Fixed #24693 -- Added label and label_lower property to Model._meta 2015-05-02 16:58:18 +02:00
Aric Coady 9c2d8cde77 Fixed #24719 -- Restored the ability to use interators as queryset related object filters. 2015-04-28 10:51:27 -04:00
Tim Graham 2d76b61dc2 Fixed #24649 -- Allowed using Avg aggregate on non-numeric field types. 2015-04-25 13:06:14 -04:00
Simon Charette b44ed404c7 Fixed #24654 -- Based ordering circular references detection on columns.
Thanks to Elmar Bucher for the report and Tim for the review.
2015-04-20 15:49:58 -04:00
Jon Dufresne b5e0eede40 Fixed #22394 -- Refactored built-in datetime lookups to transforms. 2015-04-20 15:11:11 -04:00
Curtis Maloney 14ecbd02a3 Removed cases of six.iter* wrapped in a list()
There's absolutely no advantage [and a mild performance hit] to using six.iter*
in these cases.
2015-04-18 23:29:29 +10:00
Claude Paroz 8097e54832 Fixed #23879 -- Allowed model migration skip based on feature/vendor
Thanks Carl Meyer for the report and review, and Tim Graham for the
review.
2015-04-18 15:17:49 +02:00
Anssi Kääriäinen 355c5edd93 Fixed #24605 -- Fixed incorrect reference to alias in subquery.
Thanks to charettes and priidukull for investigating the issue, and to
kurevin for the report.
2015-04-16 09:22:00 -04:00
Anssi Kääriäinen fb5c7748da Fixed #24615 -- ordering by expression not part of SELECT
Fixed queries where an expression was used in order_by() but the
expression wasn't in the query's select clause (for example the
expression could be masked by .values() call)

Thanks to Trac alias MattBlack85 for the report.
2015-04-16 09:40:47 +02:00
Alex Wilson 99d40c6f65 Fixed #24277 -- Added exception when dict used in QuerySet filtering 2015-04-14 13:28:53 -04:00
Jay Wineinger 923da0274a Fixed #24611 -- Fixed update() crash with related UUID pk object. 2015-04-13 12:18:24 -04:00
Adam Chainz 9d0c600d8d Fixed #24609 -- Made ConcatPair use CONCAT_WS() on MySQL 2015-04-09 10:17:27 -04:00
Tim Graham a10b4c010a Fixed #24578 -- Fixed crash with QuerySet.update() on FK to O2O fields.
Thanks Anssi Kääriäinen for review.
2015-04-09 06:50:21 -04:00
Simon Charette dc27f3ee0c Fixed #19259 -- Added group by selected primary keys support. 2015-03-29 22:03:30 -04:00
Marco Fucci 4ee08958f1 Fixed #24505 -- Fixed clash with hidden m2m fields.
Added support for multiple m2m fields with the same 'to' model
and with related_name set to '+'.
2015-03-26 19:00:37 -04:00
Alex Hill 720ff740e7 Fixed #24215 -- Refactored lazy model operations
This adds a new method, Apps.lazy_model_operation(), and a helper function,
lazy_related_operation(), which together supersede add_lazy_relation() and
make lazy model operations the responsibility of the App registry. This
system no longer uses the class_prepared signal.
2015-03-25 16:48:17 -04:00
Anssi Kääriäinen 8f30556329 Renamed Field.rel attribute to remote_field
Field.rel is now deprecated. Rel objects have now also remote_field
attribute. This means that self == self.remote_field.remote_field.

In addition, made the Rel objects a bit more like Field objects. Still,
marked ManyToManyFields as null=True.
2015-03-25 08:16:12 -04:00
Anssi Kääriäinen f9c70bb3a1 Renamed ForeignObject.related_field to target_field 2015-03-25 08:13:27 -04:00
Anssi Kääriäinen d43aa28f67 Removed field.field check in setup_joins() 2015-03-25 08:11:27 -04:00
Anssi Kääriäinen b68212f539 Refs #24267 -- Implemented lookups for related fields
Previously related fields didn't implement get_lookup, instead
related fields were treated specially. This commit removed some of
the special handling. In particular, related fields return Lookup
instances now, too.

Other notable changes in this commit is removal of support for
annotations in names_to_path().
2015-03-25 08:05:22 -04:00
David Szotten 80e3444eca Fixed #24483 -- Prevented keepdb from breaking with generator choices.
If Field.choices is provided as an iterator, consume it in __init__ instead
of using itertools.tee (which ends up holding everything in memory
anyway). Fixes a bug where deconstruct() was consuming the iterator but
bypassing the call to `tee`.
2015-03-24 11:42:53 -04:00
Michael Blatherwick 00e667728b Fixed #23697 -- Improved ForeignObject.get_lookup_constraint() error message. 2015-03-23 10:31:57 -04:00
Josh Smeaton 02a2943e4c Fixed #24485 -- Allowed combined expressions to set output_field 2015-03-22 17:36:55 +11:00
Josh Smeaton 127b3873d0 Fixed #24508 -- Made annotations commutative 2015-03-22 17:28:42 +11:00
Jon Dufresne 966a29c2b8 Fixed #24479 -- Added system check to prevent both ordering and order_wrt. 2015-03-21 08:16:28 -04:00
Jon Dufresne e304e13448 Removed double pop from meta_attrs. 2015-03-21 08:16:28 -04:00
Karl Hobley 81e1a35c36 Fixed #24495 -- Allowed unsaved model instance assignment check to be bypassed. 2015-03-18 19:00:09 -04:00
Tim Graham 71c638fc55 Fixed typo in refs #15579 comment. 2015-03-17 09:08:02 -04:00
Josh Smeaton 88d798d71a Refs #24485 -- Renamed some expression types 2015-03-17 08:40:18 -04:00
Josh Smeaton ff2aa40192 Fixed #24486 -- Fixed error with datetime and DurationField arithmetic 2015-03-17 08:35:49 -04:00
Andriy Sokolovskiy 81c2d9f60b Fixed #15579 -- Added ability to delete only child models in multi-table inheritance. 2015-03-17 08:33:16 -04:00
Anssi Kääriäinen fb146193c4 Fixed #24171 -- Fixed failure with complex aggregate query and expressions
The query used a construct of qs.annotate().values().aggregate() where
the first annotate used an F-object reference and the values() and
aggregate() calls referenced that F-object.

Also made sure the inner query's select clause is as simple as possible,
and made sure .values().distinct().aggreate() works correctly.
2015-03-09 07:49:23 -04:00
Josh Smeaton ceaf31adff Fixed #24420 -- Allowed ordering by case expressions 2015-03-06 13:30:02 +11:00
Claude Paroz 5cf96b49e4 Fixed #24418 -- Prevented crash in refresh_from_db with null fk
Thanks Johannes Lerch for the report, Tim Graham for the test case,
and Simon Charette for the review.
2015-02-27 20:23:07 +01:00
Anssi Kääriäinen f95122e541 Fixed #24381 -- removed ForeignObjectRel opts and to_opts
These cached properies were causing problems with pickling, and in
addition they were confusingly defined: field.rel.model._meta was
not the same as field.rel.opts.

Instead users should use field.rel.related_model._meta inplace of
field.rel.opts, and field.rel.to._meta in place of field.rel.to_opts.
2015-02-23 07:24:43 -05:00
Michael Angeletti ea3168dc6c Fixed #24376 -- added verbose_name arg to UUIDField 2015-02-21 13:27:49 -05:00
Don Kirkby 99a1bbf985 Fixed typo in django/db/models/fields/files.py comment. 2015-02-20 20:11:13 -05:00
Anssi Kääriäinen bad5f262bf Fixed #24328 -- cleaned up Options._get_fields() implementation 2015-02-20 13:00:12 -05:00
Loic Bistuer bed504d70b Fixed #24351, #24346 -- Changed the signature of allow_migrate().
The new signature enables better support for routing RunPython and
RunSQL operations, especially w.r.t. reusable and third-party apps.

This commit also takes advantage of the deprecation cycle for the old
signature to remove the backward incompatibility introduced in #22583;
RunPython and RunSQL won't call allow_migrate() when when the router
has the old signature.

Thanks Aymeric Augustin and Tim Graham for helping shape up the patch.

Refs 22583.
2015-02-20 21:34:09 +07:00
Marc Tamlyn 32d4db66b9 Update converters to take a consistent set of parameters.
As suggested by Anssi. This has the slightly strange side effect of
passing the expression to Expression.convert_value has the expression
passed back to it, but it allows more complex patterns of expressions.
2015-02-20 11:35:52 +00:00
Marc Tamlyn 4755f8fc25 Fixed #24343 -- Ensure db converters are used for foreign keys.
Joint effort between myself, Josh, Anssi and Shai.
2015-02-20 11:35:51 +00:00
Loic Bistuer 5efd472178 Reworked docstrings and comments in related.py.
Thanks Tim Graham for the review.
2015-02-16 20:40:04 +07:00
Loic Bistuer c5a77721e2 Merged ManyRelatedObjectsDescriptor and ReverseManyRelatedObjectsDescriptor
and made all "many" related objects descriptors inherit from
ForeignRelatedObjectsDescriptor.
2015-02-16 20:40:04 +07:00