Commit Graph

2125 Commits

Author SHA1 Message Date
Claude Paroz 4c5bc1ac30 Removed double import in mysql base.py 2013-09-24 10:25:39 +02:00
Aymeric Augustin a5b062576b Removed a few trailing backslashes.
We have always been at war with trailing backslashes.
2013-09-22 14:04:10 +02:00
Anssi Kääriäinen 50633e7353 Fixed #12568 -- no error when accessing custom field's descriptor
The SubfieldBase's descriptor caused an AttributeError when accessed
from the class. Introspection didn't like that.

Patch by Trac alias supervacuo.
2013-09-18 10:03:52 +03:00
Markus Holtermann 5a424c2393 Fixed #21114 -- Migrations must not have a dependency to themselves. 2013-09-17 11:47:19 -04:00
Anssi Kääriäinen 9400142132 Fixed #21109 -- made db cursor error wrapping faster 2013-09-17 12:18:55 +03:00
Tim Graham f40c82213f Added backwards compatability shims for util modules.
refs #17627
2013-09-16 12:53:42 -04:00
Tim Graham 18ffdb1772 Fixed #17627 -- Renamed util.py files to utils.py
Thanks PaulM for the suggestion and Luke Granger-Brown and
Wiktor Kołodziej for the initial patch.
2013-09-16 12:52:05 -04:00
Alex Gaynor bac86ad1a3 REmoved some unused imports 2013-09-14 12:34:57 -07:00
Alex Gaynor 5c645ec81a Merge branch 'master' of https://github.com/django/django 2013-09-14 12:32:45 -07:00
Alex Gaynor 496b4d0331 Removed an import * that was masking importing stuff from the wrong location 2013-09-14 12:32:25 -07:00
Anssi Kääriäinen ff723d894d Fixed #20950 -- Instantiate OrderedDict() only when needed
The use of OrderedDict (even an empty one) was surprisingly slow. By
initializing OrderedDict only when needed it is possible to save
non-trivial amount of computing time (Model.save() is around 30% faster
for example).

This commit targetted sql.Query only, there are likely other places
which could use similar optimizations.
2013-09-14 20:52:17 +03:00
Michael Manfre c89d80e2cc Fixed #21097 - Added DatabaseFeature.can_introspect_autofield 2013-09-14 09:48:59 +03:00
Gregor MacGregor b2b763448f Fixed #20841 -- Added messages to NotImplementedErrors
Thanks joseph at vertstudios.com for the suggestion.
2013-09-10 11:09:59 -04:00
Loic Bistuer d59f1993f1 Made MigrationWriter look for a "deconstruct" attribute on functions.
Refs #20978.
2013-09-10 10:12:23 -04:00
Loic Bistuer 5df8f749e6 Fixed #20978 -- Made deletion.SET_NULL more friendly for MigrationWriter.serialize. 2013-09-10 10:12:23 -04:00
Садовский Николай 1185370c2c Fixed #20707 -- Added explicit quota assignment to Oracle test user
To enable testing on Oracle 12c
2013-09-09 16:25:13 +03:00
Alex Gaynor 0ee8aa5c39 Removed an unused local var 2013-09-08 07:42:16 -07:00
Aymeric Augustin 31e16c1343 Negligible style fix. 2013-09-07 13:48:37 -05:00
Andrew Godwin bacbbb481d RunSQL migration operation and alpha SeparateDatabaseAndState op'n. 2013-09-07 11:03:38 -05:00
Alex Gaynor 2530735d2d Fixed a number of flake8 errors -- particularly around unused imports and local variables 2013-09-06 21:56:40 -07:00
Loic Bistuer 37d46b20fc Fixed regression introduced by efd1e60, 'map' returns an iterator on PY3. 2013-09-07 08:00:11 +07:00
Eric Boersma ded40142a9 Fixed #20007 -- Configured psycopg2 to return UnicodeArrays
Thanks hogbait for the report.
2013-09-06 20:43:58 -04:00
Loic Bistuer adc0ab3386 Fixed #21037 -- Made MigrationWriter raise a ValueError when serializing lambda functions. 2013-09-06 20:13:01 -04:00
Aymeric Augustin b4cd8169de Fixed #11811 -- Data-loss bug in queryset.update.
It's now forbidden to call queryset.update(field=instance) when instance
hasn't been saved to the database ie. instance.pk is None.
2013-09-06 17:15:23 -05:00
Aymeric Augustin 73f38eb4d1 Minor factorization. 2013-09-06 17:15:23 -05:00
Andrew Godwin efd1e6096e Adding 'sqlmigrate' command and quote_parameter to support it. 2013-09-06 15:28:12 -05:00
Andrew Godwin 05e14e8eaf Migration autodetector now corerctly deals with proxy models 2013-09-06 12:39:46 -05:00
Andrew Godwin cdeff3acc2 Project/ModelState now correctly serialize multi-model inheritance 2013-09-06 12:16:03 -05:00
Chris Wilson eade315da1 Fixed #10164 -- Made AutoField increase monotonically on SQLite
Thanks malte for the report.
2013-09-06 12:31:17 -04:00
Andrew Godwin 630eb0564a Fix SchemaEditor.__exit__ to handle exceptions correctly 2013-09-06 11:09:16 -05:00
Andrew Godwin 9f6e6009a4 Add --list option to migrate command 2013-09-06 11:06:19 -05:00
Andrew Godwin 32838a5beb Make db.migrations ignore South-style migrations. 2013-09-06 10:35:53 -05:00
Loic Bistuer e1266e50b2 Fixed #21015 -- Fixed MigrationLoader when importlib.import_module returns a file module or an empty directory. 2013-09-06 08:30:19 -04:00
Loic Bistuer 82bbb9fe81 Fixed #21014 -- Fixed gobbled ImportError in MigrationLoader. 2013-09-06 08:30:18 -04:00
Eric Boersma 4d13cc56de Fixed #21035 -- Changed docs to treat the acronym SQL phonetically.
The documentation and comments now all use 'an' to
refer to the word SQL and not 'a'.
2013-09-05 20:14:58 -04:00
Aymeric Augustin 4170b9f402 Tested exc_type instead of exc_value in __exit__.
exc_value might be None even though there's an exception, at least on
Python 2.6. Thanks Thomas Chaumeny for the report.

Fixed #21034.

Forward-port of a8624b2 from 1.6.x.
2013-09-04 16:19:04 -05:00
Loic Bistuer 34d52fd32e Fixed #21010 -- Changed ModelState to only copy _meta.local_fields. 2013-09-04 14:05:59 -04:00
Aymeric Augustin 868b4c921c Used six.moves.zip_longest, new in six 1.4.0. 2013-09-02 12:11:16 +02:00
Aymeric Augustin 365c3e8b73 Replaced "not PY3" by "PY2", new in six 1.4.0. 2013-09-02 12:11:02 +02:00
Loic Bistuer ff9e116198 Fixed #21008 -- Made MigrationWriter handle Promise objects. 2013-08-31 20:26:44 -04:00
Carl Meyer 7211741fc5 Fixed #20999 - Allow overriding formfield class with choices, without subclass restrictions.
Refs #18162. Thanks claudep and mjtamlyn for review.
2013-08-30 17:43:10 -06:00
Simon Charette 11cd7388f7 Fixed #20989 -- Removed useless explicit list comprehensions. 2013-08-30 10:57:51 -04:00
Anssi Kääriäinen e973ee6a98 Fixed #20988 -- Added model meta option select_on_save
The option can be used to force pre 1.6 style SELECT on save behaviour.
This is needed in case the database returns zero updated rows even if
there is a matching row in the DB. One such case is PostgreSQL update
trigger that returns NULL.

Reviewed by Tim Graham.

Refs #16649
2013-08-30 09:41:07 +03:00
Anssi Kääriäinen 13be3bfef1 Removed stale add_q() comment 2013-08-30 09:45:32 +03:00
Tim Graham c7d0ff0cad Fixed #20989 -- Removed explicit list comprehension inside dict() and tuple()
Thanks jeroen.pulles at redslider.net for the suggestion and
helper script.
2013-08-29 12:11:03 -04:00
Tim Graham f19a3669b8 Fixed #14786 -- Fixed get_db_prep_lookup calling get_prep_value twice if prepared is False.
Thanks homm for the report and Aramgutang and lrekucki for work on
the patch.
2013-08-29 11:13:34 -04:00
Claude Paroz 169637649b Fixed #20984 -- Stopped decoding bytes in sqlite3 adapter on Python 3
Thanks lvella at gmail.com for the report.
2013-08-29 08:39:06 +02:00
Andrew Godwin 35230adf63 Python 3 compat fix for callable() 2013-08-23 17:59:35 +01:00
Andrew Godwin 2787de652a Fix location of tablespace clauses in schema backend column SQL 2013-08-23 14:38:55 +01:00
Andrew Godwin 5569b0b92f Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/backends/oracle/base.py
	django/db/backends/postgresql_psycopg2/base.py
	django/db/models/signals.py
	tests/queries/tests.py
2013-08-23 12:36:53 +01:00
Andrew Godwin 9cc6cfc405 Fix Oracle's default handling and schema-prepared-statement issue 2013-08-23 12:07:55 +01:00
Anssi Kääriäinen 6af05e7a0f Fixed model.__eq__ and __hash__ for no pk value cases
The __eq__ method now considers two instances without primary key value
equal only when they have same id(). The __hash__ method raises
TypeError for no primary key case.

Fixed #18864, fixed #18250

Thanks to Tim Graham for docs review.
2013-08-22 17:24:07 +03:00
Tim Graham 768bbf3efe Revert "Fixed #20956 -- Removed useless check in django.db.utils"
This reverts commit ce0e86cf76.

The check is necessary if 'ENGINE' is an empty string.
Thanks apollo13 for pointing this out.
2013-08-22 09:47:17 -04:00
Dima Kurguzov ce0e86cf76 Fixed #20956 -- Removed useless check in django.db.utils 2013-08-22 08:53:14 -04:00
Anssi Kääriäinen 8d65b6082c Fixed #20955 -- select_related regression
In cases where the same connection (from model A to model B along the
same field) was needed multiple times in a select_related query, the
join setup code mistakenly reused an existing join.
2013-08-22 10:51:07 +03:00
Tim Graham 3f416f6379 Fixed a regression with get_or_create and virtual fields.
refs #20429

Thanks Simon Charette for the report and review.
2013-08-21 22:32:04 +01:00
Anssi Kääriäinen 244e2b71f5 Fixed #20946 -- model inheritance + m2m failure
Cleaned up the internal implementation of m2m fields by removing
related.py _get_fk_val(). The _get_fk_val() was doing the wrong thing
if asked for the foreign key value on foreign key to parent model's
primary key when child model had different primary key field.
2013-08-21 22:32:04 +01:00
Simon Charette 1db5fce1ee Oracle also treats NULLs as largests values when ordering. 2013-08-21 22:32:03 +01:00
Anssi Kääriäinen f5552571dc Fixed #20820 -- Model inheritance + m2m fixture loading regression
Tests by Tim Graham, report from jeroen.pulles@redslider.net.
2013-08-21 22:31:50 +01:00
Anssi Kääriäinen ced3e6b17d Fixed test failure caused by different NULL ordering between backends 2013-08-21 22:31:50 +01:00
Anssi Kääriäinen cea7204504 Fixed #14056 -- Made sure LEFT JOIN aren't trimmed in ORDER BY
If LEFT JOINs are required for correct results, then trimming the join
can lead to incorrect results. Consider case:

TBL A: ID | TBL B: ID  A_ID
       1           1   1
       2
