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:
parent
b42c54752f
commit
57b08f817a
|
@ -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()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue