From 4e754a8914a1c2c16c97bdf363d2e24bfa823730 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 25 Mar 2022 17:08:48 -0400 Subject: pep-484: the pep-484ening, SQL part three hitting DML which is causing us to open up the ColumnCollection structure a bit, as we do put anonymous column expressions with None here. However, we still want Table /TableClause to have named column collections that don't return None, so parametrize the "key" in this collection also. * rename some "immutable" elements to "readonly". we change the contents of immutablecolumncollection underneath, so it's not "immutable" Change-Id: I2593995a4e5c6eae874bed5bf76117198be8ae97 --- lib/sqlalchemy/sql/compiler.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/sql/compiler.py') diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 7fd37e9b1..a2f731ac9 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -52,7 +52,6 @@ from typing import Type from typing import TYPE_CHECKING from typing import Union -from sqlalchemy.sql.ddl import DDLElement from . import base from . import coercions from . import crud @@ -79,10 +78,12 @@ from ..util.typing import Protocol from ..util.typing import TypedDict if typing.TYPE_CHECKING: + from . import roles from .annotation import _AnnotationDict from .base import _AmbiguousTableNameMap from .base import CompileState from .cache_key import CacheKey + from .ddl import DDLElement from .dml import Insert from .dml import UpdateBase from .dml import ValuesBase @@ -724,7 +725,7 @@ class SQLCompiler(Compiled): """list of columns for which onupdate default values should be evaluated before an UPDATE takes place""" - returning: Optional[List[ColumnClause[Any]]] + returning: Optional[Sequence[roles.ColumnsClauseRole]] """list of columns that will be delivered to cursor.description or dialect equivalent via the RETURNING clause on an INSERT, UPDATE, or DELETE @@ -4099,7 +4100,9 @@ class SQLCompiler(Compiled): return " FOR UPDATE" def returning_clause( - self, stmt: UpdateBase, returning_cols: List[ColumnClause[Any]] + self, + stmt: UpdateBase, + returning_cols: Sequence[roles.ColumnsClauseRole], ) -> str: raise exc.CompileError( "RETURNING is not supported by this " -- cgit v1.2.1