Commit Graph

1550 Commits

Author SHA1 Message Date
Simon Charette 9cebb95348 Adjusted a comment to reflect some app refactor changes. 2014-11-26 09:47:37 -05:00
Collin Anderson d4ea4eea79 Fixed #23889 -- Added more usage of quote_name_unless_alias() to avoid deprecation warnings. 2014-11-21 16:44:50 -05:00
Simon Charette c7087bc777 Fixed #23862 -- Made ManyToManyRel.get_related_field() respect to_field. 2014-11-21 16:02:31 -05:00
Anssi Kääriäinen 5c481db295 Fixed #23605 -- Fixed nested subquery regression
Added relabeled_clone() method to sql.Query to fix the problem. It
manifested itself in rare cases where at least double nested subquery's
filter condition might target non-existing alias.

Thanks to Trac alias ris for reporting the problem.
2014-11-20 13:38:08 -05:00
Carl Meyer d6e2bbe734 Fixed #23876 -- Removed dead code in SQLAggregateCompiler. 2014-11-20 04:18:08 -07:00
Carl Meyer e7b9a58b08 Fixed #21794 -- Removed deprecation warning for abstract models outside an app. 2014-11-19 15:56:04 -07:00
Carl Meyer 08fbbaa45b Deprecated calling a SQLCompiler instance. 2014-11-18 19:47:16 -07:00
Anssi Kääriäinen 4252a14c39 Moved bilateral transform fetching to models.lookups 2014-11-17 18:04:08 +01:00
Karen Tracey dec93d8991 Fixed #21612 -- Made QuerySet.update() respect to_field 2014-11-16 15:44:13 +01:00
Josh Smeaton f61256da3a Renamed qn to compiler 2014-11-16 13:19:34 +01:00
Josh Smeaton f59fd15c49 Fixed #14030 -- Allowed annotations to accept all expressions 2014-11-15 14:00:43 +00:00
Tim Graham aa77e90aa9 Remove Field.get_validator_unique_lookup_type()
Usage of this method was removed pre 1.0 (c2ba59fc).
2014-11-12 20:11:40 +01:00
Anssi Kääriäinen 4e9a6c94e6 Removed extra enumerate() from Query.setup_joins() 2014-11-12 13:22:08 +02:00
Jozef Knaperek c56c42b5c0 Fixed #22967 -- Made Model._do_update consistent
Made _do_update behave more strictly according to its docs,
including a corner case when specific concurent updates are
executed and select_on_save is set.
2014-11-12 12:53:30 +02:00
Anssi Kääriäinen d647764a53 Improved Query.names_to_path docstring 2014-11-12 12:40:55 +02:00
Anssi Kääriäinen b3fd39f7c8 Simplified Query.build_lookup() 2014-11-11 08:14:29 +02:00
Veres Lajos a71a2ea756 Fixed typos using https://github.com/vlajos/misspell_fixer 2014-11-03 20:59:30 -05:00
Andy Chosak ceb1ffcc8d Fixed #23420 - broken warning for unbound naive datetime objects
Fixed issue with warning message displayed for unbound naive datetime
objects when USE_TZ is True. Adds unit test that demonstrates the issue
(discoverable when using a custom lookup in MySQL).
2014-11-03 15:51:48 +02:00
Collin Anderson ae7cb992bc Fixed #23721 -- check_related_objects without calling __iter__
Refs #14334
2014-10-28 10:13:50 +02:00
Thomas Chaumeny 00aa562884 Fixed #23493 -- Added bilateral attribute to Transform 2014-10-28 10:02:10 +02:00
Gabe Jackson 0e16c3e3cd Fixed #23396 -- Ensured ValueQuerySets are not checked by check_related_objects. 2014-10-21 10:02:51 -04:00
Nicholas Serra 6c79d32977 Fixed #23684 -- Used correct package name for Pillow in Error hint. 2014-10-19 13:46:46 +07:00
Thomas Chaumeny b962653060 Fixed #23664 -- Provided a consistent definition for OrderedSet.__bool__
This also defines QuerySet.__bool__ for consistency though this should not have any consequence as bool(qs) used to fallback on QuerySet.__len__ in Py3.
2014-10-16 14:16:24 +02:00
Claude Paroz 374c14b7fd Fixed #23659 -- Kept annotate() args ordering
Thanks Loic Bistuer and Simon Charette for the review.
2014-10-16 09:27:20 +02:00
Marc Tamlyn 92a17eaae0 Fixed #23627 -- Allowed register_lookup to work as a decorator. 2014-10-09 18:44:58 +01:00
Artem Rizhov ca61195827 Fixed #23555 -- Avoided suppressing IndexError in QuerySet.first() and .last() 2014-10-08 14:28:38 -04:00
Loic Bistuer ed37f7e979 Fixed #23611 -- update_or_create failing from a related manager
Added update_or_create to RelatedManager, ManyRelatedManager and
GenericRelatedObjectManager.
Added missing get_or_create to GenericRelatedObjectManager.
2014-10-08 03:27:31 +07:00
André Ericson 1e5e2a4707 Fixed #22064 -- Add check for related_name
Validates that related_name is a valid Python id or ends with a '+' and
it's not a keyword. Without a check it passed silently leading to
unpredictable problems.

