From 4550983e0ce2f35b3585e53894c941c23693e71d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 20 May 2020 13:41:44 -0400 Subject: Performance fixes for new result set A few small mistakes led to huge callcounts. Additionally, the warn-on-get behavior which is attempting to warn for deprecated access in SQLAlchemy 2.0 is very expensive; it's not clear if its feasible to have this warning or to somehow alter how it works. Fixes: #5340 Change-Id: I73bdd2d7b6f1b25cc0222accabd585cf761a5af4 --- lib/sqlalchemy/sql/selectable.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'lib/sqlalchemy/sql/selectable.py') diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index bcab46d84..cc82c509b 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -3527,12 +3527,14 @@ class Select( @classmethod def _create_select_from_fromclause(cls, target, entities, *arg, **kw): if arg or kw: - util.warn_deprecated_20( - "Passing arguments to %s.select() is deprecated and " - "will be removed in SQLAlchemy 2.0. Please use generative " - "methods such as select().where(), etc." - % (target.__class__.__name__,) - ) + if util.SQLALCHEMY_WARN_20: + util.warn_deprecated_20( + "Passing arguments to %s.select() is deprecated and " + "will be removed in SQLAlchemy 2.0. " + "Please use generative " + "methods such as select().where(), etc." + % (target.__class__.__name__,) + ) return Select(entities, *arg, **kw) else: return Select._create_select(*entities) @@ -3744,13 +3746,14 @@ class Select( :meth:`_expression.Select.apply_labels` """ - util.warn_deprecated_20( - "The select() function in SQLAlchemy 2.0 will accept a " - "series of columns / tables and other entities only, " - "passed positionally. For forwards compatibility, use the " - "sqlalchemy.future.select() construct.", - stacklevel=4, - ) + if util.SQLALCHEMY_WARN_20: + util.warn_deprecated_20( + "The select() function in SQLAlchemy 2.0 will accept a " + "series of columns / tables and other entities only, " + "passed positionally. For forwards compatibility, use the " + "sqlalchemy.future.select() construct.", + stacklevel=4, + ) self._auto_correlate = correlate -- cgit v1.2.1