Make __table_args__ declarative in RBACColumns
The UniqueConstraint being constructed at class load time for RBACColumns meant that all tables inheriting from it ended up sharing the same UniqueConstraint object. This led to a bunch of warnings about columns being replaced from one table to another. This didn't appear to affect any functionality but it may have broken queries across both tables. This patch just converts it into a declared attr so a separate constraint object gets created for each table that inherits the class. Closes-Bug: #1550618 Change-Id: I02b8e911125c06691bf02b6e7ac02cf25c4c4142
This commit is contained in:
parent
d32290e9a5
commit
35e234db90
|
@ -16,6 +16,7 @@
|
|||
import abc
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.ext import declarative
|
||||
from sqlalchemy.orm import validates
|
||||
|
||||
from neutron._i18n import _
|
||||
|
@ -54,10 +55,12 @@ class RBACColumns(model_base.HasId, model_base.HasTenant):
|
|||
# to reference the type. sub-classes should set their own
|
||||
pass
|
||||
|
||||
__table_args__ = (
|
||||
sa.UniqueConstraint('target_tenant', 'object_id', 'action'),
|
||||
model_base.BASEV2.__table_args__
|
||||
)
|
||||
@declarative.declared_attr
|
||||
def __table_args__(cls):
|
||||
return (
|
||||
sa.UniqueConstraint('target_tenant', 'object_id', 'action'),
|
||||
model_base.BASEV2.__table_args__
|
||||
)
|
||||
|
||||
@validates('action')
|
||||
def _validate_action(self, key, action):
|
||||
|
|
Loading…
Reference in New Issue