There have been changes in the `case` element in SQLAlchemy 1.4 that
break our conditional updates.
Previously SQLA's `case` accepted 3 parameters: whens, value, and else_,
in that order, and we were passing them as positional arguments.
New SQLA has changed, and now the signature is:
def __init__(self, *whens, **kw):
So we can no longer pass them as positional arguments.
The solution proposed by this patch relies on passing whens as a keyword
argument, which is deprecated in 1.4, because that's the compatible way
between the current SQLA version and 1.4.
Once the minimum version is bumped to 1.4 we can change our code to pass
- value = case(whens=value.whens,
+ value = case(*value.whens,
Reviewed: https:/ /review. opendev. org/c/openstack /cinder/ +/790796 /opendev. org/openstack/ cinder/ commit/ 55046123f4326ae 3caf1c241323f30 e4882c57cb
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit 55046123f4326ae 3caf1c241323f30 e4882c57cb
Author: Gorka Eguileor <email address hidden>
Date: Tue May 11 17:08:30 2021 +0200
SQLA 1.4: Fix conditional update Case
There have been changes in the `case` element in SQLAlchemy 1.4 that
break our conditional updates.
Previously SQLA's `case` accepted 3 parameters: whens, value, and else_,
in that order, and we were passing them as positional arguments.
New SQLA has changed, and now the signature is:
def __init__(self, *whens, **kw):
So we can no longer pass them as positional arguments.
The solution proposed by this patch relies on passing whens as a keyword
argument, which is deprecated in 1.4, because that's the compatible way
between the current SQLA version and 1.4.
Once the minimum version is bumped to 1.4 we can change our code to pass value.whens,
- value = case(whens=
+ value = case(*value.whens,
Closes-Bug: #1928083 d9a4783f217b6c5 375afab50ed
Change-Id: Ia5c4d06affc5ac