예제 #1
0
    def set(self, state, dict_, initiator,
            passive=attributes.PASSIVE_OFF,
            check_old=None,
            pop=False):

        # Set us on the state.
        dict_[self.key] = initiator

        if initiator is None:
            # Nullify relationship args
            dict_[self.parent_token.id.key] = None
            dict_[self.parent_token.discriminator.key] = None
        else:
            # Get the primary key of the initiator and ensure we
            # can support this assignment.
            mapper = class_mapper(type(initiator))
            if len(mapper.primary_key) > 1:
                raise sa_exc.InvalidRequestError(
                    'Generic relationships against tables with composite '
                    'primary keys are not supported.')

            pk = mapper.identity_key_from_instance(initiator)[1][0]

            # Set the identifier and the discriminator.
            discriminator = table_name(initiator)
            dict_[self.parent_token.id.key] = pk
            dict_[self.parent_token.discriminator.key] = discriminator
예제 #2
0
    def set(self, state, dict_, initiator,
            passive=attributes.PASSIVE_OFF,
            check_old=None,
            pop=False):

        # Set us on the state.
        dict_[self.key] = initiator

        # Get the primary key of the initiator and ensure we
        # can support this assignment.
        mapper = class_mapper(type(initiator))
        if len(mapper.primary_key) > 1:
            raise sa_exc.InvalidRequestError(
                'Generic relationships against tables with composite '
                'primary keys are not supported.')

        pk = mapper.identity_key_from_instance(initiator)[1][0]

        # Set the identifier and the discriminator.
        discriminator = table_name(initiator)
        dict_[self.parent_token.id.key] = pk
        dict_[self.parent_token.discriminator.key] = discriminator
예제 #3
0
파일: generic.py 프로젝트: marcosptf/fedora
def class_from_table_name(state, table):
    for class_ in state.class_._decl_class_registry.values():
        name = table_name(class_)
        if name and name == table:
            return class_
    return None
예제 #4
0
파일: generic.py 프로젝트: marcosptf/fedora
 def is_type(self, other):
     discriminator = table_name(other)
     return self.property._discriminator_col == discriminator
예제 #5
0
파일: generic.py 프로젝트: marcosptf/fedora
 def __eq__(self, other):
     discriminator = table_name(other)
     q = self.property._discriminator_col == discriminator
     q &= self.property._id_col == other.id
     return q
예제 #6
0
def class_from_table_name(state, table):
    for class_ in state.class_._decl_class_registry.values():
        name = table_name(class_)
        if name and name == table:
            return class_
    return None
예제 #7
0
 def is_type(self, other):
     discriminator = table_name(other)
     return self.property._discriminator_col == discriminator
예제 #8
0
 def __eq__(self, other):
     discriminator = table_name(other)
     q = self.property._discriminator_col == discriminator
     q &= self.property._id_col == other.id
     return q