Commit Graph

1697 Commits

Author SHA1 Message Date
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
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
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
Aymeric Augustin 3d595c3bc3 Fixed #20215 -- Disabled persistent connections by default. 2013-05-09 15:42:14 +02: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 86b4ac665a [py3] Stopped iterating on exceptions. Refs #20025. 2013-05-08 13:05:23 +02:00
Aymeric Augustin e81e319f15 Fixed #20025 -- Pointed to a MySQLdb fork for Python 3.
Made a few minor compatibility adjustments.
2013-05-08 13:05:09 +02: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
Michael Manfre f043cfe3e2 Fixed documentation of disable_constraint_checking
The docstring and base implementation of disable_constraint_checking do not indicate that a return value is expected for proper behavior.
2013-04-24 14:26:13 -03: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
Marti Raudsepp bd9b324a99 Fix typo in transaction.Atomic docstring 2013-04-03 16:49:48 +03:00
Simon Charette 8d05e6c0c7 Fixed deprecation warnings introduced by 97774429ae. 2013-04-01 17:32:09 -04:00
Claude Paroz 8c41bd93c2 Fixed #16737 -- Support non-ascii column names in inspectdb
Thanks moof at metamoof.net for the report.
2013-04-01 19:59:57 +02:00
Claude Paroz 51028f50b6 Fixed getting max_digits for MySQL decimal fields
Refs #5014.
2013-04-01 18:17:00 +02:00
Claude Paroz 3ff3212713 Fixed #19220 -- Prevented decimals to be displayed in scientific notation
Thanks nebstrebor for the report and antofik for the patch.
2013-03-31 22:39:01 +02:00
Claude Paroz 86b1c31689 Fixed #19954 -- Fixed MySQL _last_executed decoding
Queries can contain binary data undecodable with utf-8. In this
case, using the 'replace' errors mode when decoding seems like
an acceptable representation of the query.
Thanks Marcel Ryser for the report.
2013-03-28 20:08:37 +01: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
Claude Paroz 76aecfbc4b Fixed #9055 -- Standardized behaviour of parameter escaping in db cursors
Previously, depending on the database backend or the cursor type,
you'd need to double the percent signs in the query before passing
it to cursor.execute. Now cursor.execute consistently need percent
doubling whenever params argument is not None (placeholder substitution
will happen).
Thanks Thomas Güttler for the report and Walter Doekes for his work
on the patch.
2013-03-23 17:11:10 +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
Aymeric Augustin 6197935152 Fixed #19968 -- Dropped support for PostgreSQL < 8.4. 2013-03-18 21:16:29 +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
Aymeric Augustin 93af822c00 Improved recovery when the connection is closed in an atomic block. 2013-03-13 15:17:40 +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 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
Simon Charette bc7a10299f Fixed #20010 -- Make sure `last_executed_query` contains it's associated parameters on Oracle.
Also removed some unused imports.
2013-03-11 17:30:23 -04:00
Aymeric Augustin f2f98abb95 Avoided closing the database connection within a transaction.
Refs #9437.
2013-03-11 21:08:49 +01:00
Aymeric Augustin e654180ce2 Improved the API of set_autocommit. 2013-03-11 15:10:58 +01: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 423c0d5e29 Added a safety net for developers messing 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 557e404127 Re-ordered functions by deprecation status. 2013-03-11 15:04:10 +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 f7245b83bb Implemented atomic_if_autocommit.
It disables transaction management entirely when AUTOCOMMIT is False.
2013-03-11 14:48:55 +01:00
Aymeric Augustin 09ba70f9f1 Made transaction management work even before the first SQL query.
Thanks Florian again.
2013-03-11 14:48:55 +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 e264f67174 Refactored implementation of savepoints.
Prepared for using savepoints within transactions in autocommit mode.
2013-03-11 14:48:55 +01:00
Aymeric Augustin 918f44e3ae Moved standard SQL for savepoints in the base backend.
These methods are only called when uses_savepoints = True anyway.
2013-03-11 14:48:54 +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 14aa563f51 Removed superfluous code now that connections use autocommit by default. 2013-03-11 14:48:54 +01:00
Aymeric Augustin 5e27debc5c Enabled database-level autocommit for all backends.
This is mostly a documentation change.

It has the same backwards-incompatibility consequences as those
described for PostgreSQL in a previous commit.
2013-03-11 14:48:54 +01:00
Aymeric Augustin cfc114e00e Removed _enter/_leave_transaction_management.
The goal is to make all databases share a common, autocommit-based,
implementation.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 1617557ae3 Added BaseDatabaseWrapper.ensure_connection.
This API is useful because autocommit cannot be managed without an open
connection.
2013-03-11 14:48:54 +01:00
Aymeric Augustin 7b4815b455 Expressed the dirty flag handling logic in terms of autocommit. 2013-03-11 14:48:54 +01:00
Aymeric Augustin cd364efa00 Stopped flipping the uses_savepoints feature at runtime. 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 f515619494 Added an API to control database-level autocommit. 2013-03-11 14:48:53 +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
Florian Apolloner 8aefd30379 Fixed BinaryField support on Oracle. 2013-03-09 23:39:14 +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
Aymeric Augustin 25ce177e66 Added missing method in the dummy database backend. 2013-03-07 14:53:52 +01:00