Commit Graph

1098 Commits

Author SHA1 Message Date
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
Andrew Godwin b31eea069c Merge branch 'master' into schema-alteration 2013-05-18 10:21:31 +02:00
Aymeric Augustin 9c487b5974 Replaced an antiquated pattern.
Thanks Lennart Regebro for pointing it out.
2013-05-17 18:08:58 +02:00
Mike Fogel 74f3884ae0 Fixed #20413 - Respect Query.get_meta() 2013-05-15 12:55:30 -07:00
Andrew Godwin cb4b0de49e Merge branch 'master' into schema-alteration 2013-05-10 12:55:30 +01:00
Andrew Godwin 75bf394d86 Rest of the _meta.app_cache stuff. Schema tests work now. 2013-05-09 15:59:26 +01:00
Andrew Godwin 104ad0504b Split out a BaseAppCache, make AppCache borg again, add _meta.app_cache 2013-05-09 15:16:43 +01:00
Andrew Godwin 941d23e548 Whoops. Need to be good and use six. 2013-05-09 14:13:15 +01:00
Andrew Godwin ade34c44da Improve error message for bad FK resolution 2013-05-09 14:04:07 +01:00
Alex Gaynor f25fc5b220 Merge pull request #1049 from mfogel/remove-unescessary-parameter-checks
Remove unnecessary check on __set__ parameters.
2013-05-08 21:20:58 -07:00
Aymeric Augustin 1fff8daf88 Fixed test failures on MySQL.
Some tests failed when the time zone definitions were loaded in MySQL
and pytz wasn't installed. This setup isn't supported.
2013-05-08 13:03:36 +02:00
Mike Fogel a22e15effc Remove unnecessary check on __set__ parameters. 2013-05-07 21:50:59 -07:00
Claude Paroz ac9daa0cbd Systematically imported wraps from functools 2013-05-04 11:53:12 +02:00
Adrian Holovaty 6bccbc05a4 Converted a list comprehension into a generator expression in query_utils.py 2013-04-25 12:22:16 -05:00
Adrian Holovaty 5a5e1ac24d Negligible formatting fixes in query_utils.py 2013-04-25 11:42:08 -05:00
Adrian Holovaty 86243d2e57 Removed an errant ipdb import from commit 9777442 2013-04-25 11:41:57 -05:00
Andrew Godwin 7f3678dc4c Merge branch 'master' into schema-alteration
Conflicts:
	django/db/backends/__init__.py
	django/db/backends/mysql/base.py
	django/db/backends/oracle/base.py
	django/db/backends/oracle/creation.py
	django/db/backends/postgresql_psycopg2/base.py
	django/db/backends/sqlite3/base.py
	django/db/models/fields/related.py
2013-04-18 17:16:39 +01:00
Simon Charette 356443fd95 Use `LOOKUP_SEP` in `get_or_create`. 2013-04-18 01:55:12 -04:00
Tobias McNulty 161c4da588 Fixed #14019 -- Initialize `SQLInsertCompiler.return_id` attribute. 2013-04-08 13:41:36 -06:00
Simon Charette 216580e034 Fixed #20207 -- Handle ManyToManyField with a unicode name correctly. 2013-04-05 15:09:53 -04:00
Alex Gaynor 1aca9d93be Fixed a line that was overindented. 2013-04-04 15:16:16 -07:00
Simon Charette 8d05e6c0c7 Fixed deprecation warnings introduced by 97774429ae. 2013-04-01 17:32:09 -04:00
Gavin Wahl ec04fd1344 Fixed spelling errors 2013-03-28 11:16:53 -06:00
Anssi Kääriäinen e17fa9e877 Fixed #20091 -- Oracle null promotion for empty strings 2013-03-26 14:19:54 +02:00
Anssi Kääriäinen 9c4882b391 Fixed Oracle specific failures in multicolumn joins
Refs #19385
2013-03-24 22:56:40 +02:00
Anssi Kääriäinen 0e0eb8a955 Fixed field.rel.field_name handling
This is a regression fix to multicolumn joins. Refs #19385.
2013-03-24 20:59:56 +02:00
Anssi Kääriäinen 9572a3992b Python 2.6 compatibility for #19385 2013-03-24 19:00:24 +02:00
Anssi Kääriäinen 97774429ae Fixed #19385 again, now with real code changes
The commit of 266de5f9ae included only
tests, this time also code changes included...
2013-03-24 18:40:40 +02:00
Aymeric Augustin e16c48e001 Fixed #15124 -- Changed the default for BooleanField.
Thanks to the many contributors who updated and improved the patch over
the life of this ticket.
2013-03-24 13:47:01 +01:00
Marc Tamlyn 829dc3c5a6 Fixed #20094 - Be more careful when checking for Iterator
Python 2.6 has some different behaviour when checking
isinstance(foo, collections.Iterator).
2013-03-22 17:31:29 +01:00
Anssi Kääriäinen 0ff12c28d0 Removed unused import 2013-03-21 00:50:48 +02:00
Claude Paroz 23490a2394 Revert "Fixed 19895 -- Made second iteration over invalid queryset raise an exception too"
This reverts commit 2cd0edaa47.
This commit was the cause of a memory leak. See ticket for more details.
Thanks Anssi Kääriäinen for identifying the source of the bug.
2013-03-20 10:41:53 +01:00
Anssi Kääriäinen f403653cf1 Fixed #19635 -- Made fields pickleable 2013-03-17 15:32:50 +02:00
Aymeric Augustin 3beabb5afd Merge pull request #902 from evildmp/BLANK_CHOICE_NONE
Fixed #20043 -- Removed unused BLANK_CHOICE_NONE
2013-03-17 03:15:49 -07:00
Anssi Kääriäinen 6b4834952d Fixed #16649 -- Refactored save_base logic
Model.save() will use UPDATE - if not updated - INSERT instead of
SELECT - if found UPDATE else INSERT. This should save a query when
updating, but will cost a little when inserting model with PK set.

