Skip to content

Commit

Permalink
db: Pass case.whens as positionals, not a list
Browse files Browse the repository at this point in the history
Resolve the following RemovedIn20Warning warnings:

  The "whens" argument to case(), when referring to a sequence of items,
  is now passed as a series of positional elements, rather than as a
  list.

Change-Id: I4df3a52333d71809d6ff305a786ba6ae03a230ca
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Jul 24, 2023
1 parent c70349d commit e5a8918
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
12 changes: 6 additions & 6 deletions glance/db/sqlalchemy/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,17 +412,17 @@ def _paginate_query(query, model, limit, sort_keys, marker=None,
model_attr = getattr(model, sort_keys[j])
default = _get_default_column_value(
model_attr.property.columns[0].type)
attr = sa_sql.expression.case([(model_attr != None,
model_attr), ],
else_=default)
attr = sa_sql.expression.case(
(model_attr != None, model_attr),
else_=default)
crit_attrs.append((attr == marker_values[j]))

model_attr = getattr(model, sort_keys[i])
default = _get_default_column_value(
model_attr.property.columns[0].type)
attr = sa_sql.expression.case([(model_attr != None,
model_attr), ],
else_=default)
attr = sa_sql.expression.case(
(model_attr != None, model_attr),
else_=default)
if sort_dirs[i] == 'desc':
crit_attrs.append((attr < marker_values[i]))
elif sort_dirs[i] == 'asc':
Expand Down
7 changes: 0 additions & 7 deletions glance/tests/unit/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@ def setUp(self):
message='The ``aliased`` and ``from_joinpoint`` keyword ',
)

warnings.filterwarnings(
'ignore',
module='glance',
category=sqla_exc.SADeprecationWarning,
message=r'The "whens" argument to case\(\), ',
)

warnings.filterwarnings(
'ignore',
module='glance',
Expand Down

0 comments on commit e5a8918

Please sign in to comment.