]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
support select(<iterable>) in v1.4 Fixes: #5935
authorOliver Rice <github@oliverrice.com>
Fri, 12 Feb 2021 22:54:54 +0000 (16:54 -0600)
committerOliver Rice <github@oliverrice.com>
Fri, 12 Feb 2021 23:00:44 +0000 (17:00 -0600)
lib/sqlalchemy/sql/selectable.py
test/sql/test_deprecations.py

index 7e2c5dd3bd081999bac5f42ff0c4107ac0daabae..24793ea2074f0d66c7e24c7d996882cb87cb2272 100644 (file)
@@ -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)
index 35633a1a366c534664f9a984edc3d504cfdee068..ea354ddd7e11f5abe7d2d385bdee804ed7c78309 100644 (file)
@@ -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(