summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-04-10 17:52:47 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-04-10 17:52:47 +0000
commit1ff644d2f16a7517df7f175e1291ddaa501646dd (patch)
treea8f6e624e1500f3b77e43a22eaeb0e7b8ff20100 /lib/sqlalchemy/engine
parentfe591913030a244a9ccfdd47b371609f1f1b44af (diff)
parenta9b068ae564e5e775e312373088545b75aeaa1b0 (diff)
downloadsqlalchemy-1ff644d2f16a7517df7f175e1291ddaa501646dd.tar.gz
Merge "Remove code deprecated before version 1.1"
Diffstat (limited to 'lib/sqlalchemy/engine')
-rw-r--r--lib/sqlalchemy/engine/base.py13
-rw-r--r--lib/sqlalchemy/engine/default.py11
-rw-r--r--lib/sqlalchemy/engine/events.py60
-rw-r--r--lib/sqlalchemy/engine/interfaces.py47
-rw-r--r--lib/sqlalchemy/engine/reflection.py19
-rw-r--r--lib/sqlalchemy/engine/result.py10
6 files changed, 9 insertions, 151 deletions
diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py
index 34a4f04a9..1a5562a9b 100644
--- a/lib/sqlalchemy/engine/base.py
+++ b/lib/sqlalchemy/engine/base.py
@@ -1449,9 +1449,6 @@ class Connection(Connectable):
):
exc_info = sys.exc_info()
- if context and context.exception is None:
- context.exception = e
-
is_exit_exception = not isinstance(e, Exception)
if not self._is_disconnect:
@@ -1465,9 +1462,6 @@ class Connection(Connectable):
)
) or (is_exit_exception and not self.closed)
- if context:
- context.is_disconnect = self._is_disconnect
-
invalidate_pool_on_disconnect = not is_exit_exception
if self._reentrant_error:
@@ -1519,13 +1513,6 @@ class Connection(Connectable):
) and not self._execution_options.get(
"skip_user_error_events", False
):
- # legacy dbapi_error event
- if should_wrap and context:
- self.dispatch.dbapi_error(
- self, cursor, statement, parameters, context, e
- )
-
- # new handle_error event
ctx = ExceptionContextImpl(
e,
sqlalchemy_exception,
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py
index a896dfc73..43ebce83a 100644
--- a/lib/sqlalchemy/engine/default.py
+++ b/lib/sqlalchemy/engine/default.py
@@ -451,17 +451,6 @@ class DefaultDialect(interfaces.Dialect):
"""
return sqltypes.adapt_type(typeobj, self.colspecs)
- def get_pk_constraint(self, conn, table_name, schema=None, **kw):
- """Compatibility method, adapts the result of get_primary_keys()
- for those dialects which don't implement get_pk_constraint().
-
- """
- return {
- "constrained_columns": self.get_primary_keys(
- conn, table_name, schema=schema, **kw
- )
- }
-
def has_index(self, connection, table_name, index_name, schema=None):
if not self.has_table(connection, table_name, schema=schema):
return False
diff --git a/lib/sqlalchemy/engine/events.py b/lib/sqlalchemy/engine/events.py
index 638048e6f..32292c826 100644
--- a/lib/sqlalchemy/engine/events.py
+++ b/lib/sqlalchemy/engine/events.py
@@ -11,7 +11,6 @@ from .interfaces import Connectable
from .interfaces import Dialect
from .. import event
from .. import exc
-from .. import util
class ConnectionEvents(event.Events):
@@ -42,10 +41,9 @@ class ConnectionEvents(event.Events):
log.info("Received statement: %s", statement)
When the methods are called with a `statement` parameter, such as in
- :meth:`.after_cursor_execute`, :meth:`.before_cursor_execute` and
- :meth:`.dbapi_error`, the statement is the exact SQL string that was
- prepared for transmission to the DBAPI ``cursor`` in the connection's
- :class:`.Dialect`.
+ :meth:`.after_cursor_execute` or :meth:`.before_cursor_execute`,
+ the statement is the exact SQL string that was prepared for transmission
+ to the DBAPI ``cursor`` in the connection's :class:`.Dialect`.
The :meth:`.before_execute` and :meth:`.before_cursor_execute`
events can also be established with the ``retval=True`` flag, which
@@ -245,58 +243,6 @@ class ConnectionEvents(event.Events):
"""
- @util.deprecated(
- "0.9",
- "The :meth:`.ConnectionEvents.dbapi_error` "
- "event is deprecated and will be removed in a future release. "
- "Please refer to the :meth:`.ConnectionEvents.handle_error` "
- "event.",
- )
- def dbapi_error(
- self, conn, cursor, statement, parameters, context, exception
- ):
- """Intercept a raw DBAPI error.
-
- This event is called with the DBAPI exception instance
- received from the DBAPI itself, *before* SQLAlchemy wraps the
- exception with it's own exception wrappers, and before any
- other operations are performed on the DBAPI cursor; the
- existing transaction remains in effect as well as any state
- on the cursor.
-
- The use case here is to inject low-level exception handling
- into an :class:`.Engine`, typically for logging and
- debugging purposes.
-
- .. warning::
-
- Code should **not** modify
- any state or throw any exceptions here as this will
- interfere with SQLAlchemy's cleanup and error handling
- routines. For exception modification, please refer to the
- new :meth:`.ConnectionEvents.handle_error` event.
-
- Subsequent to this hook, SQLAlchemy may attempt any
- number of operations on the connection/cursor, including
- closing the cursor, rolling back of the transaction in the
- case of connectionless execution, and disposing of the entire
- connection pool if a "disconnect" was detected. The
- exception is then wrapped in a SQLAlchemy DBAPI exception
- wrapper and re-thrown.
-
- :param conn: :class:`.Connection` object
- :param cursor: DBAPI cursor object
- :param statement: string SQL statement, as passed to the DBAPI
- :param parameters: Dictionary, tuple, or list of parameters being
- passed to the ``execute()`` or ``executemany()`` method of the
- DBAPI ``cursor``. In some cases may be ``None``.
- :param context: :class:`.ExecutionContext` object in use. May
- be ``None``.
- :param exception: The **unwrapped** exception emitted directly from the
- DBAPI. The class here is specific to the DBAPI module in use.
-
- """
-
def handle_error(self, exception_context):
r"""Intercept all exceptions processed by the :class:`.Connection`.
diff --git a/lib/sqlalchemy/engine/interfaces.py b/lib/sqlalchemy/engine/interfaces.py
index 84def853f..6cf4d7dbd 100644
--- a/lib/sqlalchemy/engine/interfaces.py
+++ b/lib/sqlalchemy/engine/interfaces.py
@@ -245,19 +245,6 @@ class Dialect(object):
raise NotImplementedError()
- @util.deprecated(
- "0.8",
- "The :meth:`.Dialect.get_primary_keys` method is deprecated and "
- "will be removed in a future release. Please refer to the "
- ":meth:`.Dialect.get_pk_constraint` method. ",
- )
- def get_primary_keys(self, connection, table_name, schema=None, **kw):
- """Return information about primary keys in `table_name`.
-
- """
-
- raise NotImplementedError()
-
def get_pk_constraint(self, connection, table_name, schema=None, **kw):
"""Return information about the primary key constraint on
table_name`.
@@ -1094,40 +1081,6 @@ class ExecutionContext(object):
and updates.
"""
- exception = None
- """A DBAPI-level exception that was caught when this ExecutionContext
- attempted to execute a statement.
-
- This attribute is meaningful only within the
- :meth:`.ConnectionEvents.dbapi_error` event.
-
- .. versionadded:: 0.9.7
-
- .. seealso::
-
- :attr:`.ExecutionContext.is_disconnect`
-
- :meth:`.ConnectionEvents.dbapi_error`
-
- """
-
- is_disconnect = None
- """Boolean flag set to True or False when a DBAPI-level exception
- is caught when this ExecutionContext attempted to execute a statement.
-
- This attribute is meaningful only within the
- :meth:`.ConnectionEvents.dbapi_error` event.
-
- .. versionadded:: 0.9.7
-
- .. seealso::
-
- :attr:`.ExecutionContext.exception`
-
- :meth:`.ConnectionEvents.dbapi_error`
-
- """
-
def create_cursor(self):
"""Return a new cursor generated from this ExecutionContext's
connection.
diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py
index 8ef0d572f..85e671421 100644
--- a/lib/sqlalchemy/engine/reflection.py
+++ b/lib/sqlalchemy/engine/reflection.py
@@ -37,7 +37,6 @@ from .. import util
from ..sql import operators
from ..sql import schema as sa_schema
from ..sql.type_api import TypeEngine
-from ..util import deprecated
from ..util import topological
@@ -463,24 +462,6 @@ class Inspector(object):
col_def["type"] = coltype()
return col_defs
- @deprecated(
- "0.7",
- "The :meth:`.Inspector.get_primary_keys` method is deprecated and "
- "will be removed in a future release. Please refer to the "
- ":meth:`.Inspector.get_pk_constraint` method.",
- )
- def get_primary_keys(self, table_name, schema=None, **kw):
- """Return information about primary keys in `table_name`.
-
- Given a string `table_name`, and an optional string `schema`, return
- primary key information as a list of column names.
- """
-
- with self._operation_context() as conn:
- return self.dialect.get_pk_constraint(
- conn, table_name, schema, info_cache=self.info_cache, **kw
- )["constrained_columns"]
-
def get_pk_constraint(self, table_name, schema=None, **kw):
"""Return information about primary key constraint on `table_name`.
diff --git a/lib/sqlalchemy/engine/result.py b/lib/sqlalchemy/engine/result.py
index 986edd617..ba998aff0 100644
--- a/lib/sqlalchemy/engine/result.py
+++ b/lib/sqlalchemy/engine/result.py
@@ -687,13 +687,13 @@ class LegacyCursorResultMetaData(CursorResultMetaData):
def _contains(self, value, row):
key = value
if key in self._keymap:
- util.warn_deprecated(
+ util.warn_deprecated_20(
"Using the 'in' operator to test for string or column "
"keys, or integer indexes, in a :class:`.Row` object is "
"deprecated and will "
"be removed in a future release. "
"Use the `Row._fields` or `Row._mapping` attribute, i.e. "
- "'key in row._fields'"
+ "'key in row._fields'",
)
return True
else:
@@ -743,7 +743,8 @@ class LegacyCursorResultMetaData(CursorResultMetaData):
"Retreiving row values using Column objects from a "
"row that was unpickled is deprecated; adequate "
"state cannot be pickled for this to be efficient. "
- "This usage will raise KeyError in a future release."
+ "This usage will raise KeyError in a future release.",
+ version="1.4",
)
else:
util.warn_deprecated(
@@ -751,7 +752,8 @@ class LegacyCursorResultMetaData(CursorResultMetaData):
"matching names as keys is deprecated, and will raise "
"KeyError in a future release; only Column "
"objects that are explicitly part of the statement "
- "object should be used."
+ "object should be used.",
+ version="1.4",
)
if result is None:
if raiseerr: