From 57b08f817a15b345ef09a85a753d548858cd79bb Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Tue, 4 Feb 2020 18:30:06 -0500 Subject: [PATCH] remove DISTINCT ON SQL instruction that does nothing on MySQL The SQLAlchemy ORM call ``.distinct('host')`` indicates that an expression such as "DISTINCT ON host" should be rendered. However, this syntax is only available on PostgreSQL. When run on any other backend, the expression delivers SQL "DISTINCT" and the additional expressions are ignored. An upcoming version of SQLAlchemy will begin to warn when "DISTINCT ON" is called for on a backend that does not support it, as the semantics of "DISTINCT ON " are quite different from "DISTINCT". As Openstack targets MySQL primarily with SQLite used for unit tests, it should already be guaranteed that this query only needs to be rendering "DISTINCT" in order to pass current tests and use cases, since that's all that's being rendered. Change-Id: I267c6f772d514b442c8c3356c2babc1fe98a8b97 References: https://github.com/sqlalchemy/sqlalchemy/issues/4002 --- nova/db/sqlalchemy/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 4009b9042569..0f5d6bfe4f88 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -485,7 +485,7 @@ def service_get_all_computes_by_hv_type(context, hv_type, query = query.join(models.ComputeNode, models.Service.host == models.ComputeNode.host).\ filter(models.ComputeNode.hypervisor_type == hv_type).\ - distinct('host') + distinct() return query.all()