Commit Graph

3978 Commits

Author SHA1 Message Date
Anssi Kääriäinen 46f4b19920 Removed debug code 2013-03-17 11:31:15 +02:00
Baptiste Mispelon d5683bd06b Fix #20058: Make compilemessages use stdout instead of stderr. 2013-03-16 19:48:40 +01:00
Anssi Kääriäinen 2a2708e1b2 Fixed #17502 -- Made joining in inheritance cases consistent
The original problem was that when filtering two levels up in
inheritance chain, Django optimized the join generation so that the
middle model was skipped. But then Django generated joins from top
to middle to bottom for SELECT clause, and thus there was one extra
join (top->middle->bottom + top -> bottom).

This case is fixed in master as the filtering optimization is gone.
This has the side effect that in some cases there is still extra join
if the SELECT clause doesn't contain anything from middle or bottom.
2013-03-15 11:06:26 +02:00
Aymeric Augustin 3f2befc931 Deprecated django.views.defaults.shortcut. 2013-03-14 20:30:23 +01:00
Claude Paroz 2f121dfe63 Fixed #17051 -- Removed some 'invalid' field error messages
When the 'invalid' error message is set at field level, it masks
the error message raised by the validator, if any.
2013-03-14 17:03:43 +01:00
Claude Paroz 34d098665d Add a specific error message for URLValidator 2013-03-14 15:26:30 +01:00
Claude Paroz 9883551d50 Fixed #20039 -- Fixed has_changed form detection for required TypedChoiceFields
Thanks Florian Apolloner for the report and the review.
Also fixes #19643.
2013-03-14 14:49:07 +01: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
Florian Apolloner 22b7870e40 Began implementing a shared set of test models to speed up tests. 2013-03-13 23:25:26 +01:00
Jacob Kaplan-Moss 1059da8de6 Merge pull request #900 from bmispelon/ticket-20022
Fix #20022: Correctly handle prefixes with url-unsafe characters in reverse()
2013-03-13 22:39:25 +01:00
Baptiste Mispelon 4fa7f3cdd9 Fix #20022: Correctly handle prefixes with url-unsafe characters in reverse(). 2013-03-13 18:19:29 +01:00
Aymeric Augustin 83a416f5e7 Made atomic usable when autocommit is off.
Thanks Anssi for haggling until I implemented this.

This change alleviates the need for atomic_if_autocommit. When
autocommit is disabled for a database, atomic will simply create and
release savepoints, and not commit anything. This honors the contract of
not doing any transaction management.

This change also makes the hack to allow using atomic within the legacy
transaction management redundant.

None of the above will work with SQLite, because of a flaw in the design
of the sqlite3 library. This is a known limitation that cannot be lifted
without unacceptable side effects eg. triggering arbitrary commits.
2013-03-13 15:17:40 +01:00
Anssi Kääriäinen bd0cba58aa Fixed failing aggregation tests on MySQL 2013-03-13 12:44:24 +02: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 885d98d24a Fixed #20028 -- Made atomic usable on callable instances.
Thanks Anssi for the report.
2013-03-12 10:52:16 +01:00
Aymeric Augustin f8a634afa2 Fixed tests that relied on MANAGERS not being empty.
Regression in d0561242.
2013-03-11 23:30:02 +01:00
Jacob Kaplan-Moss d056124269 Remove a special case for comment tests from runtests.py. 2013-03-11 15:38:53 -05:00
Aymeric Augustin b746f8a9e3 Adjusted query counts to account for new savepoints. 2013-03-11 21:07:19 +01:00
Aymeric Augustin 55a9be8ecf Ran a test that closes the database connection outside of a transaction. 2013-03-11 19:42:59 +01:00
Claude Paroz 9b74a8391d Removed forced settings in runtests
Tests that require USE_I18N, LOGIN_URL or certain MIDDLEWARE_CLASSES
should be decorated appropriately.
2013-03-11 17:46:56 +01:00
Aymeric Augustin e654180ce2 Improved the API of set_autocommit. 2013-03-11 15:10:58 +01:00
Aymeric Augustin 86fd920f67 Removed a test that no longer makes any sense.
Since unmanaged == autocommit, there's nothing to commit or roll back.
2013-03-11 15:05:04 +01:00
Aymeric Augustin 0cee3c0e43 Updated a test that doesn't make sense with autocommit. 2013-03-11 15:05:04 +01:00
Aymeric Augustin 107d9b1d97 Added an option to disable the creation of savepoints in atomic. 2013-03-11 15:05:04 +01:00
Aymeric Augustin ac37ed21b3 Deprecated TransactionMiddleware and TRANSACTIONS_MANAGED.
Replaced them with per-database options, for proper multi-db support.

