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 <col>" 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
This commit is contained in:
Mike Bayer 2020-02-04 18:30:06 -05:00
parent b42c54752f
commit 57b08f817a
1 changed files with 1 additions and 1 deletions

View File

@ -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()