summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/ddl.py
diff options
context:
space:
mode:
authorAsif Saif Uddin (Auvi) <auvipy@gmail.com>2019-10-06 12:32:10 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2019-10-11 13:29:38 -0400
commitd9d576f1fda3687c3475511805895925ceba53b0 (patch)
tree75824f3984f6c8e50038c6a0fa38662200361dfe /lib/sqlalchemy/sql/ddl.py
parent476df84ec995324cf2162b9b28ad8a58b90cfadf (diff)
downloadsqlalchemy-d9d576f1fda3687c3475511805895925ceba53b0.tar.gz
Remove deprecated elements
Includes: PassiveDefault SchemaItem.quote Table.useexisting Table.quote_schema Table.append_ddl_listener MetaData.append_ddl_listener Metadata.reflect kw parameter (use reflect() method) DDL.execute_at DDL.on Partially-fixes: #4643 Closes: #4893 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4893 Pull-request-sha: 860eb6a253fe4a95685b4f5f3349b19823a304f3 Change-Id: I0f5b8a873e7581365ff8dba48eab358d9e8e7b13
Diffstat (limited to 'lib/sqlalchemy/sql/ddl.py')
-rw-r--r--lib/sqlalchemy/sql/ddl.py128
1 files changed, 4 insertions, 124 deletions
diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py
index 48d4bc9dc..5345dfb6b 100644
--- a/lib/sqlalchemy/sql/ddl.py
+++ b/lib/sqlalchemy/sql/ddl.py
@@ -16,7 +16,6 @@ from .base import _generative
from .base import Executable
from .base import SchemaVisitor
from .elements import ClauseElement
-from .. import event
from .. import exc
from .. import util
from ..util import topological
@@ -102,49 +101,6 @@ class DDLElement(roles.DDLRole, Executable, _DDLCompiles):
else:
bind.engine.logger.info("DDL execution skipped, criteria not met.")
- @util.deprecated(
- "0.7",
- "The :meth:`.DDLElement.execute_at` method is deprecated and will "
- "be removed in a future release. Please use the :class:`.DDLEvents` "
- "listener interface in conjunction with the "
- ":meth:`.DDLElement.execute_if` method.",
- )
- def execute_at(self, event_name, target):
- """Link execution of this DDL to the DDL lifecycle of a SchemaItem.
-
- Links this ``DDLElement`` to a ``Table`` or ``MetaData`` instance,
- executing it when that schema item is created or dropped. The DDL
- statement will be executed using the same Connection and transactional
- context as the Table create/drop itself. The ``.bind`` property of
- this statement is ignored.
-
- :param event:
- One of the events defined in the schema item's ``.ddl_events``;
- e.g. 'before-create', 'after-create', 'before-drop' or 'after-drop'
-
- :param target:
- The Table or MetaData instance for which this DDLElement will
- be associated with.
-
- A DDLElement instance can be linked to any number of schema items.
-
- ``execute_at`` builds on the ``append_ddl_listener`` interface of
- :class:`.MetaData` and :class:`.Table` objects.
-
- Caveat: Creating or dropping a Table in isolation will also trigger
- any DDL set to ``execute_at`` that Table's MetaData. This may change
- in a future release.
-
- """
-
- def call_event(target, connection, **kw):
- if self._should_execute_deprecated(
- event_name, target, connection, **kw
- ):
- return connection.execute(self.against(target))
-
- event.listen(target, "" + event_name.replace("-", "_"), call_event)
-
@_generative
def against(self, target):
"""Return a copy of this DDL against a specific schema item."""
@@ -221,11 +177,6 @@ class DDLElement(roles.DDLRole, Executable, _DDLCompiles):
self.state = state
def _should_execute(self, target, bind, **kw):
- if self.on is not None and not self._should_execute_deprecated(
- None, target, bind, **kw
- ):
- return False
-
if isinstance(self.dialect, util.string_types):
if self.dialect != bind.engine.name:
return False
@@ -239,33 +190,12 @@ class DDLElement(roles.DDLRole, Executable, _DDLCompiles):
return True
- def _should_execute_deprecated(self, event, target, bind, **kw):
- if self.on is None:
- return True
- elif isinstance(self.on, util.string_types):
- return self.on == bind.engine.name
- elif isinstance(self.on, (tuple, list, set)):
- return bind.engine.name in self.on
- else:
- return self.on(self, event, target, bind, **kw)
-
def __call__(self, target, bind, **kw):
"""Execute the DDL as a ddl_listener."""
if self._should_execute(target, bind, **kw):
return bind.execute(self.against(target))
- def _check_ddl_on(self, on):
- if on is not None and (
- not isinstance(on, util.string_types + (tuple, list, set))
- and not callable(on)
- ):
- raise exc.ArgumentError(
- "Expected the name of a database dialect, a tuple "
- "of names, or a callable for "
- "'on' criteria, got type '%s'." % type(on).__name__
- )
-
def bind(self):
if self._bind:
return self._bind
@@ -318,15 +248,7 @@ class DDL(DDLElement):
__visit_name__ = "ddl"
- @util.deprecated_params(
- on=(
- "0.7",
- "The :paramref:`.DDL.on` parameter is deprecated and will be "
- "removed in a future release. Please refer to "
- ":meth:`.DDLElement.execute_if`.",
- )
- )
- def __init__(self, statement, on=None, context=None, bind=None):
+ def __init__(self, statement, context=None, bind=None):
"""Create a DDL statement.
:param statement:
@@ -338,44 +260,6 @@ class DDL(DDLElement):
SQL bind parameters are not available in DDL statements.
- :param on:
-
- Optional filtering criteria. May be a string, tuple or a callable
- predicate. If a string, it will be compared to the name of the
- executing database dialect::
-
- DDL('something', on='postgresql')
-
- If a tuple, specifies multiple dialect names::
-
- DDL('something', on=('postgresql', 'mysql'))
-
- If a callable, it will be invoked with four positional arguments
- as well as optional keyword arguments:
-
- :ddl:
- This DDL element.
-
- :event:
- The name of the event that has triggered this DDL, such as
- 'after-create' Will be None if the DDL is executed explicitly.
-
- :target:
- The ``Table`` or ``MetaData`` object which is the target of
- this event. May be None if the DDL is executed explicitly.
-
- :connection:
- The ``Connection`` being used for DDL execution
-
- :tables:
- Optional keyword argument - a list of Table objects which are to
- be created/ dropped within a MetaData.create_all() or drop_all()
- method call.
-
-
- If the callable returns a true value, the DDL statement will be
- executed.
-
:param context:
Optional dictionary, defaults to None. These values will be
available for use in string substitutions on the DDL statement.
@@ -402,8 +286,6 @@ class DDL(DDLElement):
self.statement = statement
self.context = context or {}
- self._check_ddl_on(on)
- self.on = on
self._bind = bind
def __repr__(self):
@@ -431,10 +313,8 @@ class _CreateDropBase(DDLElement):
"""
- def __init__(self, element, on=None, bind=None):
+ def __init__(self, element, bind=None):
self.element = element
- self._check_ddl_on(on)
- self.on = on
self.bind = bind
def _create_rule_disable(self, compiler):
@@ -487,7 +367,7 @@ class CreateTable(_CreateDropBase):
__visit_name__ = "create_table"
def __init__(
- self, element, on=None, bind=None, include_foreign_key_constraints=None
+ self, element, bind=None, include_foreign_key_constraints=None
):
"""Create a :class:`.CreateTable` construct.
@@ -503,7 +383,7 @@ class CreateTable(_CreateDropBase):
.. versionadded:: 1.0.0
"""
- super(CreateTable, self).__init__(element, on=on, bind=bind)
+ super(CreateTable, self).__init__(element, bind=bind)
self.columns = [CreateColumn(column) for column in element.columns]
self.include_foreign_key_constraints = include_foreign_key_constraints