Thanks Konrad Świat for the initial work.
2014-10-04 20:47:26 -03:00
Thomas Chaumeny b2aad7b836 Replaced set([foo, ...]) by {foo, ...} literals. Refs PR 3282.
Thanks Collin Anderson for the review.
2014-09-29 00:01:38 +07:00
Matt Robenolt ef5f9b6ae8 Fixed #23460 -- Added literal `%s` support to extra() QuerySets. 2014-09-26 13:01:27 -04:00
Markus Holtermann 45bd7b3bd9 Fixed #23455 -- Forced related_name to be a unicode string during deconstruction. 2014-09-25 17:49:44 -04:00
Loic Bistuer e043aae9bb Fixed #23550 -- Normalized get_queryset() of RelatedObjectDescriptor
and ReverseSingleRelatedObjectDescriptor so they actually return QuerySet
instances.

Also ensured that SingleRelatedObjectDescriptor.get_queryset() accounts
for use_for_related_fields=True.

This cleanup lays the groundwork for #23533.

Thanks Anssi Kääriäinen for the review.
2014-09-24 02:03:12 +07:00
Thomas Chaumeny e008a10c2f Fixed #23443 -- Corrected erroneous FieldError message.
Thanks Tim Graham for the review.
2014-09-19 01:01:31 +07:00
Baptiste Mispelon d63ac5b595 Fixed #23492 -- Restored F.__deepcopy__.
This reverts commit 3a66035107.
A regression test was also added.
2014-09-16 12:19:00 +02:00
Marc Tamlyn ed7821231b Fixed #19463 -- Added UUIDField
Uses native support in postgres, and char(32) on other backends.
2014-09-16 10:08:09 +01:00
Tim Graham c32bc1a7a7 Fixed #11775 -- Made ABSOLUTE_URL_OVERRIDES work with models that don't define get_absolute_url().
Thanks jukvalim for the report and initial patch,
and Preston Timmons for review.
2014-09-09 11:05:31 -04:00
Tim Graham 1101467ce0 Limited lines to 119 characters in django/
refs #23395.
2014-09-05 09:22:16 -04:00
Marc Tamlyn e9103402c0 Fixed #18757, #14462, #21565 -- Reworked database-python type conversions
Complete rework of translating data values from database

Deprecation of SubfieldBase, removal of resolve_columns and
convert_values in favour of a more general converter based approach and
public API Field.from_db_value(). Now works seamlessly with aggregation,
.values() and raw queries.

Thanks to akaariai in particular for extensive advice and inspiration,
also to shaib, manfre and timograham for their reviews.
2014-09-03 20:36:03 +01:00
Akis Kesoglou 6613ea6e3f Fixed #23370 -- defer() + select_related() crashed with inherited models. 2014-08-30 07:14:44 -04:00
Andrew Torpedov bc06d2c11c Fixed #23313 -- Corrected repr(RawQuery) with dict parameters. 2014-08-29 07:22:08 -04:00
Andrew Godwin 4d2f9c38e8 Fixed #23288: deconstruct() ignoring related_name 2014-08-14 19:47:22 -07:00
Anssi Kääriäinen f7dba61881 Avoided creation of deferred model from another deferred model
Also never create deferred model when no attrs are deferred.
2014-08-12 14:58:10 +03:00
Josh Smeaton 5b0375ec3e Fixed #23001 -- Fixed mixing defer and annotations 2014-08-12 14:58:10 +03:00
Anssi Kääriäinen dfadbdac6a Fixed #16426 -- deletion of 1000+ objects with relations on SQLite
SQLite doesn't work with more than 1000 parameters in a single query.
The deletion code could generate queries that try to get related
objects for more than 1000 objects thus breaking the limit. Django now
splits the related object fetching into batches with at most 1000
parameters.

