Ejemplo n.º 1
0
    def add_field(self, field):
        """
        Adds a field to this table

        :param field: This can be a string of a field name, a dict of {'alias': field}, or
            a ``Field`` instance
        :type field: str or dict or Field
        """
        field = FieldFactory(
            field,
        )
        field.set_table(self)

        # make sure field is not already added
        field_name = field.get_name()
        for existing_field in self.fields:
            if existing_field.get_name() == field_name:
                return None

        self.before_add_field(field)
        field.before_add()

        if field.ignore is False:
            self.fields.append(field)

        return field
Ejemplo n.º 2
0
 def remove_field(self, field):
     """
     Removes a field from this table
     @param field: This can be a string of a field name, a dict of {'alias': field}, or
         a ``Field`` instance
     @type field: str or dict or Field
     """
     new_field = FieldFactory(
         field,
     )
     new_field.set_table(self)
     new_field_identifier = new_field.get_identifier()
     for field in self.fields:
         if field.get_identifier() == new_field_identifier:
             self.fields.remove(field)
             return
Ejemplo n.º 3
0
    def remove_field(self, field):
        """
        Removes a field from this table

        :param field: This can be a string of a field name, a dict of {'alias': field}, or
            a ``Field`` instance
        :type field: str or dict or :class:`Field <querybuilder.fields.Field>`
        """
        new_field = FieldFactory(field, )
        new_field.set_table(self)
        new_field_identifier = new_field.get_identifier()
        for field in self.fields:
            if field.get_identifier() == new_field_identifier:
                self.fields.remove(field)
                return field
        return None
Ejemplo n.º 4
0
    def remove_field(self, field):
        """
        Removes a field from this table

        :param field: This can be a string of a field name, a dict of {'alias': field}, or
            a ``Field`` instance
        :type field: str or dict or :class:`Field <querybuilder.fields.Field>`
        """
        new_field = FieldFactory(
            field,
        )
        new_field.set_table(self)
        new_field_identifier = new_field.get_identifier()
        for field in self.fields:
            if field.get_identifier() == new_field_identifier:
                self.fields.remove(field)
                return field
        return None
Ejemplo n.º 5
0
    def add_field(self, field):
        """
        Adds a field to this table

        :param field: This can be a string of a field name, a dict of {'alias': field}, or
            a ``Field`` instance
        :type field: str or dict or Field
        """
        field = FieldFactory(field, )
        field.set_table(self)

        # make sure field is not already added
        field_name = field.get_name()
        for existing_field in self.fields:
            if existing_field.get_name() == field_name:
                return None

        self.before_add_field(field)
        field.before_add()

        if field.ignore is False:
            self.fields.append(field)

        return field