diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-05-22 14:47:26 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2017-05-22 14:47:26 -0400 |
| commit | 0a67c1305266ba9c4558e371fa9b193788c65bea (patch) | |
| tree | d99b23444c8331a4e495fa2d56946f61c95c4ed3 /lib/sqlalchemy | |
| parent | da1bc9878b71f6f7b87e2fa7895e1631ae581609 (diff) | |
| download | sqlalchemy-0a67c1305266ba9c4558e371fa9b193788c65bea.tar.gz | |
Detect no params w/ manual version_id counter and set to itself
Fixed bug where programmatic version_id counter in conjunction with
joined table inheritance would fail if the version_id counter
were not actually incremented and no other values on the base table
were modified, as the UPDATE would have an empty SET clause. Since
programmatic version_id where version counter is not incremented
is a documented use case, this specific condition is now detected
and the UPDATE now sets the version_id value to itself, so that
concurrency checks still take place.
Change-Id: I80e385bffeed4851cc20131cbe983c173a46f655
Fixes: #3996
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/orm/persistence.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/persistence.py b/lib/sqlalchemy/orm/persistence.py index 588a1d696..86125d6f2 100644 --- a/lib/sqlalchemy/orm/persistence.py +++ b/lib/sqlalchemy/orm/persistence.py @@ -511,12 +511,19 @@ def _collect_update_commands( continue col = mapper.version_id_col + no_params = not params and not value_params params[col._label] = update_version_id if (bulk or col.key not in params) and \ mapper.version_id_generator is not False: val = mapper.version_id_generator(update_version_id) params[col.key] = val + elif mapper.version_id_generator is False and no_params: + # no version id generator, no values set on the table, + # and version id wasn't manually incremented. + # set version id to itself so we get an UPDATE + # statement + params[col.key] = update_version_id elif not (params or value_params): continue |