Now A.order_by('b__a') did use a join to B, and B's a_id column. This
was seen to contain the same value as A's id, and so the join was
trimmed. But this wasn't correct as the join is LEFT JOIN, and for row
A.id = 2 the B.a_id column is NULL.
2013-08-21 22:30:46 +01:00
Simon Charette 63378163f9 Fixed #20943 -- Weakly reference senders when caching their associated receivers 2013-08-21 22:30:45 +01:00
Andrew Godwin 2e7f45a372 Change autodetector changes API to be just one method 2013-08-21 22:25:15 +01:00
Tim Graham f7290581fe Fixed a regression with get_or_create and virtual fields.
refs #20429

Thanks Simon Charette for the report and review.
2013-08-21 08:30:21 -04:00
Anssi Kääriäinen b065aeb17f Fixed #20946 -- model inheritance + m2m failure
Cleaned up the internal implementation of m2m fields by removing
related.py _get_fk_val(). The _get_fk_val() was doing the wrong thing
if asked for the foreign key value on foreign key to parent model's
primary key when child model had different primary key field.
2013-08-21 08:32:19 +03:00
Simon Charette 859e678b3d Oracle also treats NULLs as largests values when ordering. 2013-08-20 12:28:59 -04:00
Anssi Kääriäinen 1ed77e7782 Fixed #20820 -- Model inheritance + m2m fixture loading regression
Tests by Tim Graham, report from jeroen.pulles@redslider.net.
2013-08-20 16:54:05 +03:00
Anssi Kääriäinen 8dc76c4b91 Fixed test failure caused by different NULL ordering between backends 2013-08-20 11:33:44 +03:00
Anssi Kääriäinen 905409855c Fixed #14056 -- Made sure LEFT JOIN aren't trimmed in ORDER BY
If LEFT JOINs are required for correct results, then trimming the join
can lead to incorrect results. Consider case:

TBL A: ID | TBL B: ID  A_ID
       1           1   1
       2
Now A.order_by('b__a') did use a join to B, and B's a_id column. This
was seen to contain the same value as A's id, and so the join was
trimmed. But this wasn't correct as the join is LEFT JOIN, and for row
A.id = 2 the B.a_id column is NULL.
2013-08-20 10:55:00 +03:00
Simon Charette e55ca60903 Fixed #20943 -- Weakly reference senders when caching their associated receivers 2013-08-20 01:53:58 -04:00
Andrew Godwin b6a957f0ba Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	docs/ref/django-admin.txt
2013-08-19 18:30:48 +01:00
Anssi Kääriäinen 7bc57a6d71 Fixed #11881 -- removed junk from aggregation subqueries
There were clauses that weren't needed in the subqueries. These were
ORDER BY, SELECT FOR UPDATE and related selections.
2013-08-19 16:15:09 +03:00
Anssi Kääriäinen 7737305a4f Fixed #12886 -- aggregation over sliced queryset 2013-08-19 16:00:17 +03:00
Andrew Godwin 52edc16086 Add more stringent M2M tests and fix the bug they exposed 2013-08-19 13:50:26 +01:00
Andrew Godwin 5b522cd85a Minor oracle fixes 2013-08-19 13:12:48 +01:00
Anssi Kääriäinen 4668c142dc Made Model.__eq__ consider proxy models equivalent
Fixed #11892, fixed #16458, fixed #14492.
2013-08-19 09:51:28 +03:00
Harm Geerts 240886183b Fixed #20829 -- Skip postgis metadata tables with introspection 2013-08-16 21:14:29 +02:00
Andrew Godwin 157604a87f Oracle schema backend, passes most tests and is pretty complete. 2013-08-13 20:54:57 +01:00
Loic Bistuer 163a34ce4b Fixed #20883 -- Made model inheritance find parent links in abstract parents 2013-08-13 15:14:11 +03:00
Anssi Kääriäinen dcdc579d16 Fixed #20874 -- bump_prefix() in nested subqueries
Also made some cleanup to build_filter() code by introducing submethods
solve_lookup_type() and prepare_lookup_value().
2013-08-13 14:11:52 +03:00
Andrew Godwin 44f907dd98 Start of getting Oracle to do schema stuff 2013-08-12 20:05:20 +01:00
Andrew Godwin b61b634628 Fix weird planning issues when already fully migrated. 2013-08-11 15:28:51 +01:00
Andrew Godwin b4c493ecd3 Remove keep_default from add_field 2013-08-11 14:28:55 +01:00
Andrew Godwin d985fd7a18 Fix tablespace command 2013-08-11 14:27:42 +01:00
Andrew Godwin ae19315b4d Support index_together during model creation 2013-08-11 14:23:31 +01:00
Andrew Godwin 21be9fef7b Stop being overcautious about Field.rel 2013-08-11 00:01:30 +01:00
Andrew Godwin 7702819441 Update get_constraints with better comments 2013-08-10 23:58:12 +01:00
Andrew Godwin 7970d97a70 Docs tweaks (thanks timgraham) 2013-08-10 20:00:12 +01:00
Andrew Godwin f093646bfc Remove pointless comment. 2013-08-09 17:47:13 +01:00
Andrew Godwin 9b4a789eef Add [y/n] to autodetector questions and allow for default value 2013-08-09 17:45:19 +01:00
Andrew Godwin ae96ad872f Remove pointless fetch_results param 2013-08-09 17:42:56 +01:00
Andrew Godwin fb16ee5a31 Remove commented-out print 2013-08-09 17:41:39 +01:00
Andrew Godwin 9f73629420 utils.importlib is deprecated 2013-08-09 17:36:16 +01:00
Andrew Godwin 588b523233 Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/models/options.py
2013-08-09 14:37:37 +01:00
Tim Graham ddae74b64c Fixed #9057 -- Added default_permissions model meta option.
Thanks hvendelbo for the suggestion and koenb for the draft patch.
2013-08-09 09:19:52 -04:00
Andrew Godwin de64c4d6e9 Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/core/management/commands/flush.py
	django/core/management/commands/syncdb.py
	django/db/models/loading.py
	docs/internals/deprecation.txt
	docs/ref/django-admin.txt
	docs/releases/1.7.txt