The tests and patch include some work done by Trac alias NiGhTTraX in
ticket #21205.
2014-08-11 12:47:37 +03:00
Anubhav Joshi cdfdcf4b70 Fixed #23266 -- Prevented queries caused by type checking lookup values
Small modifications done by committer.
2014-08-11 09:51:57 +03:00
Rajiv Makhijani f0b358880a Fixed #23259 -- Corrected insertion order of extra() select_params
A regression caused queries to produce incorrect results for cases where
extra(select) is excluded by values() but included by extra(order_by)

The regression was caused by 2f35c6f10f.
2014-08-11 09:33:18 +03:00
Tim Graham f9f9f3ad60 Fixed flake8 warning. 2014-08-07 10:11:15 -04:00
Alex Hill 938da36cb1 Fixed #21603 -- Fixed complex RawQuerySets queries on some versions of SQLite. 2014-08-06 08:41:34 -04:00
Tim Graham fcd42a4819 Removed code that assumed BooleanField could be null.
Such a field will no longer pass model validation.
2014-08-05 07:49:53 -04:00
Shai Berger 746f2a4bed Fixed #23061: Avoided setting a limit on a query for get with select_for_update on Oracle
Thanks Michael Miller for reporting the issue.
2014-08-05 03:12:08 +03:00
Stanislas Guerra 98e8da3709 Fixed #16311 -- Added a RelatedOnlyFieldListFilter class in admin.filters. 2014-08-04 09:39:02 -04:00
Baptiste Mispelon 44169a00c1 Removed unnecessary code in ManyToManyField.deconstruct() 2014-08-03 15:15:24 +02:00
Baptiste Mispelon 7432533932 Added missing logic to TimeField.deconstruct().
If auto_now or auto_now_add was used then the serialized
field in the migration contained unnecessary `editable` and
`blank` arguments.
2014-08-03 14:02:21 +02:00
Baptiste Mispelon 72f1eb48df Fixed #23156 -- Added missing BinaryField.deconstruct() method. 2014-08-03 13:02:31 +02:00
Mitar 1ed6fbcf44 Fixed #21940 -- Added kwargs to contribute_to_class() of model fields..
Thanks Kronuz for the suggestion.
2014-08-01 07:41:28 -04:00
areski 97a38de230 Fixed #23112 -- Field.get_choices tries to index an iterable 2014-07-30 21:35:02 +02:00
Florian Apolloner 2f73b527dd Fixed #23098 -- Checked that lazy choices are not evaluated too soon
Thanks Matthieu Agopian for the report.
2014-07-27 13:31:25 +02:00
Abraham Martin e1347e9253 Fixed #23101 db_table wasn't copied in deconstruct
Forward port of 999758fc7a from
stable/1.7.x
2014-07-26 10:00:02 -07:00
Federico Frenguelli 6eed751162 Fixed #22887 -- Added comment for translators on unique_for_date error message 2014-07-26 13:55:20 +02:00
Gavin Wahl 6e2b82fdf6 Fixed #22998 -- Updated the fast_delete logic for GFKs 2014-07-16 12:28:00 +03:00
Shai Berger dd9b3312d0 Fixed name of database connection feature 2014-07-14 19:23:57 +03:00
Anssi Kääriäinen 9cd5201abd Fixed #22994 -- regression with generic FK + admin list_view
The reason for the regression was that the GenericForeignKey field isn't
something meta.get_field_by_name() should return. The reason is that a
couple of places in Django expects get_field_by_name() to work this way.
It could make sense to return GFKs from get_field_by_name(), but that
should likely be done as part of meta refactoring or virtual fields
refactoring patches.

