From 120347aad15fac4a54e16aa60e0e5b3b6b3995c4 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Sat, 13 Feb 2021 14:21:55 -0500 Subject: Support legacy select() in addition to select() in v1.4 Fixed regression where use of an arbitrary iterable with the :func:`_sql.select` function was not working, outside of plain lists. The forwards/backwards compatibility logic here now checks for a wider range of incoming "iterable" types including that a ``.c`` collection from a selectable can be passed directly. Pull request compliments of Oliver Rice. Fixes: #5935 Closes: #5936 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5936 Pull-request-sha: 575ab3e7df30fc8da03752d102c8eeb6cb3a3e3d Change-Id: Icd972f1078d9ea96c47a64133079f00d9b0a66f3 --- lib/sqlalchemy/sql/selectable.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 23fdf7e12..ee2c4dafc 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -4861,7 +4861,11 @@ 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__") + and not isinstance(args[0], util.string_types + (ClauseElement,)) + ) or kw: return cls.create_legacy_select(*args, **kw) else: return cls._create_future_select(*args) -- cgit v1.2.1