2013-08-09 14:17:30 +01:00
Anssi Kääriäinen c7739e30b2 Fixed #17424 -- annotate() + exclude() bug
The bug was already fixed by 01b9c3d519,
so only tests added.

At the same time promote_joins()'s uncoditional flag is gone, it isn't
needed for anything any more.
2013-08-07 12:53:33 +03:00
Alex Cucu 1c64a0f29e Fixed #19918 -- Modified select_for_update to run on the write database. 2013-08-06 09:50:59 -04:00
Tim Graham 04489c7dbf Fixed #17667 -- Prevented app loading from skipping nonexistent apps after the first try
Thanks ea2100@ for the report and akaariai for the patch.
2013-08-05 13:34:35 -04:00
Curtis Maloney 07876cf02b Deprecated SortedDict (replaced with collections.OrderedDict)
Thanks Loic Bistuer for the review.
2013-08-04 07:09:39 -04:00
Tim Graham aa830009de Fixed #17519 -- Fixed missing SQL constraints to proxy models.
Thanks thibaultj for the report, jenh for the patch,
and charettes for the tests.
2013-08-02 07:41:56 -04:00
Tim Graham 5df84b268d Removed unused model option "admin" 2013-08-01 10:27:30 -04:00
Alex Couper 1123f45511 Fixed #20649 -- Allowed blank field display to be defined in the initial list of choices. 2013-07-31 14:12:03 -04:00
Loic Bistuer acd1d439fd Fixed #20826 -- Moved Manager.raw() and Manager._insert() to the QuerySet class. 2013-07-31 09:54:00 -04:00
Florian Hahn e888a9b30d Fixed #15624 -- Made sure aggregations are present in SELECT 2013-07-31 16:27:58 +03:00
Anssi Kääriäinen c21e86ab9e Added field.attname to Options.name_map
The change also removed allow_explicit_fk from sql/query.py.
2013-07-31 16:02:36 +03:00
Tai Lee 31e6d58d46 Fixed #20348 -- Consistently handle Promise objects in model fields.
All Promise objects were passed to force_text() deep in ORM query code.
Not only does this make it difficult or impossible for developers to
prevent or alter this behaviour, but it is also wrong for non-text
fields.

This commit changes `Field.get_prep_value()` from a no-op to one that
resolved Promise objects. All subclasses now call super() method first
to ensure that they have a real value to work with.
2013-07-31 15:54:17 +03:00
Andrew Godwin fddc5957c5 Implement allow_migrate for migration operations 2013-07-30 12:34:31 +01:00
Andrew Godwin 12e9804d16 Rename allow_syncdb to allow_migrate 2013-07-30 12:08:59 +01:00
Andrew Godwin 68e0a169c4 Rename pre_ and post_syncdb to *_migrate, with aliases from old names 2013-07-30 11:52:52 +01:00
Shai Berger 6ed579e7eb Fixed #20785 -- Corrected exception caught for Oracle LIKE operator detection
The code that tests to see which LIKE expressions to use now runs
using non-error-wrapped cursor, so cx_Oracle exceptions need to be caught
rather than Django DatabaseErrors.

Thanks Trac user ludo for report and initial patch.
2013-07-30 03:21:06 +03:00
Claude Paroz 5c1143910e Removed most of absolute_import imports
Should be unneeded with Python 2.7 and up.
Added some unicode_literals along the way.
2013-07-29 20:28:13 +02:00
Claude Paroz fdd7a355bf Deprecated django.utils.importlib
This was a shim for pre-Python 2.7 support.
2013-07-29 17:10:22 +02:00
Julien Phalip 47c755327b Fixed a number of minor misspellings. 2013-07-27 18:46:03 -07:00
Andrew Godwin c8cbdabfab Fix Python 3 support 2013-07-26 17:08:12 +01:00
Andrew Godwin 52643a69e3 Add --fake option to migrate 2013-07-26 16:47:00 +01:00
Andrew Godwin 3f7113f1d9 Fix timezone warnings if USE_TZ=True 2013-07-26 16:46:48 +01:00
Andrew Godwin 9c6d57ef5a Prettier imports 2013-07-26 16:40:27 +01:00
Anssi Kääriäinen 7cca8d56d2 Fixed related model lookup regression
It has been possible to use models of wrong type in related field
lookups. For example pigs__in=[a_duck] has worked. Changes to
ForeignObject broke that.

It might be a good idea to restrict the model types usable in lookups.
This should be done intentionally, not accidentally and without any
consideration for deprecation path.
2013-07-26 13:13:27 +03:00
Loic Bistuer 31fadc1202 Fixed #20625 -- Chainable Manager/QuerySet methods.
Additionally this patch solves the orthogonal problem that specialized
`QuerySet` like `ValuesQuerySet` didn't inherit from the current `QuerySet`
type. This wasn't an issue until now because we didn't officially support
custom `QuerySet` but it became necessary with the introduction of this new
feature.

Thanks aaugustin, akaariai, carljm, charettes, mjtamlyn, shaib and timgraham
for the reviews.
2013-07-26 12:41:27 +03:00
Andrew Godwin a758c9c186 Add test for creating M2Ms 2013-07-25 16:36:58 +01:00
Anssi Kääriäinen 92476e880c Fixed ._meta.pk_index() virtual field failure 2013-07-25 16:25:23 +03:00
Tim Graham 31c13a99bb Fixed #14300 -- Fixed initial SQL location if models is a package.
Thanks al_the_x for the report and fheinz for the draft patch.
2013-07-24 06:56:33 -04:00
ersran9 311c1d2848 Fixed #20761 -- Reworded ForeignKey default error message 2013-07-23 22:16:31 +02:00
Tim Graham ad98b985aa Fixed test failures introduced in e716518ad2
refs #20761
2013-07-23 15:21:29 -04:00
Loic Bistuer e716518ad2 Fixed #20761 -- Fixed DatabaseError handling in get_or_create and update_or_create. 2013-07-23 09:20:43 -04:00
Anssi Kääriäinen 6b4967e883 Minor change to get_extra_descriptor_filter()
Refs #20611.
2013-07-23 15:34:29 +03:00
Anssi Kääriäinen 4bd5554721 Fixed #20782 -- qs.values().aggregate() failure
In the combination of .values().aggregate() the aggregate_select_mask
didn't include the aggregates added. This resulted in bogus query.

