summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2021-04-29 21:28:32 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2021-04-29 21:28:32 +0000
commitd264cb8529cea6ec6af84bcd202a8494d0860066 (patch)
treef12b1fa78a6a6645d42b6df423dc7d6dca8ea6d5 /lib/sqlalchemy
parent8716e54b5b6d9ec20d40169de3d60db3da3ad41c (diff)
parent7002b2b0b109e70b47d4ae4f5f6a4d7df5586f21 (diff)
downloadsqlalchemy-d264cb8529cea6ec6af84bcd202a8494d0860066.tar.gz
Merge "Ensure iterable passed to Select is not a mapped class"
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/sql/selectable.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index ff830dbf6..43ba0da4c 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -56,6 +56,7 @@ from .elements import UnaryExpression
from .visitors import InternalTraversal
from .. import exc
from .. import util
+from ..inspection import inspect
if util.TYPE_CHECKING:
from typing import Any
@@ -4959,8 +4960,17 @@ class Select(
"""
if (
args
- and hasattr(args[0], "__iter__")
- and not isinstance(args[0], util.string_types + (ClauseElement,))
+ and (
+ isinstance(args[0], list)
+ or (
+ hasattr(args[0], "__iter__")
+ and not isinstance(
+ args[0], util.string_types + (ClauseElement,)
+ )
+ and inspect(args[0], raiseerr=False) is None
+ and not hasattr(args[0], "__clause_element__")
+ )
+ )
) or kw:
return cls.create_legacy_select(*args, **kw)
else: