Commit Graph

3062 Commits

Author SHA1 Message Date
Steadman ed63df3fc2 Fixed #24899 -- Split migrations autodetector._detect_changes() method 2015-06-04 22:35:33 -04: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
Carl Meyer 57dbc87ade Cleaned up docstring style, per Tim Graham review. 2015-06-03 19:20:12 -06:00
Carl Meyer 5c085ea7b3 Refs #24628 -- Added a second test and a docstring comment to avoid regression. 2015-06-03 13:46:01 -06:00
Carl Meyer 492537ac18 Fixed #24628 -- Fixed applied status for squashed migrations. 2015-06-02 16:15:13 -06:00
Adam Chainz 23048d186c Fixed #24866 -- Added Now() database function 2015-06-02 17:59:01 -04:00
Carl Meyer 84522c0d16 Fixed #24895 -- Fixed loading a pair of squashed migrations with a dependency. 2015-06-02 12:07:54 -06:00
Andriy Sokolovskiy 2913d6b77d Fixed #24831 -- Fixed pickling queryset with prefetch_related() after deleting objects. 2015-06-02 09:54:53 -04:00
Tim Graham e1e6399c2c Fixed #24893 -- Fixed lack of unique constraint when changing a field from primary_key=True to unique=True 2015-06-02 09:25:47 -04:00
Tim Graham 5ab8680983 Fixed #24892 -- Fixed quoting of SQL when renaming a field to AutoField in PostgreSQL 2015-06-02 09:13:55 -04:00
Jon Dufresne 44f3ee7716 Fixed #9596 -- Added date transform for DateTimeField. 2015-06-02 08:49:10 -04:00
Yoong Kang Lim 076a63e672 Fixed #24883 -- Added MigrationGraph.__repr__() 2015-06-01 10:45:52 -04:00
Josh Smeaton c7805ee214 Fixed #24699 -- Added aggregate support for DurationField on Oracle 2015-05-30 20:41:33 -04:00
Adam Chainz e60cce4e40 Fixed #24846 -- Added support to MySQL SchemaEditor for all blob/text data types 2015-05-30 20:37:57 -04:00
Andriy Sokolovskiy 80ad5472ce Fixed #24817 -- Prevented loss of null info in MySQL field renaming. 2015-05-28 10:07:52 -04:00
Matt Westcott ff8a02ae0b Fixed #24340 -- Added nested deconstruction for list, tuple and dict values
Nested deconstruction should recursively deconstruct items within list,
tuple and dict values.
2015-05-26 17:10:02 +02: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
Marten Kenbeek d73176a842 Fixed #24848 -- Fixed ValueError for faulty migrations module.
Added apps to unmigrated apps if the migrations module is a file
or a folder missing __init__.py.

Thanks to Ernest0x for the bug report.
2015-05-25 13:47:50 -04:00
Florian Apolloner 92f37e5f5f Well, what should I say: UPS. 2015-05-24 17:33:44 +02:00
Andrea Grandi 43b2d88a5b Fixed #24844 -- Corrected has_changed implementation for HStoreField. 2015-05-24 17:32:16 +02: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 da2c6959c8 Dropped the needs_datetime_string_cast feature.
It has been superseded by the converter infrastructure.
2015-05-17 10:23:13 +02:00
Aymeric Augustin ed83881e64 Fixed #23820 -- Supported per-database time zone.
The primary use case is to interact with a third-party database (not
primarily managed by Django) that doesn't support time zones and where
datetimes are stored in local time when USE_TZ is True.

Configuring a PostgreSQL database with the TIME_ZONE option while USE_TZ
is False used to result in silent data corruption. Now this is an error.
2015-05-17 09:40:28 +02: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
Aymeric Augustin fe6b5e62b1 Normalized the implementation of get_db_converters.
Put the types in the same order and checked for None consistently.
2015-05-17 09:36:27 +02:00
Aymeric Augustin ec186572e6 Removed global timezone-aware datetime converters.
Refs #23820.
2015-05-17 09:36:23 +02:00
Tim Graham eda12ceef1 Removed redundant list() calls. 2015-05-16 10:44:07 -04:00
Claude Paroz 3226050358 Fixed #24791 -- Added fallback when 'postgres' database isn't available
Thanks Carl Meyer and Tim Graham for the reviews.
2015-05-15 18:44:20 +02:00
Claude Paroz ae635cc365 Fixed #24757 -- Recreated MySQL index when needed during combined index removal
Thanks Thomas Recouvreux for the report and Tim Graham for the tests and
review.
2015-05-15 17:07:14 +02:00
Piotr Jakimiak 4157c502a5 Removed unnecessary arguments in .get method calls 2015-05-13 20:51:18 +02:00
Claude Paroz f61c4f490d Fixed #24742 -- Made runserver.check_migrations ignore read-only databases
Thanks Luis Del Giudice for the report, and Aymeric Augustin and Markus
Holtermann for the reviews.
2015-05-13 18:30:36 +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
Milan Broum 95058606c8 Allowed using the sqlite3 backend as much as possible without _sqlite3.
The inner import was dropped during the reorganizing of the database
backends in commit 28308078f3.
2015-05-04 12:59:59 -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
Markus Holtermann 811d7870a5 Moved migration exception classes to shared module
Thanks Aymeric Augustin for the review.
2015-05-02 12:54:44 +02:00
Markus Holtermann 63f9b633f9 Fixed #24725 -- Allowed renaming of target models in ManyToMany relations
This is a regression caused by introducing rendered migration states in
1aa3e09c20 and the _meta refactoring in fb48eb0581.

Thanks to Danilo Bargen for reporting the issue and Marten Kenbeek and
Tim Graham for triaging the bug and providing the initial test case.
2015-04-30 13:27:29 +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
Tim Graham 26996e2d55 Fixed #24499 -- Dropped support for PostGIS 1.5. 2015-04-25 12:21:16 -04:00
Markus Holtermann faad6070ee Fixed #24701 -- Converted model manager names to unicode in migrations
Thanks to Reto Aebersold for reporting the issue and Tim Graham and
Claude Paroz for the review.
2015-04-25 18:17:06 +02:00
Markus Holtermann b93690c465 Fixed #24573 -- Considered new related models for reloading
Thanks tttomekkk for the report.
2015-04-21 11:35:45 +02:00
Matthew Wilkes e4b7daec11 Refs #24354 -- Prevented repointing of relations on superclasses when migrating a subclass's name change
The issue was hidden on 1.8+ until #24573 due to a bug inside the model
reloading process.

Forwardport of patch from ae87ad005f
2015-04-21 11:28:38 +02:00
Marten Kenbeek 1a1f16d67d Fixed #24591 -- Optimized cloning of ModelState objects.
Changed ModelState.clone() to create a shallow copy of self.fields
and self.managers.
2015-04-20 19:53:21 -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
Marten Kenbeek 039d7881b4 Refs #24397 -- Sped up model reloading in ProjectState.
Created bulk_update() context manager on StateApps. Sped up unregistering
models in reload_models() by using this context mananger.
2015-04-20 14:42:23 -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
Claude Paroz 02260ea3f6 Fixed #24595 -- Prevented loss of null info in MySQL field alteration
Thanks Simon Percivall for the report, and Simon Charette and Tim
Graham for the reviews.
2015-04-17 10:25:15 +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
peterfarrell f8e8853b51 Fixed #24637 -- Fixed database introspection with SQLite 3.8.9. 2015-04-14 11:29:59 -04:00
Jay Wineinger 923da0274a Fixed #24611 -- Fixed update() crash with related UUID pk object. 2015-04-13 12:18:24 -04:00
Christopher Luc a7bc00e17b Fixed #24514 -- Made migration writer omit models import if it's unused. 2015-04-10 07:04:26 -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
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
Marten Kenbeek 78d43a5e10 Fixed #24366 -- Optimized traversal of large migration dependency graphs.
Switched from an adjancency list and uncached, iterative depth-first
search to a Node-based design with direct parent/child links and a
cached, recursive depth-first search. With this change, calculating
a migration plan for a large graph takes several seconds instead of
several hours.