Thanks to Trac alias debanshuk for report.
2013-07-23 11:38:38 +03:00
Andrew Godwin 162f7b938f Make migrate command recognise prefixes and 'zero'. 2013-07-22 19:43:58 +01:00
Andrew Godwin 03ec3219a0 Merge branch 'master' into schema-alteration
Conflicts:
	django/db/backends/mysql/introspection.py
	django/db/backends/oracle/creation.py
	django/db/backends/postgresql_psycopg2/creation.py
	django/db/models/base.py
	django/db/models/loading.py
2013-07-22 19:04:25 +01:00
Tim Graham 2333c9662b Fixed #14007 -- Added model discovery in models module without the need to specify app_label.
Thanks mark@ and Aramgutang for work on the patch.
2013-07-16 19:32:30 -04:00
Tim Graham 2456ffa42c Fixed #20746 -- Removed Python 2.6 specific code/docs 2013-07-14 13:02:55 -04:00
Tim Graham f2cb94f1c0 Fixed #20740 -- GenericIPAddressField should pass protocol to formfield()
Thanks Jeff250.
2013-07-12 16:05:14 -04:00
Karol Sikora 6272d2f155 Fixed #20429 -- Added QuerySet.update_or_create
Thanks tunixman for the suggestion and Loic Bistuer for the review.
2013-07-12 08:26:35 -04:00
Tim Graham 95eb68c98f Fixed #17339 -- Factor out has_result into database backend.
Thanks jonash.
2013-07-09 06:41:52 -04:00
Shai Berger c0a4894dca Fixed last_executed_query test failure on Oracle 2013-07-08 23:47:02 +03:00
Tim Graham da79ccca1d Fixed #6785 -- Made QuerySet.get() fetch a limited number of rows.
Thanks Patryk Zawadzki.
2013-07-08 08:33:40 -04:00
Alex Gaynor 43073dbd76 fixed a mis-importt in mysql/base.py 2013-07-08 11:18:06 +10:00
Alex Gaynor 03d9566e0d A large number of stylistic cleanups across django/db/ 2013-07-08 10:39:54 +10:00
Alex Gaynor 0b69a75502 Fixed a bug I introduced in my previosu ommit. 2013-07-08 10:32:04 +10:00
Alex Gaynor 626fa28878 Fixed #13813 -- Comparison of DatabaseWrappers doesn't raise errors.
Patch from Lukasz Balcerzak.
2013-07-08 09:35:08 +10:00
Alex Gaynor c8c22ccdcb Removed some logic that wasn't needed following removal of some deprecated code. 2013-07-08 08:49:58 +10:00
Andrew Godwin 3a6580e485 Make get_constraints return columns in order 2013-07-02 18:02:20 +01:00
Andrew Godwin 61ff46cf8b Add AlterIndexTogether operation 2013-07-02 18:02:01 +01:00
Andrew Godwin dbd3e775c1 Fix get_constraints to do multi-column indexes properly on pg 2013-07-02 12:06:00 +01:00
Andrew Godwin f343cbf06c Fix combined alters on PostgreSQL 2013-07-02 11:51:18 +01:00
Andrew Godwin 6a8cfbf07b Support for index_together in schema backends 2013-07-02 11:43:44 +01:00
Andrew Godwin 3b20af3e96 Autodetection of unique_together changes 2013-07-02 11:25:18 +01:00
Andrew Godwin 67dcea711e Add unique_together altering operation 2013-07-02 11:19:02 +01:00
Andrew Godwin b1e0ec06f0 Merge branch 'master' into schema-alteration 2013-07-02 10:49:53 +01:00
Aymeric Augustin d5589b4cd3 Removed some conditional code only needed under Python 2.6. 2013-07-01 12:02:17 +02:00
Alex Gaynor b9ebca6a28 Removed a comment that wasn't adding a value.
In the intervening years, RelatedField has become less of a hack (though it still is one). Anyone who wants to can re-instate the comment, but please add more details.
2013-06-30 23:32:23 -07:00
Aymeric Augustin dd9c6bc359 Introduced getters for connection.autocommit and .needs_rollback.
They ensure that the attributes aren't accessed in conditions where they
don't contain a valid value.

Fixed #20666.
2013-06-30 15:57:00 +02:00
Aymeric Augustin acd7b34aaf Advanced deprecation warnings for Django 1.7. 2013-06-29 18:49:37 +02:00
Claude Paroz 59b0c48ce2 Fixed #18592 -- Prevented crash when accessing MySQL _last_executed
Thanks reames at asymmetricventures.com for the report.
2013-06-29 18:44:41 +02:00
Claude Paroz ea3fe78a9d Fixed #20660 -- Do not try to delete an unset FieldFile
Thanks stanislas.guerra at gmail.com for the report and
Baptiste Mispelon for the review.
2013-06-29 18:08:39 +02:00
Ramiro Morales 6ba69c8456 Removed 'depth' .select_related() argument as per deprecation TL. 2013-06-28 21:48:16 -03:00
Andrew Godwin 904b82759c Fix Python 3 support 2013-06-28 17:53:49 +01:00
Andrew Godwin 7a47ba6f6a Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/backends/__init__.py
	django/db/models/fields/related.py
	tests/field_deconstruction/tests.py