Also toned down the recommendation to tie transactions to HTTP requests.
Thanks Jeremy for sharing his experience.
2013-03-11 15:04:05 +01:00
Aymeric Augustin 7c46c8d5f2 Added some assertions to enforce the atomicity of atomic. 2013-03-11 14:48:55 +01:00
Aymeric Augustin d7bc4fbc94 Implemented an 'atomic' decorator and context manager.
Currently it only works in autocommit mode.

Based on @xact by Christophe Pettus.
2013-03-11 14:48:55 +01:00
Aymeric Augustin 4b31a6a9e6 Added support for savepoints in SQLite.
Technically speaking they aren't usable yet.
2013-03-11 14:48:55 +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 af9e9386eb Enabled autocommit for PostgreSQL.
For users who didn't activate autocommit in their database options, this
is backwards-incompatible in "non-managed" aka "auto" transaction state.
This state now uses database-level autocommit instead of ORM-level
autocommit.

Also removed the uses_autocommit feature which lost its purpose.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 8717b0668c Separated autocommit and isolation level handling for PostgreSQL.
Autocommit cannot be manipulated independently from an open connection.
This commit introduces a minor change in behavior: entering transaction
management forces opening a databasse connection. This shouldn't be
backwards incompatible in any practical use case.
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
Aymeric Augustin ce76fbfc5a Fixed #20019 -- Ensured HttpRequest.resolver_match always exists.
Obviously it isn't set until the URL is resolved.
2013-03-10 23:28:19 +01:00
Ramiro Morales 7fca4416c7 Made (make|compile)messages check for availability of gettext commands.
Refs #19584.
2013-03-10 17:31:11 -03:00
Claude Paroz 6a91b63842 Fixed #19923 -- Display tracebacks for non-CommandError exceptions
By default, show tracebacks for management command errors when the
exception is not a CommandError.
Thanks Jacob Radford for the report.
2013-03-09 12:38:45 +01:00
Claude Paroz cbfb8ed53b Fixed a regression in forms changed_data
Thanks Loic Bistuer for spotting the regression and the initial
patch. Refs #16612.
2013-03-08 18:19:24 +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
Aymeric Augustin 477d737e1e Merge pull request #850 from bmispelon/ticket-19916
Fix 19916. Smarter tokenizing of contrib.comment's templatetags arguments
2013-03-07 12:12:29 -08: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
Baptiste Mispelon 81804ae474 Fix 19916. Smarter tokenizing of contrib.comment's templatetags arguments. 2013-03-07 19:30:38 +01:00
Claude Paroz 4cccb85e29 Fixed #19997 -- Added custom EMPTY_VALUES to form fields
Thanks Loic Bistuer for the report and the patch.
2013-03-07 15:22:03 +01:00
Igor Támara e2ee02c5bd Fixed #19951 -- Admin: Invalid model PK values shouldn't cause 500 status.
Avoid ValueError in admin when passing a string as PK for an inherited
model with an integer PK field.

Thanks ikks for the patch. See also #11191.
2013-03-06 21:38:44 -03:00
Ramiro Morales c31a9793c6 Merge pull request #882 from loic/testfix
Fixed minor warnings in tests.
2013-03-06 16:22:06 -08:00
Preston Holmes 876fc39128 PEP8 cleanup of functional.py 2013-03-06 16:14:46 -08:00
Preston Holmes 0ea5bf88dd Fixed #19543 -- implemented SimpleLazyObject.__repr__
Thanks to Florian Hahn for the patch
2013-03-06 16:13:12 -08:00
Aymeric Augustin b3aa853ec5 Used more precise test assertions. 2013-03-06 15:33:35 +01:00
Loic Bistuer 9ba0e4e4ee Fixed minor warnings in tests. 2013-03-06 01:13:36 +07:00
Juan Pedro Fisanotti d9330d5be2 Fixed #6585 -- Admin relationship widgets: Respect ordering defined by target model's ModelAdmin.
Thanks Gary Wilson for the report and Juan Pedro Fisanotti, Carlos
Matías de la Torre for the fix.
2013-03-04 18:08:53 -03:00