From: Oliver Rice Date: Fri, 12 Feb 2021 22:54:54 +0000 (-0600) Subject: support select() in v1.4 Fixes: #5935 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de85ad51009101b8b946d34265bd21842e127dbb;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git support select() in v1.4 Fixes: #5935 --- diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 7e2c5dd3bd..24793ea207 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -4870,7 +4870,7 @@ class Select( constructs as given, as well as ORM-mapped classes. """ - if (args and isinstance(args[0], list)) or kw: + if (args and hasattr(args[0], '__iter__')) or kw: return cls.create_legacy_select(*args, **kw) else: return cls._create_future_select(*args) diff --git a/test/sql/test_deprecations.py b/test/sql/test_deprecations.py index 35633a1a36..ea354ddd7e 100644 --- a/test/sql/test_deprecations.py +++ b/test/sql/test_deprecations.py @@ -437,6 +437,15 @@ class SelectableTest(fixtures.TestBase, AssertsCompiledSQL): stmt = select([column("q")]) self.assert_compile(stmt, "SELECT q") + def test_select_iterable_argument(self): + + with testing.expect_deprecated_20( + r"The legacy calling style of select\(\) is deprecated " + "and will be removed in SQLAlchemy 2.0" + ): + stmt = select(iter([column("q")])) + self.assert_compile(stmt, "SELECT q") + def test_select_kw_argument(self): with testing.expect_deprecated_20(