2013-06-28 17:32:57 +01:00
Andrew Godwin 48dd1e63bb Ported over Field.deconstruct() from my schema alteration branch.
This is to help other ongoing branches which would benefit from
this functionality.
2013-06-28 17:27:52 +01:00
Shai Berger d097417025 Support 'pyformat' style parameters in raw queries, Refs #10070
Add support for Oracle, fix an issue with the repr of RawQuerySet,
add tests and documentations. Also added a 'supports_paramstyle_pyformat'
database feature, True by default, False for SQLite.

Thanks Donald Stufft for review of documentation.
2013-06-28 06:59:10 +03:00
Aymeric Augustin c1284c3d3c Fixed #20571 -- Added an API to control connection.needs_rollback.
This is useful:
- to force a rollback on the exit of an atomic block without having to
  raise and catch an exception;
- to prevent a rollback after handling an exception manually.
2013-06-27 22:19:54 +02:00
Andrew Godwin 99b467f272 Add related_query_name to ForeignKey/M2M. Refs #20244 2013-06-27 14:44:21 +01:00
Loic Bistuer a9ea7d8c70 Fixed #20462 - Replaced the str() cast introduced in 273dc55 by force_text() 2013-06-26 21:30:58 +07:00
Andrew Clark 273dc550a4 Fixed #20462 -- null/non-string regex lookups are now consistent
Thanks to noirbizarre for the report and initial patch.
2013-06-26 08:13:26 -04:00
Simon Charette b91787910c Fixed #20642 -- Deprecated `Option.get_(add|change|delete)_permission`.
Those methods were only used by `contrib.admin` internally and exclusively
related to `contrib.auth`. Since they were undocumented but used
in the wild the raised deprecation warning point to an also undocumented
alternative that lives in `contrib.auth`.

Also did some PEP8 and other cleanups in the affected modules.
2013-06-25 12:22:37 -04:00
Andrew Godwin e2d7e83256 Autodetect ForeignKeys and add dependencies/split on circulars 2013-06-22 17:15:51 +01:00
Gilberto Gonçalves 680b512fc1 Fixed #20587 -- Made convert_values handle None values 2013-06-22 14:05:12 +01:00
Andrew Godwin 48493cff73 Remove EmailField max_length default removal in deconstruct() 2013-06-22 12:56:37 +01:00
Andrew Godwin cca40703df Prompt about renames rather than doing them automatically 2013-06-21 15:32:15 +01:00
Andrew Godwin 92a10f5552 Autodetect field renames. HAHAHA. AHAHAHAHA. YES. 2013-06-20 16:02:43 +01:00
Andrew Godwin 47e4b86ddf Autodetect field alters 2013-06-20 15:19:30 +01:00
Andrew Godwin 80bdf68d6b Add AlterField and RenameField operations 2013-06-20 15:12:59 +01:00
Andrew Godwin 6f667999e1 Add operation that renames tables 2013-06-20 14:54:11 +01:00
Andrew Godwin 73e30e9d3b Better naming, and prompt for NOT NULL field addition 2013-06-19 17:01:48 +01:00
Andrew Godwin 41214eaf18 Autodetect fields, have migrate actually work 2013-06-19 16:41:04 +01:00
Andrew Godwin f25a385a5e Makemigration command now works 2013-06-19 16:23:52 +01:00
Aymeric Augustin ffcf24c9ce Removed several unused imports. 2013-06-19 17:18:40 +02:00
Andrew Godwin ab5cbae9b7 First stab at some migration creation commands 2013-06-19 15:36:22 +01:00
Andrew Godwin 2ae8a8a77d Fix test running with new apps stuff/migrate actually running migrations 2013-06-19 15:36:02 +01:00
Andrew Godwin 9daf81b94e Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/models/loading.py
2013-06-19 12:05:23 +01:00
Florian Hahn 2f35c6f10f Fixed #14930 -- values_list() failure on qs ordered by extra column
Thanks lsaffre for the report and simon29, vicould, and Florian Hahn
for the patch.

Some changes done by committer.
2013-06-18 23:56:51 +03:00
Loic Bistuer ee77d4b253 Fixed #20199 -- Allow ModelForm fields to override error_messages from model fields 2013-06-18 08:01:17 -04:00
Loic Bistuer f34cfec0fa Refactored ValidationError to allow persisting error params and error codes as the exception bubbles up 2013-06-18 08:01:17 -04:00
Anssi Kääriäinen aa22cbd51a Fixed #20583 -- ORM always uses setup_joins() for join generation
There were a couple of places which used Query.join() directly. By
using setup_joins() in these places the code is more DRY, and in
addition there is no need to directly call field.get_joining_columns()
unless the field is the given join_field from get_path_info(). This
makes it easier to make sure a ForeignObject subclass generates joins
correctly in all cases.
2013-06-16 15:44:52 +03:00
Anssi Kääriäinen 5459795ef2 Fixed #20289 -- pickling of dynamic models 2013-06-14 17:05:54 +03:00
Anssi Kääriäinen 89bf7a4525 Fixed #20528 -- regression in select_related join promotion
The join used by select_related was incorrectly INNER when the query
had an ORed filter for nullable join that was trimmed away. Fixed this
by forcing the join type to LOUTER even when a join was trimmed away
in ORed queries.
2013-06-14 16:29:06 +03:00
Baptiste Mispelon dc9c359546 Fixed #20594 -- Add validation to models.SlugField.
Thanks carbonXT for the report.
2013-06-13 13:31:57 -04:00
Tim Graham 92c49d6f01 Revert "Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields."
This reverts commit 64041f0e6e.

lookup.tests.LookupTests.test_regex_non_string fails under Postgres.
We should also try to rewrite the test using an existing model.
2013-06-11 17:55:19 -04:00
Axel Haustant 64041f0e6e Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields. 2013-06-11 14:13:40 -04:00
Aymeric Augustin 4daf570b98 Added TransactionTestCase.available_apps.
This can be used to make Django's test suite significantly faster by
reducing the number of models for which content types and permissions
must be created and tables must be flushed in each non-transactional
test.