Also fixed #17341 -- made sure .save() commits transactions only after
the whole model has been saved. This wasn't the case in model
inheritance situations.

The save_base implementation was refactored into multiple methods.
A typical chain for inherited save is:
save_base()
    _save_parents(self)
        for each parent:
            _save_parents(parent)
            _save_table(parent)
    _save_table(self)
2013-03-14 11:01:47 +02:00
Daniele Procida a4c9a4a5fe removed unused BLANK_CHOICE_NONE 2013-03-13 21:26:15 +00:00
Anssi Kääriäinen d3f00bd570 Refactored qs.add_q() and utils/tree.py
The sql/query.py add_q method did a lot of where/having tree hacking to
get complex queries to work correctly. The logic was refactored so that
it should be simpler to understand. The new logic should also produce
leaner WHERE conditions.

The changes cascade somewhat, as some other parts of Django (like
add_filter() and WhereNode) expect boolean trees in certain format or
they fail to work. So to fix the add_q() one must fix utils/tree.py,
some things in add_filter(), WhereNode and so on.

This commit also fixed add_filter to see negate clauses up the path.
A query like .exclude(Q(reversefk__in=a_list)) didn't work similarly to
.filter(~Q(reversefk__in=a_list)). The reason for this is that only
the immediate parent negate clauses were seen by add_filter, and thus a
tree like AND: (NOT AND: (AND: condition)) will not be handled
correctly, as there is one intermediary AND node in the tree. The
example tree is generated by .exclude(~Q(reversefk__in=a_list)).

Still, aggregation lost connectors in OR cases, and F() objects and
aggregates in same filter clause caused GROUP BY problems on some
databases.

Fixed #17600, fixed #13198, fixed #17025, fixed #17000, fixed #11293.
2013-03-13 10:44:49 +02:00
Anssi Kääriäinen d744c550d5 Fixed #19964 -- Removed relabel_aliases from some structs
Before there was need to have both .relabel_aliases() and .clone() for
many structs. Now there is only relabeled_clone() for those structs
where alias is the only mutable attribute.
2013-03-12 21:33:47 +02:00
Aymeric Augustin 4dbd1b2dd8 Used commit_on_success_unless_managed to make ORM operations atomic. 2013-03-11 15:05:05 +01:00
Aymeric Augustin 3bdc7a6a70 Deprecated transaction.is_managed().
It's synchronized with the autocommit flag.
2013-03-11 14:48:54 +01:00
Aymeric Augustin ba5138b1c0 Deprecated transaction.commit/rollback_unless_managed.
Since "unless managed" now means "if database-level autocommit",
committing or rolling back doesn't have any effect.

Restored transactional integrity in a few places that relied on
automatically-started transactions with a transitory API.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 7aacde84f2 Made transaction.managed a no-op and deprecated it.
enter_transaction_management() was nearly always followed by managed().

In three places it wasn't, but they will all be refactored eventually.
The "forced" keyword argument avoids introducing behavior changes until
then.

This is mostly backwards-compatible, except, of course, for managed
itself. There's a minor difference in _enter_transaction_management:
the top self.transaction_state now contains the new 'managed' state
rather than the previous one. Django doesn't access
self.transaction_state in _enter_transaction_management.
2013-03-11 14:48:53 +01:00
Loic Bistuer 6983a1a540 Fixed #15363 -- Renamed and normalized to `get_queryset` the methods that return a QuerySet. 2013-03-08 10:11:45 -05:00
Alex Gaynor bbbd698c7a Added a ManyToManyField(db_constraint=False) option, this allows not creating constraints on the intermediary models. 2013-03-07 11:24:51 -08:00
Claude Paroz 2add24cc2c One more EMPTY_VALUES replacement following 22be90dd17
Thanks Loic Bistuer for catching this omission. Refs #19989.
2013-03-06 17:00:46 +01:00
Claude Paroz 22be90dd17 Fixed #19989 -- Suppressed UnicodeWarning during BinaryField validation
Thanks Aymeric Augustin for the report and Simon Charette for the
review.
2013-03-06 08:30:23 +01:00
Claude Paroz d680a3f447 Added support for serializing BinaryField 2013-03-02 10:29:02 +01:00
Claude Paroz 8ee1eddb7e Add a BinaryField model field
Thanks Michael Jung, Charl Botha and Florian Apolloner for review
and help on the patch.
2013-03-02 10:29:02 +01:00
Aymeric Augustin 0c82b1dfc4 Fixed #19929 -- Improved error when MySQL doesn't have TZ definitions.
Thanks tomas_00 for the report.
2013-02-28 17:35:13 +01:00
Anssi Kääriäinen 06de130dae Fixed #12823 -- Was already fixed in master, tests added
Also added a little improvement to sql/query.py to get rid of
non-necessary IS NOT NULL check.
2013-02-28 15:05:48 +02:00