Thanks to glicerinu@gmail.com for the report and to Tim for working on
the issue.
2014-07-14 10:50:41 -04:00
Anubhav Joshi 011abb7d96 Fixed #19671 -- Added warnings that null and validators are ignored for ManyToManyField.
Thanks Loic Bistuer and Tim Graham for help and review.
2014-07-09 16:01:09 -04:00
Daniel Hahler 67f9f385aa Fixed various minor doc typos / references. 2014-07-05 20:26:26 -04:00
Tim Graham 7fd55c3481 Fixed #20631 -- Increased the default EmailField max_length to 254.
Thanks pmartin for the report.
2014-07-04 14:15:00 -04:00
Anubhav Joshi 10e83d48a3 Fixed #22935 -- Changed ForeignKey.default_error_messages['invalid'] to refer to correct field.
Thanks Tim Graham for suggestion and review.
2014-07-02 13:01:36 -04:00
Anssi Kääriäinen 0b6f05ede6 Fixed #19501 -- added Model.from_db() method
The Model.from_db() is intended to be used in cases where customization
of model loading is needed. Reasons can be performance, or adding custom
behavior to the model (for example "dirty field tracking" to issue
automatic update_fields when saving models).

A big thank you to Tim Graham for the review!
2014-07-01 16:31:01 +03:00
Anubhav Joshi 34ba86706f Fixed #14334 -- Query relation lookups now check object types.
Thanks rpbarlow for the suggestion; and loic, akaariai, and jorgecarleitao
for reviews.
2014-07-01 06:12:58 -04:00
Anubhav Joshi fd5897193f Fixed problem with refs #10811.
When 'to_field' is specified with a FK, then we need to check the pk value
the object.
2014-06-30 10:25:57 -04:00
Lovas Bence 9385aa3198 Fixed #22050 -- Fixed defer fields on proxy related models. 2014-06-25 07:20:18 -04:00
Andrew Godwin 0b571753a8 Fixed #22889: Unneeded to_field in fk.deconstruct causing swap issues 2014-06-23 20:39:17 -07:00
Anubhav Joshi 1c50d6ae2b Fixed problem introduced with #refs 13711. 2014-06-23 19:36:40 +03:00
Renaud Parent 87d0a3384c Fixed #22778 -- Added a model Meta option to define default_related_name.
Thanks jorgecarleitao and mmardini for reviews.
2014-06-18 13:53:07 -04:00
Anubhav Joshi 91f1b6dcdc Fixed #13711 -- Model check added to ensure that auto-generated column name is within limits of the database.
Thanks russellm for report and Tim Graham for review.
2014-06-17 16:16:02 -04:00
Tim Graham 95cc0e15b4 Fixed #22819 -- Renamed output_type -> output_field in query expression API.
Thanks jorgecarleitao for the suggestion.
2014-06-17 11:57:16 -04:00
Jorge C. Leitão d2cbcbcc76 Improved code style of Query.table_alias() usage. 2014-06-14 15:14:13 +02:00
Jorge C. Leitão 0b980ef857 Removed unnecessary attribute assigment to SQLCompiler. 2014-06-14 15:14:12 +02:00
Jorge C. Leitão e66896226a Fixed #22826 -- Improved internal usage of Query.setup_joins. 2014-06-14 15:14:12 +02:00
Anubhav Joshi 42736ac8e8 Fixed #21430 -- Added a RuntimeWarning when unpickling Models and QuerySets from a different Django version.
Thanks FunkyBob for the suggestion, prasoon2211 for the initial patch,
and akaariai, loic, and charettes for helping in shaping the patch.
2014-06-11 10:03:34 -04:00
Anubhav Joshi 5643a3b51b Fixed #10811 -- Made assigning unsaved objects to FK, O2O, and GFK raise ValueError.
This prevents silent data loss.