It's documented for Django contributors and committers but it's branded
as a private API to preserve our freedom to change it in the future.

Most of the credit goes to Anssi. He got the idea and did the research.

Fixed #20483.
2013-06-10 11:24:10 +02:00
Aymeric Augustin 13b7f299de Added a stealth option to flush to allow cascades.
This allows using flush on a subset of the tables without having to
manually cascade to all tables with foreign keys to the tables being
truncated, when they're known to be empty.

On databases where truncate is implemented with DELETE FROM, this
doesn't make a difference. The cascade is allowed, not mandatory.
2013-06-10 11:21:54 +02:00
Aymeric Augustin 79ff1aedd5 Replaced a dict emulating a set with a set. 2013-06-09 14:31:04 +02:00
Andrew Godwin 315ab41e41 Initial stab at a migrate command, it's probably quite a way off. 2013-06-07 18:47:17 +01:00
Andrew Godwin 91c470def5 Auto-naming for migrations and some writer fixes 2013-06-07 17:56:43 +01:00
Andrew Godwin cd809619a2 Autodetector tests 2013-06-07 15:49:48 +01:00
Andrew Godwin c7aa4b5338 Field encoding 2013-06-07 15:36:31 +01:00
Andrew Godwin 4492f06408 A bit of an autodetector and a bit of a writer 2013-06-07 15:28:38 +01:00
Andrew Godwin 3c296382b8 Merge remote-tracking branch 'core/master' into schema-alteration
Conflicts:
	django/db/models/fields/related.py
2013-06-07 11:15:34 +01:00
Anssi Kääriäinen 31fd64ad8a Fixed #20564 -- Generic relations exclude() regression
The patch for #19385 caused a regression in certain generic relations
.exclude() filters if a subquery was needed. The fix contains a
refactoring to how Query.split_exclude() and Query.trim_start()
interact.

Thanks to Trac alias nferrari for the report.
2013-06-06 01:54:46 +03:00
James Aylett 5448555785 Fixed #17601 -- expose underlying db exceptions under py2
Use __cause__ to expose the underlying database exceptions even
under python 2.
2013-06-04 12:46:10 +01:00
Aymeric Augustin b55624a026 Added get_app_paths() to the AppCache.
This method is useful to discover files inside apps.
2013-06-02 20:39:45 +02:00
Dan Loewenherz 07a73a2714 Fixed #20337 -- Clarified error message when database relation is not allowed. 2013-06-01 07:55:49 -04:00
Andrew Godwin 7609e0b42e Remove debug prints 2013-05-30 18:25:57 +01:00
Andrew Godwin 8d81c6bc82 Use correct model versions for field operations 2013-05-30 18:24:20 +01:00
Andrew Godwin e6ba63def3 Fix error in ModelState.clone() not copying deep enough 2013-05-30 18:24:10 +01:00
Andrew Godwin e6f7f4533c Add an Executor for end-to-end running 2013-05-30 18:08:58 +01:00
Andrew Godwin dfa7c5cade Allow retrieval of project state at start of migrations 2013-05-30 17:56:26 +01:00
Tim Graham 5074c75a37 Fixed #16856 - Added a way to clear select_related.
Thanks Carl for the suggestion and David Cramer for the patch.
2013-05-30 11:06:05 -04:00
Tim Graham 616f3c4a79 Fixed #20272 - Moved update_fields existence check into Model._do_update.
Thanks Gavin Wahl.
2013-05-30 10:48:30 -04:00
Tai Lee 69f7db153d Fixed #16436 -- defer + annotate + select_related crash
Correctly calculate the ``aggregate_start`` offset from loaded fields,
if any are deferred, instead of ``self.query.select`` which includes all
fields on the model.

Also made some PEP 8 fixes.
2013-05-30 08:46:31 +03:00
Andrew Godwin d0ecefc2c9 Start adding operations that work and tests for them 2013-05-29 17:47:10 +01:00
Shai Berger 0027f13904 Fixed #20014 -- implemented get_key_columns() for Oracle
Thanks Aymeric Augustin for reporting
2013-05-27 21:12:47 +03:00
Shai Berger 5e05ec3ea6 Fixed #20501 -- failure of datetime queries with timezones under Oracle 2013-05-27 17:28:57 +03:00
Tim Graham 90af278203 Fixed #16137 - Removed kwargs requirement for QuerySet.get_or_create
Thanks wilfred@, poirier, and charettes for work
on the patch.
2013-05-27 10:01:14 -04:00
Tim Graham 6f8627dd7f Fixed #17582 - Added message to DoesNotExist exceptions.
Thanks simon@ for the suggestion and JordanPowell
for the initial patch.
2013-05-27 07:57:06 -04:00
Anssi Kääriäinen 37ea9f9c03 Fixed #20507 -- SubqueryConstraint alias handling
MySQL should work now, too.
2013-05-27 15:05:03 +03:00
Anssi Kääriäinen d467e11785 Fixed #20507 -- SubqueryConstraint alias relabeling
The SubqueryConstraint defined relabeled_clone(), but that was never
called. Instead there is now clone() and relabel_aliases() methods for
SubqueryConstraint.

