summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/selectable.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-04-04 10:13:23 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2022-04-07 10:47:53 -0400
commit2acc9ec1281b2818bd44804f040d94ec46215688 (patch)
tree40e77ef66a8682b4a1d885575412a78152806397 /lib/sqlalchemy/sql/selectable.py
parent3b4d62f4f72e8dfad7f38db192a6a90a8551608c (diff)
downloadsqlalchemy-2acc9ec1281b2818bd44804f040d94ec46215688.tar.gz
cx_Oracle modernize
Full "RETURNING" support is implemented for the cx_Oracle dialect, meaning multiple RETURNING rows are now recived for DML statements that produce more than one row for RETURNING. cx_Oracle 7 is now the minimum version for cx_Oracle. Getting Oracle to do multirow returning took about 5 minutes. however, getting Oracle's RETURNING system to integrate with ORM-enabled insert, update, delete, is a big deal because that architecture wasn't really working very robustly, including some recent changes in 1.4 for FromStatement were done in a hurry, so this patch also cleans up the FromStatement situation and begins to establish it more concretely as the base for all ReturnsRows / TextClause ORM scenarios. Fixes: #6245 Change-Id: I2b4e6007affa51ce311d2d5baa3917f356ab961f
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r--lib/sqlalchemy/sql/selectable.py24
1 files changed, 10 insertions, 14 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py
index 6504449f1..292225ce2 100644
--- a/lib/sqlalchemy/sql/selectable.py
+++ b/lib/sqlalchemy/sql/selectable.py
@@ -127,6 +127,9 @@ if TYPE_CHECKING:
_ColumnsClauseElement = Union["FromClause", ColumnElement[Any], "TextClause"]
+_LabelConventionCallable = Callable[
+ [Union["ColumnElement[Any]", "TextClause"]], Optional[str]
+]
class _JoinTargetProtocol(Protocol):
@@ -183,7 +186,7 @@ class ReturnsRows(roles.ReturnsRowsRole, DQLDMLClauseElement):
def selectable(self) -> ReturnsRows:
return self
- @util.non_memoized_property
+ @util.ro_non_memoized_property
def _all_selected_columns(self) -> _SelectIterable:
"""A sequence of column expression objects that represents the
"selected" columns of this :class:`_expression.ReturnsRows`.
@@ -3277,7 +3280,7 @@ class SelectBase(
"""
raise NotImplementedError()
- @util.non_memoized_property
+ @util.ro_non_memoized_property
def _all_selected_columns(self) -> _SelectIterable:
"""A sequence of expressions that correspond to what is rendered
in the columns clause, including :class:`_sql.TextClause`
@@ -3586,7 +3589,7 @@ class SelectStatementGrouping(GroupedElement, SelectBase):
) -> None:
self.element._generate_fromclause_column_proxies(subquery)
- @util.non_memoized_property
+ @util.ro_non_memoized_property
def _all_selected_columns(self) -> _SelectIterable:
return self.element._all_selected_columns
@@ -4297,7 +4300,7 @@ class CompoundSelect(HasCompileState, GenerativeSelect):
for select in self.selects:
select._refresh_for_new_column(column)
- @util.non_memoized_property
+ @util.ro_non_memoized_property
def _all_selected_columns(self) -> _SelectIterable:
return self.selects[0]._all_selected_columns
@@ -4408,7 +4411,7 @@ class SelectState(util.MemoizedSlots, CompileState):
@classmethod
def _column_naming_convention(
cls, label_style: SelectLabelStyle
- ) -> Callable[[Union[ColumnElement[Any], TextClause]], Optional[str]]:
+ ) -> _LabelConventionCallable:
table_qualified = label_style is LABEL_STYLE_TABLENAME_PLUS_COL
dedupe = label_style is not LABEL_STYLE_NONE
@@ -5984,7 +5987,7 @@ class Select(
)
return cc.as_readonly()
- @HasMemoized.memoized_attribute
+ @HasMemoized_ro_memoized_attribute
def _all_selected_columns(self) -> _SelectIterable:
meth = SelectState.get_plugin_class(self).all_selected_columns
return list(meth(self))
@@ -6537,14 +6540,7 @@ class TextualSelect(SelectBase):
(c.key, c) for c in self.column_args
).as_readonly()
- # def _generate_columns_plus_names(
- # self, anon_for_dupe_key: bool
- # ) -> List[Tuple[str, str, str, ColumnElement[Any], bool]]:
- # return Select._generate_columns_plus_names(
- # self, anon_for_dupe_key=anon_for_dupe_key
- # )
-
- @util.non_memoized_property
+ @util.ro_non_memoized_property
def _all_selected_columns(self) -> _SelectIterable:
return self.column_args