Marked test `migrations.test_graph.GraphTests.test_dfs` as an expected
failure due to reaching the maximum recursion depth.
2015-02-23 12:38:53 +01:00
Michael Manfre 7fa7dd48c4 Fixed signature of BaseDatabaseOperations.date_interval_sql() and document the change. 2015-02-22 23:23:16 -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
Shai Berger ceadc94f09 Fixed #24307: Avoided redundant column nullability modifications on Oracle
Thanks Joris Benschop for the report, and Tim Graham for the tests.
2015-02-19 02:39:41 +02:00
Marten Kenbeek 15dc8d1c9d Fixed #24291 - Fixed migration ModelState generation with unused swappable models
Swapped out models don't have a _default_manager unless they have
explicitly defined managers. ModelState.from_model() now accounts for
this case and uses an empty list for managers if no explicit managers
are defined and a model is swapped out.
2015-02-18 19:05:10 +01:00
Adam Chainz e9282747a4 Removed unused foreign_key_re variables in MySQL/Oracle DB backends 2015-02-18 10:22:30 -05:00
Tim Graham fa66ea7532 Refs #24324 -- Fixed UnicodeDecodeError in MigrationWriter on Python 2. 2015-02-17 18:48:15 -05:00
Tim Graham c9ece2e6b9 Refs #24324 -- Fixed UnicodeDecodeError in makemigrations.
If the project path contained a non-ASCII character, Python 2 crashed.
2015-02-17 08:12:49 -05:00
Tim Graham 63c5c98701 Refs #24324 -- Fixed UnicodeEncodeError in SQLite backend while testing.
If 'name' contained non-ASCII characters, the comparison raised a
UnicodeEncodeError on Python 2.
2015-02-17 08:09:46 -05:00
Tim Graham 3adc5f1ee6 Fixed #24335 -- Bumped required psycopg2 version to 2.4.5 (2.5 for contrib.postgres). 2015-02-16 18:07:27 -05:00
Markus Holtermann b29f3b5120 Fixed #24225, #24264, #24282 -- Rewrote model reloading in migration project state
Instead of naively reloading only directly related models (FK, O2O, M2M
relationship) the project state needs to reload their relations as well
as the model changes as well. Furthermore inheriting models (and super
models) need to be reloaded in order to keep inherited fields in sync.

To prevent endless recursive calls an iterative approach is taken.
2015-02-16 19:31:51 +01: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
Aymeric Augustin a73c8540a8 Removed 'autocommit' options for the psycopg2 backend.
It was documented as not having any effect since Django 1.6.
2015-02-14 18:51:18 +01:00
Aymeric Augustin 28e97a9bdc Cleaned up init_connection_state in the psycopg2 backend.
settings_dict['TIME_ZONE'] is set in ConnectionHandler.ensure_defaults.
2015-02-14 18:51:18 +01:00
Aymeric Augustin 76356d963c Fixed #24318 -- Set the transaction isolation level with psycopg >= 2.4.2. 2015-02-14 18:51:11 +01:00
Loic Bistuer 18c0aaa912 Fixed #24289 -- Reversed usage of Field.many_to_one and one_to_many.
Thanks Carl Meyer and Tim Graham for the reviews and to all involved
in the discussion.
2015-02-14 02:28:24 +07:00
Markus Holtermann f287bec583 Fixed #24184 -- Prevented automatic soft-apply of migrations
Previously Django only checked for the table name in CreateModel
operations in initial migrations and faked the migration automatically.
This led to various errors and unexpected behavior. The newly introduced
--fake-initial flag to the migrate command must be passed to get the
same behavior again. With this change Django will bail out in with a
"duplicate relation / table" error instead.

Thanks Carl Meyer and Tim Graham for the documentation update, report
and review.
2015-02-13 14:29:59 +01:00
Josh Smeaton de0241eb98 Fixed #24319 -- Added validation for UUID model field 2015-02-13 09:45:53 +11:00
Simon Charette 9239f1dda7 Refs #24215 -- Prevented pending lookup pollution by abstract models. 2015-02-12 13:07:09 -05:00
Josh Smeaton e2d6e14662 Refs #14030 -- Improved expression support for python values 2015-02-12 08:46:25 +11:00
Daniel Pyrathon 19188826b4 Fixed #24146 -- Allowed model._meta.get_field() to be used after apps.models_ready 2015-02-10 19:55:06 -05:00
Josh Smeaton 1fbe8a2de3 Fixed #24200 -- Made introspection bypass statement cache 2015-02-10 23:24:34 +02:00
Aymeric Augustin 1b8af4cfa0 Disallowed importing concrete models without an application.
Removed fragile algorithm to find which application a model belongs to.

