Commit Graph

1090 Commits

Author SHA1 Message Date
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
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
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
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
Erik Romijn 60d94c2a80 Fixed #11442 -- Postgresql backend casts all inet types to text 2013-05-19 13:28:09 +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
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
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