diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-01-29 11:44:58 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2016-01-29 11:44:58 -0500 |
commit | c59bf0007f0148b73c80a3d6b86d6c66ae0ab422 (patch) | |
tree | b08546beb64fc526fcee16a32eb2d98d408a902b | |
parent | 859379e2fcc4506d036700ba1eca4c0ae526a8ee (diff) | |
download | sqlalchemy-c59bf0007f0148b73c80a3d6b86d6c66ae0ab422.tar.gz |
- The ``sqlalchemy.dialects.postgres`` module, long deprecated, is
removed; this has emitted a warning for many years and projects
should be calling upon ``sqlalchemy.dialects.postgresql``.
Engine URLs of the form ``postgres://`` will still continue to function,
however.
-rw-r--r-- | doc/build/changelog/changelog_11.rst | 9 | ||||
-rw-r--r-- | doc/build/changelog/migration_11.rst | 11 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/__init__.py | 9 | ||||
-rw-r--r-- | lib/sqlalchemy/dialects/postgres.py | 18 | ||||
-rw-r--r-- | test/dialect/postgresql/test_dialect.py | 10 |
5 files changed, 38 insertions, 19 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst index 511b7b8be..37cb773d8 100644 --- a/doc/build/changelog/changelog_11.rst +++ b/doc/build/changelog/changelog_11.rst @@ -22,6 +22,15 @@ :version: 1.1.0b1 .. change:: + :tags: change, postgresql + + The ``sqlalchemy.dialects.postgres`` module, long deprecated, is + removed; this has emitted a warning for many years and projects + should be calling upon ``sqlalchemy.dialects.postgresql``. + Engine URLs of the form ``postgres://`` will still continue to function, + however. + + .. change:: :tags: bug, sqlite :tickets: 3634 diff --git a/doc/build/changelog/migration_11.rst b/doc/build/changelog/migration_11.rst index 3be758226..5f17b4e7e 100644 --- a/doc/build/changelog/migration_11.rst +++ b/doc/build/changelog/migration_11.rst @@ -16,7 +16,7 @@ What's New in SQLAlchemy 1.1? some issues may be moved to later milestones in order to allow for a timely release. - Document last updated: January 19, 2016 + Document last updated: January 29, 2016 Introduction ============ @@ -1364,6 +1364,15 @@ emits:: :ticket:`2729` +The "postgres" module is removed +--------------------------------- + +The ``sqlalchemy.dialects.postgres`` module, long deprecated, is +removed; this has emitted a warning for many years and projects +should be calling upon ``sqlalchemy.dialects.postgresql``. +Engine URLs of the form ``postgres://`` will still continue to function, +however. + Dialect Improvements and Changes - MySQL ============================================= diff --git a/lib/sqlalchemy/dialects/__init__.py b/lib/sqlalchemy/dialects/__init__.py index af20c3906..bf9c6d38e 100644 --- a/lib/sqlalchemy/dialects/__init__.py +++ b/lib/sqlalchemy/dialects/__init__.py @@ -17,6 +17,7 @@ __all__ = ( from .. import util +_translates = {'postgres': 'postgresql'} def _auto_fn(name): """default dialect importer. @@ -30,6 +31,14 @@ def _auto_fn(name): else: dialect = name driver = "base" + + if dialect in _translates: + translated = _translates[dialect] + util.warn_deprecated( + "The '%s' dialect name has been " + "renamed to '%s'" % (dialect, translated) + ) + dialect = translated try: module = __import__('sqlalchemy.dialects.%s' % (dialect, )).dialects except ImportError: diff --git a/lib/sqlalchemy/dialects/postgres.py b/lib/sqlalchemy/dialects/postgres.py deleted file mode 100644 index 04d37a2e6..000000000 --- a/lib/sqlalchemy/dialects/postgres.py +++ /dev/null @@ -1,18 +0,0 @@ -# dialects/postgres.py -# Copyright (C) 2005-2016 the SQLAlchemy authors and contributors -# <see AUTHORS file> -# -# This module is part of SQLAlchemy and is released under -# the MIT License: http://www.opensource.org/licenses/mit-license.php - -# backwards compat with the old name -from sqlalchemy.util import warn_deprecated - -warn_deprecated( - "The SQLAlchemy PostgreSQL dialect has been renamed from 'postgres' to " - "'postgresql'. The new URL format is " - "postgresql[+driver]://<user>:<pass>@<host>/<dbname>" -) - -from sqlalchemy.dialects.postgresql import * -from sqlalchemy.dialects.postgresql import base diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py index 52620bb78..c0e1819d6 100644 --- a/test/dialect/postgresql/test_dialect.py +++ b/test/dialect/postgresql/test_dialect.py @@ -15,6 +15,9 @@ import logging import logging.handlers from sqlalchemy.testing.mock import Mock from sqlalchemy.engine import engine_from_config +from sqlalchemy.engine import url +from sqlalchemy.testing import is_ +from sqlalchemy.testing import expect_deprecated class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): @@ -79,6 +82,13 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL): psycopg2.Error) assert isinstance(exception, exc.OperationalError) + def test_deprecated_dialect_name_still_loads(self): + with expect_deprecated( + "The 'postgres' dialect name " + "has been renamed to 'postgresql'"): + dialect = url.URL("postgres").get_dialect() + is_(dialect, postgresql.dialect) + # currently not passing with pg 9.3 that does not seem to generate # any notices here, would rather find a way to mock this @testing.requires.no_coverage |