Fixed #21680, #21719. Refs #21794.
2015-02-10 21:41:19 +01:00
Loic Bistuer c8e24bbc9b Fixed isort import that's inconsistent between platforms. 2015-02-11 02:24:14 +07:00
Tim Graham 2d7c27d387 Fixed #24302 -- Added DurationField.formfield() 2015-02-09 10:20:01 -05:00
Tim Graham e144e0e237 Removed unnecessary parentheses in model check messages. 2015-02-09 08:53:58 -05:00
Aron Podrigal 4d73303ee9 Fixed #24249 -- Improved field shadowing validation in model multi-inheritance. 2015-02-09 08:37:55 -05:00
я котик пур-пур 981bd64dfb Unified local imports in django.db.backends.mysql. 2015-02-09 08:23:17 -05:00
Markus Holtermann 2832a9b028 Revert "Fixed #24075 -- Prevented running post_migrate signals when unapplying initial migrations of contenttypes and auth"
This reverts commit 737d24923a.
2015-02-07 20:14:49 +01:00
Collin Anderson db77915c9f Fixed E265 comment style 2015-02-06 09:30:35 -05:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Tim Graham 0f54cf28c0 Added UUIDField.deconstruct() 2015-02-05 19:15:02 -05:00
Loic Bistuer 20eb51ce0d Fix small regression caused by 71ada3a8e6.
During direct assignment, evaluating the iterable before the transaction
is started avoids leaving the transaction dirty if an exception is raised.
This is slightly more wasteful but probably not enough to warrant a change
of behavior.

Thanks Anssi for the feedback. Refs #6707.
2015-02-05 16:59:56 +07:00
Loic Bistuer 71ada3a8e6 Fixed #6707 -- Added RelatedManager.set() and made descriptors' __set__ use it.
Thanks Anssi Kääriäinen, Carl Meyer, Collin Anderson, and Tim Graham for the reviews.
2015-02-05 12:45:08 +07:00
Anssi Kääriäinen 4d3470e52e Removed non-used EmptyShortCircuit 2015-02-04 09:26:40 -05:00
Anssi Kääriäinen 7145c8a62a Removed EverythingNode
At the same time, made sure that empty nodes in where clause match
everything.
2015-02-04 09:26:40 -05:00
Anssi Kääriäinen afe0bb7b13 Fixed #24268 -- removed Query.having
Instead of splitting filter clauses to where and having parts before
adding them to query.where or query.having, add all filter clauses to
query.where, and when compiling the query split the where to having and
where parts.
2015-02-04 09:26:40 -05:00
Aron Podrigal 79f27f2b61 Fixed #15321 -- Honored ancestors unique checks.
Thanks to Tim for the review.
2015-02-03 18:56:53 -05:00
Simon Charette 65e005f8cd Fixed #24266 -- Changed get_parent_list to return a list ordered by MRO.
Thanks to Aron Podrigal for the initial patch and Tim for the review.
2015-02-03 16:40:31 -05:00
Tim Graham 0e489c19f1 Reverted "Fixed #24146 -- Fixed a missing fields regression in admin checks."
This reverts commit e8171daf0c.

A new solution is forthcoming.
2015-02-03 15:23:39 -05:00
Anssi Kääriäinen 8adc59038c Fixed #23617 -- Added get_pk_value_on_save()
The method is mainly intended for use with UUIDField. For UUIDField we
want to call the field's default even when primary key value is
explicitly set to None to match the behavior of AutoField.

Thanks to Marc Tamlyn and Tim Graham for review.
2015-02-03 09:23:44 -05:00
Tim Graham f79ce63fdb Removed query.alias_diff()
This function is unused since 6fe2b001db
2015-02-01 21:37:25 -05:00
Tim Graham 99ca7c2bd3 Removed Query.raise_field_error()
This method was inadvertently reintroduced in
f59fd15c49
2015-02-01 20:26:04 -05:00
Tim Graham 75303b01a9 Fixed #24245 -- Added introspection for database defaults.
Needed for tests for migrations handling of database defaults.
2015-01-31 12:33:11 -05:00
Tim Graham 64a899dc81 Removed PostgreSQL DatabaseWrapper._set_isolation_level().
This method is unused since 8717b0668c.
2015-01-31 11:05:26 -05:00
Claude Paroz a0b5f15ea5 Fixed #14483 -- Allowed using subqueries with GIS lookups 2015-01-30 20:27:18 +01:00
Tim Graham 293fd5da5b Reverted "Fixed #6785 -- Made QuerySet.get() fetch a limited number of rows."
This reverts commit da79ccca1d.

This optimized the unsuccessful case at the expense of the successful one.
2015-01-30 12:51:12 -05:00
Loic Bistuer 4c3bfe9053 Fixed #24211 -- Removed ValuesQuerySet() and ValuesListQuerySet().
Thanks Anssi Kääriäinen, Marc Tamlyn, and Tim Graham for the reviews.
2015-01-30 22:02:58 +07:00
Tim Graham 29c0073335 Fixed #24164 -- Fixed Oracle GIS limited aggregation test failure. 2015-01-30 06:28:47 -05:00
Simon Charette eb4cdfbdd6 Fixed #23940 -- Allowed model fields to be named `exact`.
An explicit `__exact` lookup in the related managers filters
was interpreted as a reference to a foreign `exact` field.

