]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix Existing.select_from type definition
authorFederico Caselli <cfederico87@gmail.com>
Tue, 12 Sep 2023 20:08:25 +0000 (22:08 +0200)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 12 Sep 2023 20:08:25 +0000 (22:08 +0200)
Fixed typing issue with :meth:`_sql.Existing.select_from` that
prevented its use with ORM classes.

Fixes: #10337
Change-Id: I4324c09054803f0b1ae7c4bde202cad0b55e1a4f

doc/build/changelog/unreleased_20/10337.rst [new file with mode: 0644]
lib/sqlalchemy/sql/selectable.py
test/typing/plain_files/orm/typed_queries.py

diff --git a/doc/build/changelog/unreleased_20/10337.rst b/doc/build/changelog/unreleased_20/10337.rst
new file mode 100644 (file)
index 0000000..26020d7
--- /dev/null
@@ -0,0 +1,6 @@
+.. change::
+    :tags: bug, typing
+    :tickets: 10337
+
+    Fixed typing issue with :meth:`_sql.Existing.select_from` that
+    prevented its use with ORM classes.
index 71fca7e1f2b095a002bc0b70f08907503dcd2670..b4061a80e60c7471dea269794dd1b93ee48779c6 100644 (file)
@@ -6728,7 +6728,7 @@ class Exists(UnaryExpression[bool]):
         )
         return e
 
-    def select_from(self, *froms: FromClause) -> Self:
+    def select_from(self, *froms: _FromClauseArgument) -> Self:
         """Return a new :class:`_expression.Exists` construct,
         applying the given
         expression to the :meth:`_expression.Select.select_from`
index 530e5f670fda18f54dcbec54385fe99e0596c40a..722729b506f1d4ccf1519783ac16a5f3493dd8c6 100644 (file)
@@ -6,6 +6,7 @@ from sqlalchemy import Column
 from sqlalchemy import column
 from sqlalchemy import create_engine
 from sqlalchemy import delete
+from sqlalchemy import exists
 from sqlalchemy import func
 from sqlalchemy import insert
 from sqlalchemy import Integer
@@ -530,3 +531,8 @@ def t_aliased_fromclause() -> None:
 
     # EXPECTED_TYPE: FromClause
     reveal_type(a4)
+
+
+def test_select_from() -> None:
+    select(1).select_from(User).exists()
+    exists(1).select_from(User).select()