def _extra_table_args(klass): # pylint: disable=unused-argument return ( db.UniqueConstraint('workflow_id', 'person_id'), db.Index('ix_workflow_id', 'workflow_id'), db.Index('ix_person_id', 'person_id'), )
def _extra_table_args(model): if getattr(model, '_slug_uniqueness', True): return ( db.UniqueConstraint('slug', name='uq_{}'.format(model.__tablename__)), ) return ()
def _extra_table_args(cls): return ( db.UniqueConstraint('document_id', 'documentable_id', 'documentable_type'), db.Index('ix_document_id', 'document_id'), )
class Label(base.ContextRBAC, mixins.Base, db.Model, Indexed): """Represent object labels""" __tablename__ = 'labels' _fulltext_attrs = [ 'name', 'object_type', ] @validates('name') def validate_name(self, key, value): """Validates and cleans name that has leading/trailing spaces""" # pylint: disable=unused-argument,no-self-use return value if value is None else value.strip() name = db.Column(db.String, nullable=False) object_type = db.Column(db.String) _api_attrs = reflection.ApiAttributes("name") _extra_table_args = [ db.UniqueConstraint('name', 'object_type'), ] @classmethod def indexed_query(cls): return super(Label, cls).indexed_query().options( orm.Load(cls).load_only("name", "object_type"), )
def _extra_table_args(_): return ( db.UniqueConstraint("parent_type", "parent_id", "child_type", "child_id"), db.Index("ix_snapshots_parent", "parent_type", "parent_id"), db.Index("ix_snapshots_child", "child_type", "child_id"), )
def _extra_table_args(model): """If model._title_uniqueness is set, apply UNIQUE constraint to title.""" if getattr(model, '_title_uniqueness', True): return (db.UniqueConstraint('title', name='uq_t_{}'.format( model.__tablename__)), ) return ()
def _extra_table_args(cls): if getattr(cls, '_title_uniqueness', True): return ( db.UniqueConstraint( 'title', name='uq_t_{}'.format(cls.__tablename__)), ) return ()
def _extra_table_args(_): return ( db.UniqueConstraint( 'person_id', 'ac_role_id', 'object_id', 'object_type' ), db.Index('idx_object_type_object_idx', 'object_type', 'object_id'), )
def _extra_table_args(cls): return ( db.UniqueConstraint('source_id', 'source_type', 'destination_id', 'destination_type'), db.Index('ix_relationships_source', 'source_type', 'source_id'), db.Index('ix_relationships_destination', 'destination_type', 'destination_id'), )
def __table_args__(cls): # pylint: disable=no-self-argument return ( db.Index("ix_source", "source_type", "source_id", "source_attr"), # db.Index("value_string"), not needed yet db.Index("ix_value_integer", "value_integer"), db.Index("ix_value_datetime", "value_datetime"), db.UniqueConstraint( "object_id", "object_type", "attribute_definition_id", "attribute_template_id", name="uq_attributes", ), )
def _extra_table_args(_): return ( db.UniqueConstraint( 'ac_role_id', 'object_id', 'object_type', 'parent_id_nn', ), db.Index('idx_object_type_object_idx', 'object_type', 'object_id'), db.Index('ix_role_object', 'ac_role_id', 'object_type', 'object_id'), db.Index( 'idx_object_type_object_id_parent_id_nn', 'object_type', 'object_id', 'parent_id_nn', ), )
class ObjectLabel(base.ContextRBAC, Base, db.Model): """ObjectLabel Model.""" __tablename__ = 'object_labels' label_id = db.Column(db.Integer, db.ForeignKey(Label.id), nullable=False, primary_key=True) object_id = db.Column(db.Integer, nullable=False) object_type = db.Column(db.String, nullable=False) label = db.relationship( 'Label', primaryjoin='remote(Label.id) == ObjectLabel.label_id', ) labeled_object = utils.PolymorphicRelationship("object_id", "object_type", "{}_labeled") _extra_table_args = [ db.UniqueConstraint('label_id', 'object_id', 'object_type'), ]
class Label(mixins.Base, db.Model, Indexed): """Represent object labels""" __tablename__ = 'labels' _fulltext_attrs = [ 'name', 'object_type', ] name = db.Column(db.String, nullable=False) object_type = db.Column(db.String) _api_attrs = reflection.ApiAttributes("name") _extra_table_args = [ db.UniqueConstraint('name', 'object_type'), ] @classmethod def indexed_query(cls): return super(Label, cls).indexed_query().options( orm.Load(cls).load_only("name", "object_type"), )
def _extra_table_args(_): return (db.UniqueConstraint('name', 'object_type'), )
def _extra_table_args(_): return (db.UniqueConstraint('attributable_id', 'custom_attribute_id'), )
def __table_args__(cls): # pylint: disable=no-self-argument return (db.UniqueConstraint("name", "namespace_id"), )
def _extra_table_args(cls): return ( db.UniqueConstraint('person_id', 'personable_id', 'personable_type'), db.Index('ix_person_id', 'person_id'), )
def _extra_table_args(model): return (db.UniqueConstraint('person_id', name='uq_{}'.format(model.__tablename__)), db.Index('ix_user_roles_person', 'person_id'))
def _extra_table_args(cls): return ( db.UniqueConstraint('risk_id', 'object_id', 'object_type'), db.Index('ix_risk_id', 'risk_id'), )
def _extra_table_args(cls): return ( db.UniqueConstraint('person_id', 'ownable_id', 'ownable_type'), db.Index('ix_object_owners_ownable', 'ownable_type', 'ownable_id'), )
def _extra_table_args(klass): # pylint: disable=unused-argument return ( db.UniqueConstraint('task_group_id', 'object_id', 'object_type'), db.Index('ix_task_group_id', 'task_group_id'), )
def _extra_table_args(cls): return ( db.UniqueConstraint('audit_id', 'auditable_id', 'auditable_type'), db.Index('ix_audit_id', 'audit_id'), )