Commit Graph

106 Commits

Author SHA1 Message Date
Nick Pope d3677043fc Added backward compatibility test for ConnectionHandler.databases property.
The ConnectionHandler.databases property is no longer used within
Django, but it is maintained for backward compatibility with 3rd party
packages that have used this private API in the past.
2022-05-13 12:01:07 +02:00
Nick Pope 20e65a34ae
Made closing in connection handlers more DRY. 2022-05-12 15:13:51 +02:00
Florian Apolloner 13378ad952 Moved ensure_defaults() and prepare_test_settings() logic to ConnectionHandler.configure_settings(). 2022-03-17 07:36:34 +01:00
Florian Apolloner 58ad9a99a7 Removed usage of django.db.utils.ConnectionHandler.databases. 2022-03-17 07:36:34 +01:00
django-bot 9c19aff7c7 Refs #33476 -- Reformatted code with Black. 2022-02-07 20:37:05 +01:00
Przemysław Suliga 4ce59f602e Fixed #30398 -- Added CONN_HEALTH_CHECKS database setting.
The CONN_HEALTH_CHECKS setting can be used to enable database
connection health checks for Django's persistent DB connections.

Thanks Florian Apolloner for reviews.
2021-12-01 07:44:48 +01:00
Mariusz Felisiak 5bcba16c01
Refs #25175 -- Removed postgresql_psycopg2 in django.db.utils.load_backend().
Follow up to 944469939b.
2021-01-06 20:15:14 +01:00
William Schwartz 0ea1866f6e
Simplified django.db.utils.load_backend().
Previously load_backend() performed search by computing the (sole)
entry of django.db.backends.__path__ manually from
django.db.utils.__file__. Now django.db.backends.__path__ is used
directly.
2021-01-04 07:16:13 +01:00
Florian Apolloner 98e05ccde4 Fixed #32233 -- Cleaned-up duplicate connection functionality. 2020-12-08 08:55:44 +01:00
Hasan Ramezani 4cce1d13cf Fixed #32197 -- Improved error message when loading a database backend fails. 2020-11-16 06:05:03 +01:00
Jon Dufresne f5ebdfce5c Fixed #25388 -- Added an option to allow disabling of migrations during test database creation. 2019-11-20 20:42:38 +01:00
Andrew Godwin a415ce70be Fixed #30451 -- Added ASGI handler and coroutine-safety.
This adds an ASGI handler, asgi.py file for the default project layout,
a few async utilities and adds async-safety to many parts of Django.
2019-06-20 12:29:43 +02:00
Benjy Weinberger 222caab68a Fixed #30071 -- Fixed error message when a 'default' database isn't provided. 2019-01-09 10:58:37 -05:00
Tom 11b8c30b9e Ref #23919 -- Replaced some os.path usage with pathlib.Path. 2018-04-19 21:30:00 -04:00
Mariusz Felisiak 84dcd16247 Refs #23919 -- Used "raise from" instead of __cause__ in reraising backend-specific database exceptions.
Thanks Tim Graham for the review.
2017-04-25 08:29:54 +02:00
Anton Samarchyan 60e52a047e Refs #27656 -- Updated django.db docstring verbs according to PEP 257. 2017-02-28 09:17:27 -05:00
Tim Graham a87d6b69a7 Tidied djang.db.utils.load_backend().
Removed an unneeded EnvironmentError catching and used
"raise from exc" syntax.
2017-01-24 08:33:26 -05:00
Tim Graham 435e4bf38e Refs #23919 -- Removed __traceback__ setting needed for Python 2.
Partially reverted refs #25761 and refs #16245.
2017-01-24 08:31:58 -05:00
Claude Paroz 6e55e1d88a Refs #23919 -- Replaced six.reraise by raise 2017-01-22 20:08:04 +01:00
Tim Graham 4e729feaa6 Refs #23919 -- Removed django.utils._os.upath()/npath()/abspathu() usage.
These functions do nothing on Python 3.
2017-01-20 08:01:02 -05:00
Simon Charette cecc079168 Refs #23919 -- Stopped inheriting from object to define new style classes. 2017-01-19 08:39:46 +01:00
Claude Paroz 7b2f2e74ad Refs #23919 -- Removed six.<various>_types usage
Thanks Tim Graham and Simon Charette for the reviews.
2017-01-18 20:18:46 +01:00
Claude Paroz c716fe8782 Refs #23919 -- Removed six.PY2/PY3 usage
Thanks Tim Graham for the review.
2017-01-18 16:21:28 +01:00
Raphaël Hertzog 9f4e031bd3 Fixed #25761 -- Added __cause__.__traceback__ to reraised exceptions.
When Django reraises an exception, it sets the __cause__ attribute even
in Python 2, mimicking Python's 3 behavior for "raise Foo from Bar".
However, Python 3 also ensures that all exceptions have a __traceback__
attribute and thus the "traceback2" Python 2 module (backport of Python
3's "traceback" module) relies on the fact that whenever you have a
__cause__ attribute, the recorded exception also has a __traceback__
attribute.

This is breaking testtools which is using traceback2 (see
https://github.com/testing-cabal/testtools/issues/162).

This commit fixes this inconsistency by ensuring that Django sets
the __traceback__ attribute on any exception stored in a __cause__
attribute of a reraised exception.
2015-12-03 16:31:50 -05:00
Tim Graham 4fd264b6f1 Refs #24351 -- Removed support for the old allow_migrate() signature per deprecation timeline. 2015-09-23 19:31:09 -04:00
Caio Ariede ec9004728e Fixed #25175 -- Renamed the postgresql_psycopg2 database backend to postgresql. 2015-08-07 09:33:17 -04:00
Tim Graham 28ee511b7e Fixed db.utils.load_backend() on non-ASCII paths. 2015-07-17 08:21:43 -04:00
Tim Graham bbbb7ce115 Filtered out 'base' from database backend choices error message. 2015-07-15 10:51:26 -04:00
Tim Graham aaacaeb096 Renamed RemovedInDjangoXYWarnings for new roadmap.
Forwardport of ae1d663b79
from stable/1.8.x plus more.
2015-06-24 16:08:20 -04:00
Tim Graham 3872a33132 Fixed #24979 -- Removed usage of inspect.getargspec(). 2015-06-15 13:43:22 -04:00
Tim Graham 47fcbe506c Fixed flake8 warnings on Python 3. 2015-06-15 11:27:09 -04:00
Aymeric Augustin ed83881e64 Fixed #23820 -- Supported per-database time zone.
The primary use case is to interact with a third-party database (not
primarily managed by Django) that doesn't support time zones and where
datetimes are stored in local time when USE_TZ is True.

Configuring a PostgreSQL database with the TIME_ZONE option while USE_TZ
is False used to result in silent data corruption. Now this is an error.
2015-05-17 09:40:28 +02:00
Andrei Kulakov e2bfcab065 Fixed #24394 -- Allowed running tests with empty default dictionary. 2015-03-25 17:56:59 -04:00
Loic Bistuer bed504d70b Fixed #24351, #24346 -- Changed the signature of allow_migrate().
The new signature enables better support for routing RunPython and
RunSQL operations, especially w.r.t. reusable and third-party apps.

This commit also takes advantage of the deprecation cycle for the old
signature to remove the backward incompatibility introduced in #22583;
RunPython and RunSQL won't call allow_migrate() when when the router
has the old signature.

Thanks Aymeric Augustin and Tim Graham for helping shape up the patch.

Refs 22583.
2015-02-20 21:34:09 +07:00
Tim Graham 0ed7d15563 Sorted imports with isort; refs #23860. 2015-02-06 08:16:28 -05:00
Tim Graham f635d75935 Removed support for old-style test database settings per deprecation timeline. 2015-01-17 09:55:18 -05:00
Tim Graham d79a30ba3f Removed fallback suport for allow_syncdb() in database routers per deprecation timeline. 2015-01-17 07:39:46 -05:00
Loic Bistuer 8f4877c89d Fixed #22583 -- Allowed RunPython and RunSQL to provide hints to the db router.
Thanks Markus Holtermann and Tim Graham for the review.
2015-01-10 00:30:48 +07:00
Claude Paroz 1d24f073e6 Fixed #21255 -- Closed connections after management command ran
Thanks kabakov.as@gmail.com for the report, and Aymeric Augustin,
Simon Charette for the reviews.
2014-12-29 19:02:45 +01:00
Shai Berger 88edce2abb Restored the 'TEST_' prefix in the warning about deprecated test database settings 2014-12-01 02:12:19 +02:00
Anubhav Joshi 9bc2d766a0 Fixed #21755 -- Added ForeignKey support to REQUIRED_FIELDS.
This allows specifying ForeignKeys in REQUIRED_FIELDS when using a
custom User model.

Thanks cjerdonek and bmispelon for suggestion and timgraham for review.
2014-07-03 07:42:52 -04:00
Tim Graham a2cd0e12c9 Silenced deprecation warnings for refs #22811 and fixed build. 2014-06-12 09:28:36 -04:00
Tim Graham 1c58cabad7 Fixed #22811 -- Allowed setting both the old and new TEST database settings.
An ImproperlyConfigured exception will be raised they mismatch.
2014-06-12 08:17:49 -04:00
Anubhav Joshi 42736ac8e8 Fixed #21430 -- Added a RuntimeWarning when unpickling Models and QuerySets from a different Django version.
Thanks FunkyBob for the suggestion, prasoon2211 for the initial patch,
and akaariai, loic, and charettes for helping in shaping the patch.
2014-06-11 10:03:34 -04:00
Aymeric Augustin 06160cb945 Removed deprecated TRANSACTIONS_MANAGED setting. 2014-03-21 21:34:47 +01:00
Shai Berger deff74ea0c Fixed the last fix for database test settings to work with Python3. 2014-03-09 12:27:12 +02:00
Shai Berger 84c137490b Fixed test breakage following test-settings enhancements 2014-03-09 10:23:47 +02:00
Shai Berger 41afae4ce9 Reorganized the database test settings
Change database test settings from "TEST_"-prefixed entries in the
database settings dictionary to setting in a dictionary that is itself
an entry "TEST" in the database settings.

Refs #21775

Thanks Josh Smeaton for review.
2014-03-09 03:57:18 +02:00
Claude Paroz 210d0489c5 Fixed #21188 -- Introduced subclasses for to-be-removed-in-django-XX warnings
Thanks Anssi Kääriäinen for the idea and Simon Charette for the
review.
2014-03-08 09:57:40 +01:00
Marc Tamlyn d238ab2991 Silence deprecation warnings.
Also they should only be raised if allow_syncdb does exist, not just if
allow_migrate does not.

Refs comments on 250841017c
2014-02-09 17:48:15 +00:00