diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/ddl.py | 128 | ||||
| -rw-r--r-- | lib/sqlalchemy/sql/schema.py | 108 |
2 files changed, 4 insertions, 232 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 diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index d5ee1057b..af538af0e 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -123,23 +123,6 @@ class SchemaItem(SchemaEventTarget, visitors.Visitable): def __repr__(self): return util.generic_repr(self, omit_kwarg=["info"]) - @property - @util.deprecated( - "0.9", - "The :attr:`.SchemaItem.quote` attribute is deprecated and will be " - "removed in a future release. Use the :attr:`.quoted_name.quote` " - "attribute on the ``name`` field of the target schema item to retrieve" - "quoted status.", - ) - def quote(self): - """Return the value of the ``quote`` flag passed - to this schema object, for those schema items which - have a ``name`` field. - - """ - - return self.name.quote - @util.memoized_property def info(self): """Info dictionary associated with the object, allowing user-defined @@ -442,14 +425,6 @@ class Table(DialectKWArgs, SchemaItem, TableClause): __visit_name__ = "table" - @util.deprecated_params( - useexisting=( - "0.7", - "The :paramref:`.Table.useexisting` parameter is deprecated and " - "will be removed in a future release. Please use " - ":paramref:`.Table.extend_existing`.", - ) - ) def __new__(cls, *args, **kw): if not args: # python3k pickle seems to call this @@ -467,11 +442,6 @@ class Table(DialectKWArgs, SchemaItem, TableClause): schema = None keep_existing = kw.pop("keep_existing", False) extend_existing = kw.pop("extend_existing", False) - if "useexisting" in kw: - if extend_existing: - msg = "useexisting is synonymous with extend_existing." - raise exc.ArgumentError(msg) - extend_existing = kw.pop("useexisting", False) if keep_existing and extend_existing: msg = "keep_existing and extend_existing are mutually exclusive." @@ -506,21 +476,6 @@ class Table(DialectKWArgs, SchemaItem, TableClause): with util.safe_reraise(): metadata._remove_table(name, schema) - @property - @util.deprecated( - "0.9", - "The :meth:`.SchemaItem.quote` method is deprecated and will be " - "removed in a future release. Use the :attr:`.quoted_name.quote` " - "attribute on the ``schema`` field of the target schema item to " - "retrieve quoted status.", - ) - def quote_schema(self): - """Return the value of the ``quote_schema`` flag passed - to this :class:`.Table`. - """ - - return self.schema.quote - def __init__(self, *args, **kw): """Constructor for :class:`~.schema.Table`. @@ -801,22 +756,6 @@ class Table(DialectKWArgs, SchemaItem, TableClause): constraint._set_parent_with_dispatch(self) - @util.deprecated( - "0.7", - "the :meth:`.Table.append_ddl_listener` method is deprecated and " - "will be removed in a future release. Please refer to " - ":class:`.DDLEvents`.", - ) - def append_ddl_listener(self, event_name, listener): - """Append a DDL event listener to this ``Table``. - - """ - - def adapt_listener(target, connection, **kw): - listener(event_name, target, connection) - - event.listen(self, "" + event_name.replace("-", "_"), adapt_listener) - def _set_parent(self, metadata): metadata._add_table(self.name, self.schema, self) self.metadata = metadata @@ -2634,19 +2573,6 @@ class DefaultClause(FetchedValue): return "DefaultClause(%r, for_update=%r)" % (self.arg, self.for_update) -@util.deprecated_cls( - "0.6", - ":class:`.PassiveDefault` is deprecated and will be removed in a " - "future release. Please refer to :class:`.DefaultClause`.", -) -class PassiveDefault(DefaultClause): - """A DDL-specified DEFAULT column value. - """ - - def __init__(self, *arg, **kw): - DefaultClause.__init__(self, *arg, **kw) - - class Constraint(DialectKWArgs, SchemaItem): """A table-level SQL constraint.""" @@ -3747,18 +3673,9 @@ class MetaData(SchemaItem): __visit_name__ = "metadata" - @util.deprecated_params( - reflect=( - "0.8", - "The :paramref:`.MetaData.reflect` flag is deprecated and will " - "be removed in a future release. Please use the " - ":meth:`.MetaData.reflect` method.", - ) - ) def __init__( self, bind=None, - reflect=False, schema=None, quote_schema=None, naming_convention=None, @@ -3927,13 +3844,6 @@ class MetaData(SchemaItem): self._fk_memos = collections.defaultdict(list) self.bind = bind - if reflect: - if not bind: - raise exc.ArgumentError( - "A bind must be supplied in conjunction " - "with reflect=True" - ) - self.reflect() tables = None """A dictionary of :class:`.Table` objects keyed to their name or "table key". @@ -4238,24 +4148,6 @@ class MetaData(SchemaItem): except exc.UnreflectableTableError as uerr: util.warn("Skipping table %s: %s" % (name, uerr)) - @util.deprecated( - "0.7", - "the :meth:`.MetaData.append_ddl_listener` method is deprecated and " - "will be removed in a future release. Please refer to " - ":class:`.DDLEvents`.", - ) - def append_ddl_listener(self, event_name, listener): - """Append a DDL event listener to this ``MetaData``. - - - """ - - def adapt_listener(target, connection, **kw): - tables = kw["tables"] - listener(event, target, connection, tables=tables) - - event.listen(self, "" + event_name.replace("-", "_"), adapt_listener) - def create_all(self, bind=None, tables=None, checkfirst=True): """Create all tables stored in this metadata. |
