diff options
author | mike bayer <mike_mp@zzzcomputing.com> | 2023-02-05 16:40:43 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2023-02-05 16:40:43 +0000 |
commit | 2459619e751f39a796bb1dd9fe75947dd0961fee (patch) | |
tree | 37b4197c034b803f91b2646df2300bab4b15a7e4 /lib/sqlalchemy/orm/mapper.py | |
parent | e8f5a9277e2ffc674cde99114845b866d7e10b51 (diff) | |
parent | 92e3c21ea9b8192ff3d6ad856389186dfe8b3d3d (diff) | |
download | sqlalchemy-2459619e751f39a796bb1dd9fe75947dd0961fee.tar.gz |
Merge "dont add non-server-side cols to returning for versioning" into main
Diffstat (limited to 'lib/sqlalchemy/orm/mapper.py')
-rw-r--r-- | lib/sqlalchemy/orm/mapper.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/sqlalchemy/orm/mapper.py b/lib/sqlalchemy/orm/mapper.py index a3b209e4a..bb7e470ff 100644 --- a/lib/sqlalchemy/orm/mapper.py +++ b/lib/sqlalchemy/orm/mapper.py @@ -83,6 +83,7 @@ from ..sql import util as sql_util from ..sql import visitors from ..sql.cache_key import MemoizedHasCacheKey from ..sql.elements import KeyedColumnElement +from ..sql.schema import Column from ..sql.schema import Table from ..sql.selectable import LABEL_STYLE_TABLENAME_PLUS_COL from ..util import HasMemoized @@ -112,7 +113,6 @@ if TYPE_CHECKING: from ..sql.base import ReadOnlyColumnCollection from ..sql.elements import ColumnClause from ..sql.elements import ColumnElement - from ..sql.schema import Column from ..sql.selectable import FromClause from ..util import OrderedSet @@ -2523,6 +2523,24 @@ class Mapper( return from_obj @HasMemoized.memoized_attribute + def _version_id_has_server_side_value(self) -> bool: + vid_col = self.version_id_col + + if vid_col is None: + return False + + elif not isinstance(vid_col, Column): + return True + else: + return vid_col.server_default is not None or ( + vid_col.default is not None + and ( + not vid_col.default.is_scalar + and not vid_col.default.is_callable + ) + ) + + @HasMemoized.memoized_attribute def _single_table_criterion(self): if self.single and self.inherits and self.polymorphic_on is not None: return self.polymorphic_on._annotate( |