예제 #1
0
 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'),
     )
예제 #2
0
 def _extra_table_args(model):
   if getattr(model, '_slug_uniqueness', True):
     return (
         db.UniqueConstraint('slug',
                             name='uq_{}'.format(model.__tablename__)),
     )
   return ()
예제 #3
0
 def _extra_table_args(cls):
   return (
       db.UniqueConstraint('document_id',
                           'documentable_id',
                           'documentable_type'),
       db.Index('ix_document_id', 'document_id'),
   )
예제 #4
0
파일: label.py 프로젝트: xuechaos/ggrc-core
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"), )
예제 #5
0
파일: snapshot.py 프로젝트: kripsy/Project
 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"),
     )
예제 #6
0
 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 ()
예제 #7
0
 def _extra_table_args(cls):
   if getattr(cls, '_title_uniqueness', True):
     return (
         db.UniqueConstraint(
             'title', name='uq_t_{}'.format(cls.__tablename__)),
     )
   return ()
예제 #8
0
파일: list.py 프로젝트: testinfox/ggrc-core
 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'),
   )
예제 #9
0
 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'),
     )
예제 #10
0
 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",
         ),
     )
예제 #11
0
파일: list.py 프로젝트: pypros/ggrc-core
 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',
       ),
   )
예제 #12
0
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'),
  ]
예제 #13
0
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"),
    )
예제 #14
0
파일: role.py 프로젝트: sepatus88/ggrc-core
 def _extra_table_args(_):
     return (db.UniqueConstraint('name', 'object_type'), )
예제 #15
0
 def _extra_table_args(_):
     return (db.UniqueConstraint('attributable_id',
                                 'custom_attribute_id'), )
예제 #16
0
 def __table_args__(cls):  # pylint: disable=no-self-argument
     return (db.UniqueConstraint("name", "namespace_id"), )
예제 #17
0
 def _extra_table_args(cls):
     return (
         db.UniqueConstraint('person_id', 'personable_id',
                             'personable_type'),
         db.Index('ix_person_id', 'person_id'),
     )
예제 #18
0
 def _extra_table_args(model):
     return (db.UniqueConstraint('person_id',
                                 name='uq_{}'.format(model.__tablename__)),
             db.Index('ix_user_roles_person', 'person_id'))
예제 #19
0
 def _extra_table_args(cls):
     return (
         db.UniqueConstraint('risk_id', 'object_id', 'object_type'),
         db.Index('ix_risk_id', 'risk_id'),
     )
예제 #20
0
 def _extra_table_args(cls):
     return (
         db.UniqueConstraint('person_id', 'ownable_id', 'ownable_type'),
         db.Index('ix_object_owners_ownable', 'ownable_type', 'ownable_id'),
     )
예제 #21
0
 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'),
     )
예제 #22
0
 def _extra_table_args(cls):
     return (
         db.UniqueConstraint('audit_id', 'auditable_id', 'auditable_type'),
         db.Index('ix_audit_id', 'audit_id'),
     )