Fix GROUP BY usage for PostgreSQL in migrations

Currently get_duplicate_l3_ha_port_bindings[1] is not postgres-compliant
because it's GROUP BY usage is not postgres-compliant: everything in the
SELECT list must be aggregated or in GROUP BY.

This change updates get_duplicate_l3_ha_port_bindings to respect
previous PostgreSQL rule.

[1] neutron.db.migration.alembic_migrations.versions.mitaka.expand\
     .1df244e556f5_add_unique_ha_router_agent_port_bindings

Change-Id: Ie99dd31d695ab89814a86e50d45ababe53bd56fd
Closes-Bug: #1546731
This commit is contained in:
Cedric Brandily 2016-02-17 21:25:46 +01:00
parent 21d139d441
commit 77a9c1c0d4
1 changed files with 2 additions and 2 deletions

View File

@ -64,8 +64,8 @@ def get_duplicate_l3_ha_port_bindings(connection):
if 'ha_router_agent_port_bindings' not in insp.get_table_names():
return {}
session = sa.orm.Session(bind=connection.connect())
query = (session.query(ha_router_agent_port_bindings)
query = (session.query(ha_router_agent_port_bindings.c.router_id)
.group_by(ha_router_agent_port_bindings.c.router_id,
ha_router_agent_port_bindings.c.l3_agent_id)
.having(sa.func.count() > 1)).all()
return [q.router_id for q in query]
return [q[0] for q in query]