db: Remove unnecessary 'insert()' argument

The function signature for this method is change in SQLAlchemy 2.x:

  TypeError: insert() takes 1 positional argument but 2 were given

We missed this previously as the deprecation checks in SQLAlchemy were
presumably checking for non-None values.

Change-Id: I4e366a0dbad56e739370b8bec0b84f6162f3d7a0
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2023-04-17 16:41:37 +01:00
parent 1f30b5a4e2
commit b2520d6728
3 changed files with 3 additions and 3 deletions

View File

@@ -4733,7 +4733,7 @@ def instance_tag_set(context, instance_uuid, tags):
if to_add:
data = [
{'resource_id': instance_uuid, 'tag': tag} for tag in to_add]
context.session.execute(models.Tag.__table__.insert(None), data)
context.session.execute(models.Tag.__table__.insert(), data)
return context.session.query(models.Tag).filter_by(
resource_id=instance_uuid).all()

View File

@@ -125,7 +125,7 @@ def _metadata_add_to_db(context, aggregate_id, metadata, max_retries=10,
"aggregate_id": aggregate_id})
if new_entries:
context.session.execute(
api_models.AggregateMetadata.__table__.insert(None),
api_models.AggregateMetadata.__table__.insert(),
new_entries)
return metadata

View File

@@ -6617,7 +6617,7 @@ class TestDBInstanceTags(test.TestCase):
db.instance_tag_set(self.context, uuid, [tag1, tag2])
# Check insert() was called to insert 'tag1' and 'tag2'
mock_insert.assert_called_once_with(None)
mock_insert.assert_called_once_with()
mock_insert.reset_mock()
db.instance_tag_set(self.context, uuid, [tag1])