Thanks to Trac alias zhiyajun11 for the report, Josh for the investigation,
Loïc for the test name and Tim for the review.
2015-01-29 14:40:20 -05:00
Tim Graham f609731118 Removed ForeignObjectRel.get_lookup_constraint() [unused]. 2015-01-29 13:31:12 -05:00
Tim Graham 18f3e79b13 Removed threading fallback imports.
Django imports threading in many other places without fallback.
2015-01-28 10:23:25 -05:00
Josh Smeaton 14d0bd67d4 Refs #14030 -- Renamed CombinableMixin to Combinable
Removed unused method and updated docstrings.
2015-01-28 10:59:30 +11:00
Josh Smeaton 7171bf755b Refs #14030 -- Added repr methods to all expressions 2015-01-28 10:59:30 +11:00
Loic Bistuer 84b6c76830 Fixed #24210 -- Cleaned up relational fields __init__().
Thanks Collin Anderson and Tim Graham for the reviews.
2015-01-27 22:35:49 +07:00
Josh Smeaton 8196e4bdf4 Fixed #24154 -- Backends can now check support for expressions 2015-01-27 12:20:06 +11:00
Andriy Sokolovskiy 38c17871bb Fixed #24104 -- Fixed check to look on field.many_to_many instead of class instance 2015-01-22 18:41:19 +01:00
Loic Bistuer d450af8a26 Fixed small inconsistency when handling aggregate's default_alias.
Refs #14030.
2015-01-22 00:44:14 +07:00
Adam Taylor 039465a6a7 Fixed typos in code comments. 2015-01-20 12:18:03 -05:00
Tim Graham be1357e709 Fixed a query failure on Python 3.5; refs #23763.
The failure was introduced in Django by
c7fd9b242d and the change in
Python 3.5 is https://hg.python.org/cpython/rev/a3c345ba3563.
2015-01-20 08:13:53 -05:00
Josh Smeaton 61c102d010 Fixed #24183 -- Fixed wrong comparisons in Substr 2015-01-20 12:09:15 +11:00
Markus Holtermann 7f20041bca Fixed #24155 -- Maintained kwargs and import order in migration writer
Thanks Tomas Dobrovolny for the report and Tim Graham for the review.
2015-01-20 01:24:41 +01:00
Tim Graham 378a0d27d6 Advanced deprecation warnings for Django 1.9. 2015-01-19 12:22:41 -05:00
Tim Graham 33457cd3b0 Removed IPAddressField per deprecation timeline; refs #20439. 2015-01-19 11:12:57 -05:00
Tim Graham 5008a4db44 Removed legacy ORM lookup support per deprecation timeline; refs #16187. 2015-01-19 11:11:30 -05:00
Markus Holtermann 5792e6a88c Fixed #24163 -- Removed unique constraint after index on MySQL
Thanks Łukasz Harasimowicz for the report.
2015-01-19 16:52:26 +01:00
Josh Smeaton 69c6a6868f Fixed #24174 -- Fixed extra order by descending 2015-01-19 12:51:27 +11:00
Tim Graham 2b039d966f Removed obsolete SQL generation methods. 2015-01-18 15:58:06 -05:00
Tim Graham 7e8cf74dc7 Removed support for syncing apps without migrations per deprecation timeline.
Kept support for creating models without migrations when running tests
(especially for Django's test suite).
2015-01-18 15:58:06 -05:00
Tim Graham 2cd00424c4 Removed support for callable QuerySet arguments per deprecation timeline; refs #11629. 2015-01-18 14:01:25 -05:00
Tim Graham 3b570dbcdb Removed BaseDatabaseValidation.validate_field() per deprecation timeline. 2015-01-17 14:58:09 -05:00
Tim Graham e1b93dbbef Removed deprecated aliases in django.db.models. 2015-01-17 14:57:34 -05:00
Tim Graham b845951fd4 Required sqlparse for SQL splitting per deprecation timeline. 2015-01-17 10:20:30 -05:00
Tim Graham 4aa089a9a9 Removed support for custom SQL per deprecation timeline. 2015-01-17 10:16:06 -05:00
Tim Graham f635d75935 Removed support for old-style test database settings per deprecation timeline. 2015-01-17 09:55:18 -05:00
Tim Graham f6463bb380 Removed the syncdb command per deprecation timeline. 2015-01-17 09:20:12 -05:00
Tim Graham f4f24d30e0 Removed pre_syncdb and post_syncdb signals per deprecation timeline. 2015-01-17 09:07:00 -05:00