Commit Graph

2845 Commits

Author SHA1 Message Date
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
Patryk Zawadzki 0385dad073 Fixed #24513 -- Made sure a model is only rendered once during reloads
This also prevents state modifications from corrupting previous states.
Previously, when a model defining a relation was unregistered first,
clearing the cache would cause its related models' _meta to be cleared
and would result in the old models losing track of their relations.
2015-04-07 14:49:47 +02:00
Jon Dufresne 2cf58e80d1 Fixed #24584 -- Fixed microsecond handling with older MySQLdb 2015-04-06 22:43:51 +02:00
Marten Kenbeek e8e4f978dd Fixed #24278 -- Fixed serialization of migration operations.
Fixed MigrationWriter.serialize() to correctly handle migration
operations by utilizing OperationWriter.

Thanks Piotr Maliński for the report.
2015-04-05 20:26:21 +02:00
Marten Kenbeek d597174bd4 Refs #24278 -- Allowed multi-line serializations in OperationWriter.
Changed OperationWriter to support multi-line serialized values with
correct indentation.
2015-04-05 20:19:24 +02:00
Alex Hill 07ba148d9e Cleaned up use of context manager in SQLite schema editor 2015-04-03 09:13:55 -04:00
Baptiste Mispelon 30a3c2f74c Fixed #24566 -- Added support for serializing timedelta
Thanks to knbk for the report.
2015-04-02 17:21:20 +02:00
Markus Holtermann 3e7d9d05ac Refs #24554 -- Prevented rendering of unused migrations
Thanks Claude Paroz and Tim Graham for the review
2015-04-01 02:00:34 +02:00
Markus Holtermann 57dc8dd3fa Fixed #24554 -- Sped up migrations by rendering initial apps when they are first needed
Calling Migration.mutate_state() now also allows to do in_place
mutations in case an intermediate state is thrown away later.

Thanks Anssi Kääriäinen for the idea, Ryan Hall for parts of the patch,
and Claude Paroz and Tim Graham for the review
2015-04-01 02:00:05 +02:00
Andriy Sokolovskiy 29b4a3f513 Removed duplicate attribute in MySQL DatabaseSchemaEditor. 2015-03-30 19:23:41 -04:00
Markus Holtermann c5cc332bf2 Fixed #24550 -- Added migration operation description to sqlmigrate output
Thanks Tim Graham for the review.
2015-03-30 16:31:20 +02:00
Simon Charette dc27f3ee0c Fixed #19259 -- Added group by selected primary keys support. 2015-03-29 22:03:30 -04:00
Marten Kenbeek 75430be86f Refs #24366 -- Fixed recursion depth error in migration graph
Made MigrationGraph forwards_plan() and backwards_plan() fall back to an
iterative approach in case the recursive approach exceeds the recursion
depth limit.
2015-03-29 16:08:07 +02:00
Marten Kenbeek bc83add04c Refs #24366 -- Renamed arguments in MigrationGraph, renamed tests 2015-03-29 16:07:58 +02:00
Markus Holtermann c7ec3c07e7 Fixed #24537 -- Ignored field order in RenameModel detection
Thanks to David Sanders for the report and test and Simon Charette for
the review.
2015-03-28 20:45:15 +01: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
Andrei Kulakov e2bfcab065 Fixed #24394 -- Allowed running tests with empty default dictionary. 2015-03-25 17:56:59 -04:00
Alex Hill 7a75ed1a4f Removed untouched branch in StateApps.__init__() 2015-03-25 16:48:26 -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
Tim Graham 13bc311cdb Removed getLogger alias in django.utils.log. 2015-03-24 08:41:05 -04:00
Claude Paroz 01ec127bae Fixed #12400 -- Allowed geometry fields in unique_together
Thanks Tim Graham for the review.
2015-03-23 19:52:49 +01:00
Baptiste Mispelon 1aadade373 Fixed #24521 -- Added support for serializing frozensets in migrations. 2015-03-23 15:38:25 +01: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
Alex Hill 880393a902 Explicitly disable FK constraints in SQLite editor 2015-03-21 10:31:07 +01:00
Alex Hill 6c58e53d5d Safer table alterations under SQLite
Table alterations in SQLite require creating a new table and copying
data over from the old one. This change ensures that no Django model
ever exists with the temporary table name as its db_table attribute.
2015-03-21 10:31:07 +01: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
Marten Kenbeek e272904ff7 Fixed #23407 -- Extended coverage of makemigrations --noinput option.
Changed --noinput option in makemigrations to suppress all user prompts,
not just when combined with --merge.
2015-03-08 19:44:14 +01:00
Marten Kenbeek 888c9b6429 Fixed #24397 -- Sped up rendering multiple model states.
Set apps.ready to False when rendering multiple models. This prevents
that the cache on Model._meta is expired on all models after each time a
single model is rendered. Prevented that Apps.clear_cache() refills the
cache on Apps.get_models(), so that the wrong value cannot be cached
when cloning a StateApps.
2015-03-08 13:54:49 +01:00
Jean-Louis Fuchs f4f0060fea Fixed #24447 -- Made migrations add FK constraints for existing columns
When altering from e.g. an IntegerField to a ForeignKey, Django didn't
add a constraint.
2015-03-07 14:09:56 +01:00
Josh Smeaton ceaf31adff Fixed #24420 -- Allowed ordering by case expressions 2015-03-06 13:30:02 +11:00
Markus Holtermann a9e29fae10 Fixed #24435 -- Prevented m2m field removal and addition in migrations when changing blank
Thanks Mark Tranchant for the report an Tim Graham for the test and
review.
2015-03-04 14:26:49 +01:00
Tim Graham 4e8b167e4d Fixed MySQL build failure introduced by refs #24390.
Added table_name back to _create_index_sql() to prevent
duplicate index names on MySQL.
2015-03-02 13:07:34 -05:00
László Károlyi f37c11eea3 Fixed #24390 -- Made migration index names deterministic. 2015-03-02 09:25:19 -05: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
Aymeric Augustin b9c619abc1 Prevented makemigrations from writing in sys.path[0].
There's no reason to assume that sys.path[0] is an appropriate location
for generating code. Specifically that doesn't work with extend_sys_path
which puts the additional directories at the end of sys.path.

In order to create a new migrations module, instead of using an
arbitrary entry from sys.path, import as much as possible from the path
to the module, then create missing submodules from there.

Without this change, the tests introduced in the following commit fail,
which seems sufficient to prevent regressions for such a refactoring.
2015-02-23 19:55:10 +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