diff options
author | Dan Smith <dansmith@redhat.com> | 2021-12-02 12:01:17 -0800 |
---|---|---|
committer | Christian Rohmann <christian.rohmann@inovex.de> | 2022-05-17 20:04:50 +0200 |
commit | 677c89c23631e9083261a1a18ed438d8966e0de2 (patch) | |
tree | 5fe6493335d71f1b9c72b76279e536a7f827cbcf | |
parent | b1d635c287f950b15df207455d64d97228963e5f (diff) | |
download | glance-677c89c23631e9083261a1a18ed438d8966e0de2.tar.gz |
Fix set_property_atomic() boolean type castingwallaby-em22.1.1
In set_property_atomic() we pass an integer query filter for the
deleted field, since most projects use an integer for this column.
However, in glance the column is a boolean, which trips up postgres
since the types are different (mysql and sqlite work fine). This
minor change to use False instead of 0 should fix that for postgres
users.
Change-Id: I5149df76943c1c19f3204b904c0e2d3ef846bdf7
Closes-Bug: #1953063
(cherry picked from commit 753c74c343ab4ef32879a3dd95c3a956af77f869)
(cherry picked from commit 316ce9659acdec0bc45f8a33825ae3b076199b24)
-rw-r--r-- | glance/db/sqlalchemy/api.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/glance/db/sqlalchemy/api.py b/glance/db/sqlalchemy/api.py index 0d373ba6c..17535b776 100644 --- a/glance/db/sqlalchemy/api.py +++ b/glance/db/sqlalchemy/api.py @@ -804,13 +804,13 @@ def image_set_property_atomic(image_id, name, value): table = models.ImageProperty.__table__ # This should be: - # UPDATE image_properties SET value=$value, deleted=0 - # WHERE name=$name AND deleted!=0 + # UPDATE image_properties SET value=$value, deleted=False + # WHERE name=$name AND deleted!=False result = connection.execute(table.update().where( sa_sql.and_(table.c.name == name, table.c.image_id == image_id, - table.c.deleted != 0)).values( - value=value, deleted=0)) + table.c.deleted != False)).values( + value=value, deleted=False)) if result.rowcount == 1: # Found and updated a deleted property, so we win return @@ -855,7 +855,7 @@ def image_delete_property_atomic(image_id, name, value): sa_sql.and_(table.c.name == name, table.c.value == value, table.c.image_id == image_id, - table.c.deleted == 0))) + table.c.deleted == False))) if result.rowcount == 1: return |