A related problem was that SubqueryConstraint didn't correctly use
quote_name_unless_alias() of the outer query. This resulted in failures
when running under PostgreSQL.
2013-05-27 12:25:29 +03:00
Ramiro Morales 0fa8d43e74 Replaced `and...or...` constructs with PEP 308 conditional expressions. 2013-05-26 23:47:50 -03:00
Claude Paroz 7e95d7a930 Fixed a regression in router initialization
Regression was introduced in 6a6bb168b. Thanks Bas Peschier for the
report.
2013-05-24 20:48:02 +02:00
Luke Plant 17559e6eb0 Optimisation in prefetch_related_objects 2013-05-24 11:19:44 +01:00
Luke Plant 4fd94969d8 Fixed #19607 - prefetch_related crash
Thanks to av@rdf.ru and flarno11@yahoo.de for the report.
2013-05-24 11:10:48 +01:00
Claude Paroz 6a6bb168be Delayed settings.DATABASE_ROUTERS usage by ConnectionRouter
Refs #20474.
2013-05-23 15:19:12 +02:00
Claude Paroz 2d8c132b18 Delayed settings.DATABASES usage by ConnectionHandler
Refs #20474.
2013-05-23 15:19:12 +02:00
Claude Paroz 499a745ae1 Fixed #20474 -- Proxied and deprecated django.db.backend 2013-05-23 15:19:12 +02:00
Donald Stufft 3de1288042 Fixed #11398 - Added a pre_syncdb signal 2013-05-23 01:09:22 -04:00
Aymeric Augustin 0e51d8eb66 Fixed #20463 -- Made get_or_create more robust.
When an exception other than IntegrityError was raised, get_or_create
could fail and leave the database connection in an unusable state.

Thanks UloPe for the report.
2013-05-22 10:56:06 +02:00
Shai Berger dfe6ea3b1f Fixed #20012 -- test_year_lookup_edge_case fails under Oracle
Used formatted date instead of datetime object for the end of the
year range, as the datetime object loses fractions-of-seconds when
inserted into the db.
2013-05-22 01:52:15 +03:00
Shai Berger 8fd40b9ae7 Fixed #20015 -- date__startswith('2008') fails under Oracle
Removed the explicit casting of strings to dates
2013-05-22 01:52:15 +03:00
Shai Berger b6ad9998e6 Fixed #20453 -- inspectdb test failure on Oracle 2013-05-22 01:52:15 +03:00
Anssi Kääriäinen 70679243d1 Fixed #18702 -- Removed chunked reads from QuerySet iteration 2013-05-21 19:51:59 +03:00
Selwin Ong ea9a0857d4 Fixed #19326 -- Added first() and last() methods to QuerySet 2013-05-21 18:52:28 +03:00
Claude Paroz d595b61aca (Re-)moved some imports 2013-05-21 17:34:19 +02:00
Ramiro Morales 4ba1c2e785 Fixed #9321 -- Deprecated hard-coding of help text in model ManyToManyField fields.
This is backward incompatible for custom form field/widgets that rely
on the hard-coded 'Hold down "Control", or "Command" on a Mac, to select
more than one.' sentence.

Application that use standard model form fields and widgets aren't
affected but need to start handling these help texts by themselves
before Django 1.8.

For more details, see the related release notes and deprecation timeline
sections added with this commit.
2013-05-20 16:29:51 -03:00
Anssi Kääriäinen 266c0bb23e Fixed #20278 -- ensured .get() exceptions do not recurse infinitely
A regression caused by d5b93d3281 made .get() error
reporting recurse infinitely on certain rare conditions. Fixed this by
not trying to print the given lookup kwargs.
2013-05-20 18:50:40 +03:00
Anssi Kääriäinen c9a96075fa Fixed #20378 -- regression in GenericRelation on abstract model
When a GenericRelation was defined on abstract model, queries on childs
of the abstract model didn't work. The problem was in the way fields and
in particular field.rel was copied from models to their children.

The regression was likely caused by #19385. Thanks to Gavin Wahl for
spotting the regression.
2013-05-20 18:02:10 +03:00
Anssi Kääriäinen f53059b411 Fixed qs.values() regression when used in subquery 2013-05-20 15:38:47 +03:00
Aymeric Augustin 6633eeb886 Changed API to disable ATOMIC_REQUESTS per view.
A decorator is easier to apply to CBVs. Backwards compatibility isn't an
issue here, except for people running on a recent clone of master.

Fixed a few minor problems in the transactions docs while I was there.
2013-05-19 19:53:16 +02:00
Aymeric Augustin 181f2ec603 Fixed test failures with Oracle when pytz isn't installed.
Thanks Shai Berger for the report.
2013-05-19 14:38:48 +02:00
Aymeric Augustin f7467181aa Merge pull request #1160 from erikr/host-inet-postgres2
Fixed #11442 -- Postgresql backend casts all inet types to text
2013-05-19 04:57:10 -07:00
Erik Romijn 60d94c2a80 Fixed #11442 -- Postgresql backend casts all inet types to text 2013-05-19 13:28:09 +02:00
Aymeric Augustin a7e2835276 Merge pull request #1028 from manfre/patch-2
Fixed #20340 - document required return value for disable_constraint_checking
2013-05-19 04:17:08 -07:00
Andrew Godwin 264f8650e3 ModelState now freezes options and bases 2013-05-19 12:35:17 +02:00
Andrew Godwin 38a8cf1cdc Fix state tests a little 2013-05-18 18:30:34 +02:00
Andrew Godwin 7d041b9394 Split up test and make the State classes a bit better. 2013-05-18 13:49:56 +02:00
Andrew Godwin 028bbd15ca Add a deconstruct() method to Fields.
This allows the field's initial argument to be obtained so it can be
serialised to, and re-created from, a textual format.
2013-05-18 13:48:57 +02:00
Shai Berger 215647c0f7 Fixed #20386 - Introspection problem on Oracle
Made introspection always return a unicode as column name on Oracle.
Thanks aaugustin for review and suggestion to use force_text().
2013-05-18 14:19:26 +03:00
Andrew Godwin 331546f6ee More conversion to a ContextManager schema_editor 2013-05-18 11:48:46 +02:00
Andrew Godwin ce5bd42259 Turn SchemaEditor into a context manager 2013-05-18 11:06:30 +02:00
Andrew Godwin b31eea069c Merge branch 'master' into schema-alteration 2013-05-18 10:21:31 +02:00