diff options
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/coercions.py | 20 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/dml.py | 165 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 22 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/schema.py | 8 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 414 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 19 |
6 files changed, 45 insertions, 603 deletions
diff --git a/lib/sqlalchemy/sql/coercions.py b/lib/sqlalchemy/sql/coercions.py index d11ab6712..fe4fc4b40 100644 --- a/lib/sqlalchemy/sql/coercions.py +++ b/lib/sqlalchemy/sql/coercions.py @@ -99,14 +99,15 @@ def _document_text_coercion(paramname, meth_rst, param_rst): def _expression_collection_was_a_list(attrname, fnname, args): if args and isinstance(args[0], (list, set, dict)) and len(args) == 1: if isinstance(args[0], list): - util.warn_deprecated_20( - 'The "%s" argument to %s(), when referring to a sequence ' + raise exc.ArgumentError( + f'The "{attrname}" argument to {fnname}(), when ' + "referring to a sequence " "of items, is now passed as a series of positional " - "elements, rather than as a list. " % (attrname, fnname) + "elements, rather than as a list. " ) return args[0] - else: - return args + + return args def expect( @@ -883,15 +884,6 @@ class StatementImpl(_CoerceLiterals, RoleImpl): original_element, resolved, argname=argname, **kw ) - def _text_coercion(self, element, argname=None): - util.warn_deprecated_20( - "Using plain strings to indicate SQL statements without using " - "the text() construct is " - "deprecated and will be removed in version 2.0. Ensure plain " - "SQL statements are passed using the text() construct." - ) - return elements.TextClause(element) - class SelectStatementImpl(_NoTextCoercion, RoleImpl): __slots__ = () diff --git a/lib/sqlalchemy/sql/dml.py b/lib/sqlalchemy/sql/dml.py index feb286d65..fad1728f8 100644 --- a/lib/sqlalchemy/sql/dml.py +++ b/lib/sqlalchemy/sql/dml.py @@ -237,66 +237,6 @@ class UpdateBase( is_dml = True - @classmethod - def _constructor_20_deprecations(cls, fn_name, clsname, names): - - param_to_method_lookup = dict( - whereclause=( - "The :paramref:`%(func)s.whereclause` parameter " - "will be removed " - "in SQLAlchemy 2.0. Please refer to the " - ":meth:`%(classname)s.where` method." - ), - values=( - "The :paramref:`%(func)s.values` parameter will be removed " - "in SQLAlchemy 2.0. Please refer to the " - ":meth:`%(classname)s.values` method." - ), - inline=( - "The :paramref:`%(func)s.inline` parameter will be " - "removed in " - "SQLAlchemy 2.0. Please use the " - ":meth:`%(classname)s.inline` method." - ), - prefixes=( - "The :paramref:`%(func)s.prefixes parameter will be " - "removed in " - "SQLAlchemy 2.0. Please use the " - ":meth:`%(classname)s.prefix_with` " - "method." - ), - return_defaults=( - "The :paramref:`%(func)s.return_defaults` parameter will be " - "removed in SQLAlchemy 2.0. Please use the " - ":meth:`%(classname)s.return_defaults` method." - ), - returning=( - "The :paramref:`%(func)s.returning` parameter will be " - "removed in SQLAlchemy 2.0. Please use the " - ":meth:`%(classname)s.returning`` method." - ), - preserve_parameter_order=( - "The :paramref:`%(func)s.preserve_parameter_order` parameter " - "will be removed in SQLAlchemy 2.0. Use the " - ":meth:`%(classname)s.ordered_values` method with a list " - "of tuples. " - ), - ) - - return util.deprecated_params( - **{ - name: ( - "2.0", - param_to_method_lookup[name] - % { - "func": "_expression.%s" % fn_name, - "classname": "_expression.%s" % clsname, - }, - ) - for name in names - } - ) - def _generate_fromclause_column_proxies(self, fromclause): fromclause._columns._populate_separate_keys( col._make_proxy(fromclause) for col in self._returning @@ -332,15 +272,6 @@ class UpdateBase( self._validate_dialect_kwargs(opt) return self - def _validate_dialect_kwargs_deprecated(self, dialect_kw): - util.warn_deprecated_20( - "Passing dialect keyword arguments directly to the " - "%s constructor is deprecated and will be removed in SQLAlchemy " - "2.0. Please use the ``with_dialect_options()`` method." - % (self.__class__.__name__) - ) - self._validate_dialect_kwargs(dialect_kw) - @_generative def returning(self: SelfUpdateBase, *cols) -> SelfUpdateBase: r"""Add a :term:`RETURNING` or equivalent clause to this statement. @@ -499,14 +430,10 @@ class ValuesBase(UpdateBase): _returning = () - def __init__(self, table, values, prefixes): + def __init__(self, table): self.table = coercions.expect( roles.DMLTableRole, table, apply_propagate_attrs=self ) - if values is not None: - self.values.non_generative(self, values) - if prefixes: - self._setup_prefixes(prefixes) @_generative @_exclusive_against( @@ -765,7 +692,7 @@ class ValuesBase(UpdateBase): :meth:`.ValuesBase.return_defaults` is used by the ORM to provide an efficient implementation for the ``eager_defaults`` feature of - :func:`.mapper`. + :class:`_orm.Mapper`. :param cols: optional list of column key names or :class:`_schema.Column` @@ -809,6 +736,7 @@ class Insert(ValuesBase): select = None include_insert_from_select_defaults = False + _inline = False is_insert = True @@ -835,26 +763,9 @@ class Insert(ValuesBase): + HasCTE._has_ctes_traverse_internals ) - @ValuesBase._constructor_20_deprecations( - "insert", - "Insert", - [ - "values", - "inline", - "prefixes", - "returning", - "return_defaults", - ], - ) def __init__( self, table, - values=None, - inline=False, - prefixes=None, - returning=None, - return_defaults=False, - **dialect_kw, ): """Construct an :class:`_expression.Insert` object. @@ -922,17 +833,7 @@ class Insert(ValuesBase): :ref:`inserts_and_updates` - SQL Expression Tutorial """ - super(Insert, self).__init__(table, values, prefixes) - self._inline = inline - if returning: - self._returning = returning - if dialect_kw: - self._validate_dialect_kwargs_deprecated(dialect_kw) - - if return_defaults: - self._return_defaults = True - if not isinstance(return_defaults, bool): - self._return_defaults_columns = return_defaults + super(Insert, self).__init__(table) @_generative def inline(self: SelfInsert) -> SelfInsert: @@ -1120,6 +1021,8 @@ class Update(DMLWhereBase, ValuesBase): __visit_name__ = "update" is_update = True + _preserve_parameter_order = False + _inline = False _traverse_internals = ( [ @@ -1142,30 +1045,9 @@ class Update(DMLWhereBase, ValuesBase): + HasCTE._has_ctes_traverse_internals ) - @ValuesBase._constructor_20_deprecations( - "update", - "Update", - [ - "whereclause", - "values", - "inline", - "prefixes", - "returning", - "return_defaults", - "preserve_parameter_order", - ], - ) def __init__( self, table, - whereclause=None, - values=None, - inline=False, - prefixes=None, - returning=None, - return_defaults=False, - preserve_parameter_order=False, - **dialect_kw, ): r"""Construct an :class:`_expression.Update` object. @@ -1275,18 +1157,7 @@ class Update(DMLWhereBase, ValuesBase): """ - self._preserve_parameter_order = preserve_parameter_order - super(Update, self).__init__(table, values, prefixes) - if returning: - self._returning = returning - if whereclause is not None: - self._where_criteria += ( - coercions.expect(roles.WhereHavingRole, whereclause), - ) - self._inline = inline - if dialect_kw: - self._validate_dialect_kwargs_deprecated(dialect_kw) - self._return_defaults = return_defaults + super(Update, self).__init__(table) @_generative def ordered_values(self: SelfUpdate, *args) -> SelfUpdate: @@ -1373,18 +1244,9 @@ class Delete(DMLWhereBase, UpdateBase): + HasCTE._has_ctes_traverse_internals ) - @ValuesBase._constructor_20_deprecations( - "delete", - "Delete", - ["whereclause", "values", "prefixes", "returning"], - ) def __init__( self, table, - whereclause=None, - returning=None, - prefixes=None, - **dialect_kw, ): r"""Construct :class:`_expression.Delete` object. @@ -1424,16 +1286,3 @@ class Delete(DMLWhereBase, UpdateBase): self.table = coercions.expect( roles.DMLTableRole, table, apply_propagate_attrs=self ) - if returning: - self._returning = returning - - if prefixes: - self._setup_prefixes(prefixes) - - if whereclause is not None: - self._where_criteria += ( - coercions.expect(roles.WhereHavingRole, whereclause), - ) - - if dialect_kw: - self._validate_dialect_kwargs_deprecated(dialect_kw) diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 6e5fbba88..3ec702e10 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -2785,10 +2785,7 @@ class Case(ColumnElement): ("else_", InternalTraversal.dp_clauseelement), ] - # TODO: for Py2k removal, this will be: - # def __init__(self, *whens, value=None, else_=None): - - def __init__(self, *whens, **kw): + def __init__(self, *whens, value=None, else_=None): r"""Produce a ``CASE`` expression. The ``CASE`` construct in SQL is a conditional object that @@ -2875,8 +2872,7 @@ class Case(ColumnElement): whether or not :paramref:`.case.value` is used. .. versionchanged:: 1.4 the :func:`_sql.case` - function now accepts the series of WHEN conditions positionally; - passing the expressions within a list is deprecated. + function now accepts the series of WHEN conditions positionally In the first form, it accepts a list of 2-tuples; each 2-tuple consists of ``(<sql expression>, <value>)``, where the SQL @@ -2911,24 +2907,14 @@ class Case(ColumnElement): """ - if "whens" in kw: - util.warn_deprecated_20( - 'The "whens" argument to case() is now passed using ' - "positional style only, not as a keyword argument." - ) - whens = (kw.pop("whens"),) - whens = coercions._expression_collection_was_a_list( "whens", "case", whens ) - try: whens = util.dictlike_iteritems(whens) except TypeError: pass - value = kw.pop("value", None) - whenlist = [ ( coercions.expect( @@ -2954,15 +2940,11 @@ class Case(ColumnElement): self.type = type_ self.whens = whenlist - else_ = kw.pop("else_", None) if else_ is not None: self.else_ = coercions.expect(roles.ExpressionElementRole, else_) else: self.else_ = None - if kw: - raise TypeError("unknown arguments: %s" % (", ".join(sorted(kw)))) - @property def _from_objects(self): return list( diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py index a5fdd39d4..d836384b4 100644 --- a/lib/sqlalchemy/sql/schema.py +++ b/lib/sqlalchemy/sql/schema.py @@ -538,12 +538,6 @@ class Table(DialectKWArgs, SchemaItem, TableClause): "1.4", "Deprecated alias of :paramref:`_schema.Table.must_exist`", ), - autoload=( - "2.0", - "The autoload parameter is deprecated and will be removed in " - "version 2.0. Please use the " - "autoload_with parameter, passing an engine or connection.", - ), ) def __new__(cls, *args, **kw): if not args and not kw: @@ -638,7 +632,7 @@ class Table(DialectKWArgs, SchemaItem, TableClause): self.fullname = self.name autoload_with = kwargs.pop("autoload_with", None) - autoload = kwargs.pop("autoload", autoload_with is not None) + autoload = autoload_with is not None # this argument is only used with _init_existing() kwargs.pop("autoload_replace", True) keep_existing = kwargs.pop("keep_existing", False) diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 9c5850761..046b41d89 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -1360,110 +1360,6 @@ class Join(roles.DMLTableRole, FromClause): .alias(name) ) - @util.deprecated_20( - ":meth:`_sql.Join.alias`", - alternative="Create a select + subquery, or alias the " - "individual tables inside the join, instead.", - ) - def alias(self, name=None, flat=False): - r"""Return an alias of this :class:`_expression.Join`. - - The default behavior here is to first produce a SELECT - construct from this :class:`_expression.Join`, then to produce an - :class:`_expression.Alias` from that. So given a join of the form:: - - j = table_a.join(table_b, table_a.c.id == table_b.c.a_id) - - The JOIN by itself would look like:: - - table_a JOIN table_b ON table_a.id = table_b.a_id - - Whereas the alias of the above, ``j.alias()``, would in a - SELECT context look like:: - - (SELECT table_a.id AS table_a_id, table_b.id AS table_b_id, - table_b.a_id AS table_b_a_id - FROM table_a - JOIN table_b ON table_a.id = table_b.a_id) AS anon_1 - - The equivalent long-hand form, given a :class:`_expression.Join` - object ``j``, is:: - - from sqlalchemy import select, alias - j = alias( - select(j.left, j.right).\ - select_from(j).\ - set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL).\ - correlate(False), - name=name - ) - - The selectable produced by :meth:`_expression.Join.alias` - features the same - columns as that of the two individual selectables presented under - a single name - the individual columns are "auto-labeled", meaning - the ``.c.`` collection of the resulting :class:`_expression.Alias` - represents - the names of the individual columns using a - ``<tablename>_<columname>`` scheme:: - - j.c.table_a_id - j.c.table_b_a_id - - :meth:`_expression.Join.alias` also features an alternate - option for aliasing joins which produces no enclosing SELECT and - does not normally apply labels to the column names. The - ``flat=True`` option will call :meth:`_expression.FromClause.alias` - against the left and right sides individually. - Using this option, no new ``SELECT`` is produced; - we instead, from a construct as below:: - - j = table_a.join(table_b, table_a.c.id == table_b.c.a_id) - j = j.alias(flat=True) - - we get a result like this:: - - table_a AS table_a_1 JOIN table_b AS table_b_1 ON - table_a_1.id = table_b_1.a_id - - The ``flat=True`` argument is also propagated to the contained - selectables, so that a composite join such as:: - - j = table_a.join( - table_b.join(table_c, - table_b.c.id == table_c.c.b_id), - table_b.c.a_id == table_a.c.id - ).alias(flat=True) - - Will produce an expression like:: - - table_a AS table_a_1 JOIN ( - table_b AS table_b_1 JOIN table_c AS table_c_1 - ON table_b_1.id = table_c_1.b_id - ) ON table_a_1.id = table_b_1.a_id - - The standalone :func:`_expression.alias` function as well as the - base :meth:`_expression.FromClause.alias` - method also support the ``flat=True`` - argument as a no-op, so that the argument can be passed to the - ``alias()`` method of any selectable. - - :param name: name given to the alias. - - :param flat: if True, produce an alias of the left and right - sides of this :class:`_expression.Join` and return the join of those - two selectables. This produces join expression that does not - include an enclosing SELECT. - - .. seealso:: - - :ref:`core_tutorial_aliases` - - :func:`_expression.alias` - - """ - return self._anonymous_fromclause(flat=flat, name=name) - @property def _hide_froms(self): return itertools.chain( @@ -2618,7 +2514,6 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause): .. versionadded:: 1.3.18 :func:`_expression.table` can now accept a ``schema`` argument. """ - super(TableClause, self).__init__() self.name = name self._columns = DedupeColumnCollection() @@ -2665,7 +2560,7 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause): c.table = self @util.preload_module("sqlalchemy.sql.dml") - def insert(self, values=None, inline=False, **kwargs): + def insert(self): """Generate an :func:`_expression.insert` construct against this :class:`_expression.TableClause`. @@ -2676,12 +2571,10 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause): See :func:`_expression.insert` for argument and usage information. """ - return util.preloaded.sql_dml.Insert( - self, values=values, inline=inline, **kwargs - ) + return util.preloaded.sql_dml.Insert(self) @util.preload_module("sqlalchemy.sql.dml") - def update(self, whereclause=None, values=None, inline=False, **kwargs): + def update(self): """Generate an :func:`_expression.update` construct against this :class:`_expression.TableClause`. @@ -2694,14 +2587,10 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause): """ return util.preloaded.sql_dml.Update( self, - whereclause=whereclause, - values=values, - inline=inline, - **kwargs, ) @util.preload_module("sqlalchemy.sql.dml") - def delete(self, whereclause=None, **kwargs): + def delete(self): """Generate a :func:`_expression.delete` construct against this :class:`_expression.TableClause`. @@ -2712,7 +2601,7 @@ class TableClause(roles.DMLTableRole, Immutable, FromClause): See :func:`_expression.delete` for argument and usage information. """ - return util.preloaded.sql_dml.Delete(self, whereclause, **kwargs) + return util.preloaded.sql_dml.Delete(self) @property def _from_objects(self): @@ -2806,7 +2695,7 @@ class Values(Generative, FromClause): ("literal_binds", InternalTraversal.dp_boolean), ] - def __init__(self, *columns, **kw): + def __init__(self, *columns, name=None, literal_binds=False): r"""Construct a :class:`_expression.Values` construct. The column expressions and the actual data for @@ -2844,8 +2733,8 @@ class Values(Generative, FromClause): super(Values, self).__init__() self._column_args = columns - self.name = kw.pop("name", None) - self.literal_binds = kw.pop("literal_binds", False) + self.name = name + self.literal_binds = literal_binds self.named_with_column = self.name is not None @property @@ -3286,65 +3175,12 @@ class SelectStatementGrouping(GroupedElement, SelectBase): return self.element._from_objects -class DeprecatedSelectBaseGenerations: - """A collection of methods available on :class:`_sql.Select` and - :class:`_sql.CompoundSelect`, these are all **deprecated** methods as they - modify the object in-place. - - """ - - @util.deprecated( - "1.4", - "The :meth:`_expression.GenerativeSelect.append_order_by` " - "method is deprecated " - "and will be removed in a future release. Use the generative method " - ":meth:`_expression.GenerativeSelect.order_by`.", - ) - def append_order_by(self, *clauses): - """Append the given ORDER BY criterion applied to this selectable. - - The criterion will be appended to any pre-existing ORDER BY criterion. - - This is an **in-place** mutation method; the - :meth:`_expression.GenerativeSelect.order_by` method is preferred, - as it - provides standard :term:`method chaining`. - - .. seealso:: - - :meth:`_expression.GenerativeSelect.order_by` - - """ - self.order_by.non_generative(self, *clauses) - - @util.deprecated( - "1.4", - "The :meth:`_expression.GenerativeSelect.append_group_by` " - "method is deprecated " - "and will be removed in a future release. Use the generative method " - ":meth:`_expression.GenerativeSelect.group_by`.", - ) - def append_group_by(self, *clauses): - """Append the given GROUP BY criterion applied to this selectable. - - The criterion will be appended to any pre-existing GROUP BY criterion. - - This is an **in-place** mutation method; the - :meth:`_expression.GenerativeSelect.group_by` method is preferred, - as it - provides standard :term:`method chaining`. - - - """ - self.group_by.non_generative(self, *clauses) - - SelfGenerativeSelect = typing.TypeVar( "SelfGenerativeSelect", bound="GenerativeSelect" ) -class GenerativeSelect(DeprecatedSelectBaseGenerations, SelectBase): +class GenerativeSelect(SelectBase): """Base class for SELECT statements where additional elements can be added. @@ -3368,39 +3204,9 @@ class GenerativeSelect(DeprecatedSelectBaseGenerations, SelectBase): _fetch_clause_options = None _for_update_arg = None - def __init__( - self, - _label_style=LABEL_STYLE_DEFAULT, - use_labels=False, - limit=None, - offset=None, - order_by=None, - group_by=None, - ): - if use_labels: - if util.SQLALCHEMY_WARN_20: - util.warn_deprecated_20( - "The use_labels=True keyword argument to GenerativeSelect " - "is deprecated and will be removed in version 2.0. Please " - "use " - "select.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) " - "if you need to replicate this legacy behavior.", - stacklevel=4, - ) - _label_style = LABEL_STYLE_TABLENAME_PLUS_COL - + def __init__(self, _label_style=LABEL_STYLE_DEFAULT): self._label_style = _label_style - if limit is not None: - self.limit.non_generative(self, limit) - if offset is not None: - self.offset.non_generative(self, offset) - - if order_by is not None: - self.order_by.non_generative(self, *util.to_list(order_by)) - if group_by is not None: - self.group_by.non_generative(self, *util.to_list(group_by)) - @_generative def with_for_update( self: SelfGenerativeSelect, @@ -3516,14 +3322,6 @@ class GenerativeSelect(DeprecatedSelectBaseGenerations, SelectBase): self._label_style = style return self - @util.deprecated_20( - ":meth:`_sql.GenerativeSelect.apply_labels`", - alternative="Use set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) " - "instead.", - ) - def apply_labels(self): - return self.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL) - @property def _group_by_clause(self): """ClauseList access to group_by_clauses for legacy dialects""" @@ -3894,9 +3692,9 @@ class CompoundSelect(HasCompileState, GenerativeSelect): INTERSECT_ALL = util.symbol("INTERSECT ALL") _is_from_container = True + _auto_correlate = False - def __init__(self, keyword, *selects, **kwargs): - self._auto_correlate = kwargs.pop("correlate", False) + def __init__(self, keyword, *selects): self.keyword = keyword self.selects = [ coercions.expect(roles.CompoundElementRole, s).self_group( @@ -3905,17 +3703,7 @@ class CompoundSelect(HasCompileState, GenerativeSelect): for s in selects ] - if kwargs and util.SQLALCHEMY_WARN_20: - util.warn_deprecated_20( - "Set functions such as union(), union_all(), extract(), etc. " - "in SQLAlchemy 2.0 will accept a " - "series of SELECT statements only. " - "Please use generative methods such as order_by() for " - "additional modifications to this CompoundSelect.", - stacklevel=4, - ) - - GenerativeSelect.__init__(self, **kwargs) + GenerativeSelect.__init__(self) @classmethod def _create_union(cls, *selects, **kwargs): @@ -3938,7 +3726,7 @@ class CompoundSelect(HasCompileState, GenerativeSelect): return CompoundSelect(CompoundSelect.UNION, *selects, **kwargs) @classmethod - def _create_union_all(cls, *selects, **kwargs): + def _create_union_all(cls, *selects): r"""Return a ``UNION ALL`` of multiple selectables. The returned object is an instance of @@ -3950,15 +3738,11 @@ class CompoundSelect(HasCompileState, GenerativeSelect): :param \*selects: a list of :class:`_expression.Select` instances. - :param \**kwargs: - available keyword arguments are the same as those of - :func:`select`. - """ - return CompoundSelect(CompoundSelect.UNION_ALL, *selects, **kwargs) + return CompoundSelect(CompoundSelect.UNION_ALL, *selects) @classmethod - def _create_except(cls, *selects, **kwargs): + def _create_except(cls, *selects): r"""Return an ``EXCEPT`` of multiple selectables. The returned object is an instance of @@ -3967,15 +3751,11 @@ class CompoundSelect(HasCompileState, GenerativeSelect): :param \*selects: a list of :class:`_expression.Select` instances. - :param \**kwargs: - available keyword arguments are the same as those of - :func:`select`. - """ - return CompoundSelect(CompoundSelect.EXCEPT, *selects, **kwargs) + return CompoundSelect(CompoundSelect.EXCEPT, *selects) @classmethod - def _create_except_all(cls, *selects, **kwargs): + def _create_except_all(cls, *selects): r"""Return an ``EXCEPT ALL`` of multiple selectables. The returned object is an instance of @@ -3984,15 +3764,11 @@ class CompoundSelect(HasCompileState, GenerativeSelect): :param \*selects: a list of :class:`_expression.Select` instances. - :param \**kwargs: - available keyword arguments are the same as those of - :func:`select`. - """ - return CompoundSelect(CompoundSelect.EXCEPT_ALL, *selects, **kwargs) + return CompoundSelect(CompoundSelect.EXCEPT_ALL, *selects) @classmethod - def _create_intersect(cls, *selects, **kwargs): + def _create_intersect(cls, *selects): r"""Return an ``INTERSECT`` of multiple selectables. The returned object is an instance of @@ -4001,15 +3777,11 @@ class CompoundSelect(HasCompileState, GenerativeSelect): :param \*selects: a list of :class:`_expression.Select` instances. - :param \**kwargs: - available keyword arguments are the same as those of - :func:`select`. - """ - return CompoundSelect(CompoundSelect.INTERSECT, *selects, **kwargs) + return CompoundSelect(CompoundSelect.INTERSECT, *selects) @classmethod - def _create_intersect_all(cls, *selects, **kwargs): + def _create_intersect_all(cls, *selects): r"""Return an ``INTERSECT ALL`` of multiple selectables. The returned object is an instance of @@ -4018,12 +3790,9 @@ class CompoundSelect(HasCompileState, GenerativeSelect): :param \*selects: a list of :class:`_expression.Select` instances. - :param \**kwargs: - available keyword arguments are the same as those of - :func:`select`. """ - return CompoundSelect(CompoundSelect.INTERSECT_ALL, *selects, **kwargs) + return CompoundSelect(CompoundSelect.INTERSECT_ALL, *selects) def _scalar_type(self): return self.selects[0]._scalar_type() @@ -4117,134 +3886,6 @@ class CompoundSelect(HasCompileState, GenerativeSelect): return self.selects[0].selected_columns -class DeprecatedSelectGenerations: - """A collection of methods available on :class:`_sql.Select`, these - are all **deprecated** methods as they modify the :class:`_sql.Select` - object in -place. - - """ - - @util.deprecated( - "1.4", - "The :meth:`_expression.Select.append_correlation` " - "method is deprecated " - "and will be removed in a future release. Use the generative " - "method :meth:`_expression.Select.correlate`.", - ) - def append_correlation(self, fromclause): - """Append the given correlation expression to this select() - construct. - - This is an **in-place** mutation method; the - :meth:`_expression.Select.correlate` method is preferred, - as it provides - standard :term:`method chaining`. - - """ - - self.correlate.non_generative(self, fromclause) - - @util.deprecated( - "1.4", - "The :meth:`_expression.Select.append_column` method is deprecated " - "and will be removed in a future release. Use the generative " - "method :meth:`_expression.Select.add_columns`.", - ) - def append_column(self, column): - """Append the given column expression to the columns clause of this - select() construct. - - E.g.:: - - my_select.append_column(some_table.c.new_column) - - This is an **in-place** mutation method; the - :meth:`_expression.Select.add_columns` method is preferred, - as it provides standard - :term:`method chaining`. - - """ - self.add_columns.non_generative(self, column) - - @util.deprecated( - "1.4", - "The :meth:`_expression.Select.append_prefix` method is deprecated " - "and will be removed in a future release. Use the generative " - "method :meth:`_expression.Select.prefix_with`.", - ) - def append_prefix(self, clause): - """Append the given columns clause prefix expression to this select() - construct. - - This is an **in-place** mutation method; the - :meth:`_expression.Select.prefix_with` method is preferred, - as it provides - standard :term:`method chaining`. - - """ - self.prefix_with.non_generative(self, clause) - - @util.deprecated( - "1.4", - "The :meth:`_expression.Select.append_whereclause` " - "method is deprecated " - "and will be removed in a future release. Use the generative " - "method :meth:`_expression.Select.where`.", - ) - def append_whereclause(self, whereclause): - """Append the given expression to this select() construct's WHERE - criterion. - - The expression will be joined to existing WHERE criterion via AND. - - This is an **in-place** mutation method; the - :meth:`_expression.Select.where` method is preferred, - as it provides standard - :term:`method chaining`. - - """ - self.where.non_generative(self, whereclause) - - @util.deprecated( - "1.4", - "The :meth:`_expression.Select.append_having` method is deprecated " - "and will be removed in a future release. Use the generative " - "method :meth:`_expression.Select.having`.", - ) - def append_having(self, having): - """Append the given expression to this select() construct's HAVING - criterion. - - The expression will be joined to existing HAVING criterion via AND. - - This is an **in-place** mutation method; the - :meth:`_expression.Select.having` method is preferred, - as it provides standard - :term:`method chaining`. - - """ - - self.having.non_generative(self, having) - - @util.deprecated( - "1.4", - "The :meth:`_expression.Select.append_from` method is deprecated " - "and will be removed in a future release. Use the generative " - "method :meth:`_expression.Select.select_from`.", - ) - def append_from(self, fromclause): - """Append the given :class:`_expression.FromClause` expression - to this select() construct's FROM clause. - - This is an **in-place** mutation method; the - :meth:`_expression.Select.select_from` method is preferred, - as it provides - standard :term:`method chaining`. - - """ - self.select_from.non_generative(self, fromclause) - - @CompileState.plugin_for("default", "select") class SelectState(util.MemoizedSlots, CompileState): __slots__ = ( @@ -4700,7 +4341,6 @@ class Select( HasSuffixes, HasHints, HasCompileState, - DeprecatedSelectGenerations, _SelectFromElements, GenerativeSelect, ): @@ -5345,7 +4985,9 @@ class Select( ) @_generative - def with_only_columns(self: SelfSelect, *columns, **kw) -> SelfSelect: + def with_only_columns( + self: SelfSelect, *columns, maintain_column_froms=False + ) -> SelfSelect: r"""Return a new :func:`_expression.select` construct with its columns clause replaced with the given columns. @@ -5404,10 +5046,6 @@ class Select( # is the case for now. self._assert_no_memoizations() - maintain_column_froms = kw.pop("maintain_column_froms", False) - if kw: - raise TypeError("unknown parameters: %s" % (", ".join(kw),)) - if maintain_column_froms: self.select_from.non_generative(self, *self.columns_clause_froms) diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index cb44fc086..3c1632172 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -1207,14 +1207,9 @@ class Enum(Emulated, String, SchemaType): .. versionadded:: 1.3.8 :param omit_aliases: A boolean that when true will remove aliases from - pep 435 enums. For backward compatibility it defaults to ``False``. - A deprecation warning is raised if the enum has aliases and this - flag was not set. + pep 435 enums. defaults to ``True``. - .. versionadded:: 1.4.5 - - .. deprecated:: 1.4 The default will be changed to ``True`` in - SQLAlchemy 2.0. + .. versionchanged:: 2.0 This parameter now defaults to True. """ self._enum_init(enums, kw) @@ -1239,7 +1234,7 @@ class Enum(Emulated, String, SchemaType): self.values_callable = kw.pop("values_callable", None) self._sort_key_function = kw.pop("sort_key_function", NO_ARG) length_arg = kw.pop("length", NO_ARG) - self._omit_aliases = kw.pop("omit_aliases", NO_ARG) + self._omit_aliases = kw.pop("omit_aliases", True) values, objects = self._parse_into_values(enums, kw) self._setup_for_values(values, objects, kw) @@ -1284,14 +1279,6 @@ class Enum(Emulated, String, SchemaType): _members = self.enum_class.__members__ - aliases = [n for n, v in _members.items() if v.name != n] - if self._omit_aliases is NO_ARG and aliases: - util.warn_deprecated_20( - "The provided enum %s contains the aliases %s. The " - "``omit_aliases`` will default to ``True`` in SQLAlchemy " - "2.0. Specify a value to silence this warning." - % (self.enum_class.__name__, aliases) - ) if self._omit_aliases is True: # remove aliases members = OrderedDict( |