From 8e91cfe529b9b0150c16e52e22e4590bfbbe79fd Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 7 Nov 2022 18:40:03 -0500 Subject: establish consistency for RETURNING column labels The RETURNING clause now renders columns using the routine as that of the :class:`.Select` to generate labels, which will include disambiguating labels, as well as that a SQL function surrounding a named column will be labeled using the column name itself. This is a more comprehensive change than a similar one made for the 1.4 series that adjusted the function label issue only. includes 1.4's changelog for the backported version which also fixes an Oracle issue independently of the 2.0 series. Fixes: #8770 Change-Id: I2ab078a214a778ffe1720dbd864ae4c105a0691d --- lib/sqlalchemy/sql/selectable.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/sqlalchemy/sql/selectable.py') diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 9de015774..488dfe721 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -2193,7 +2193,9 @@ class SelectsRows(ReturnsRows): _label_style: SelectLabelStyle = LABEL_STYLE_NONE def _generate_columns_plus_names( - self, anon_for_dupe_key: bool + self, + anon_for_dupe_key: bool, + cols: Optional[_SelectIterable] = None, ) -> List[_ColumnsPlusNames]: """Generate column names as rendered in a SELECT statement by the compiler. @@ -2204,7 +2206,9 @@ class SelectsRows(ReturnsRows): _column_naming_convention as well. """ - cols = self._all_selected_columns + + if cols is None: + cols = self._all_selected_columns key_naming_convention = SelectState._column_naming_convention( self._label_style -- cgit v1.2.1