Thanks Aymeric Augustin for the initial patch and Loic Bistuer for the review.
2014-06-05 13:12:01 -04:00
Craig de Stigter ce993efda8 Fixed #22690 -- Added a check for proxy models containing fields.
Removed the FieldError raised by ModelBase.__new__ in this case.
2014-06-02 09:32:38 -04:00
Vincent-Vega d04e730224 Fixed #22711 -- Adjusted ordering checks to allow implicit relation fields.
refs #19195.
2014-06-01 15:36:25 -04:00
Alex Gaynor 1dcc603eff Fixed several typos in Django 2014-05-28 17:39:14 -07:00
Víðir Valberg Guðmundsson 6cfa2fae39 Fixed #22720 -- Migrations attempt to create _order twice. 2014-05-29 01:00:30 +02:00
Ramiro Morales d731f48ece Merge pull request #2679 from ramiro/t22421
Fixed #22421 -- Regression in fixtures loading.
2014-05-21 18:57:46 -03:00
Loic Bistuer 870b0a1f86 Fixed the ordering of prefetch lookups so that latter lookups can refer to former lookups.
Thanks Anssi Kääriäinen and Tim Graham for the reviews. Refs #17001 and #22650.
2014-05-21 10:30:48 +07:00
Loic Bistuer bdf3473e64 Fixed #22650 -- Fixed regression on prefetch_related.
Regression from f51c1f59 when using select_related then prefetch_related
on the reverse side of an O2O:

Author.objects.select_related('bio').prefetch_related('bio__books')

Thanks Aymeric Augustin for the report and tests. Refs #17001.
2014-05-21 10:26:04 +07:00
Ramiro Morales 862e1ff234 Fixed #22421 -- Regression in fixtures loading.
Loading fixtures were failing since the refactoring in 244e2b71f5 for
inheritance setups where the chain contains abstract models and the
root ancestor contains a M2M relation.

Thanks Stanislas Guerra for the report.

Refs #20946.
2014-05-17 17:36:45 -03:00
Marc Tamlyn a2dd618e3b Fixed #22648 -- Transform.output_type should respect overridden custom_lookup and custom_transform.
Previously, class lookups from the output_type would be used, but any
changes to custom_lookup or custom_transform would be ignored.
2014-05-17 12:26:15 +02:00
Florian Apolloner 11932e978f Merge pull request #2346 from Markush2010/ticket21905
Fixed #21905 -- Add info message if DateField or TimeField use a fixed value
2014-05-17 12:09:04 +02:00
Tim Graham 1efb2e73bf Fixed typo. 2014-05-16 16:39:12 -04:00
Markus Holtermann 9d8c73f6a1 Fixed #21905 -- Add info message if DateField or TimeField use a fixed value 2014-05-16 18:59:31 +02:00
Vlad Starostin 1be03aff5c Fixed #18389 -- Fixed the way contribute_to_class is called
Now this method is only called only if the object is an instance.
This allows to have field classes as model class attributes.
2014-05-16 10:40:07 -04:00
Russell Keith-Magee 2c176eb95c Refs #21798 - Modified error number to provide room for future expansion. 2014-05-16 15:41:17 +02:00
Daniel Pyrathon cb15231888 Fixed #21798 -- Added check for DateTime mutually exclusive options
Added DateTimeCheckMixin to avoid the use of default, auto_now, and
auto_now_add options together. Added the fields.E151 Error that is raised
if one or more of these options are used together.
2014-05-16 05:57:19 -04:00
Aymeric Augustin f574220f09 Fixed #22508 -- Avoided overwriting select_related.
Previously, known related objects overwrote related objects loaded
though select_related. This could cancel the effect of select_related
when it was used over more than one level.

Thanks boxm for the bug report and timo for bisecting the regression.
2014-05-10 16:39:20 +02:00
Claude Paroz da9cf53cb5 Fixed #22564 -- Prevented unneeded bytestrings in migrations
In some cases, this could lead to migrations written with Python 2
being incompatible with Python 3.
Thanks Tim Graham for the report and Loïc Bistuer for the advices.
2014-05-06 09:13:07 +02:00
Claude Paroz 12474dacef Added a bunch of missing unicode_literals
Refs #22564.
2014-05-06 09:13:07 +02:00
Anssi Kääriäinen 3b7c66a3ac Fixed #22466 -- ordering by reverse foreign key
Ordering by reverse foreign key was broken by custom lookups patch
(commit 20bab2cf9d).

Thanks to everybody who helped solving this issue. Special thanks to
Trac alias takis for reporting this.
2014-05-05 15:28:07 +03:00
Jakub Roztocil 7131e14d00 Fixed #22489 -- missing implemenation for search lookup
When custom lookups were added, converting the search lookup to use
the new Lookup infrastructure wasn't done.

Some changes were needed to the added test, main change done by
committer was ensuring the test works on MySQL versions prior to 5.6.
2014-05-05 14:36:15 +03:00