Adds the passed +record+ to satisfy the query. Only intended to be
        used in conjunction with associations (i.e. do not use if self.record
        is None).

        Intended use case (DO THIS):

        post.comments.append(comment)

        NOT THIS:

        Query(Post).where(content="foo").append(post)

def append(self, record):
        """
        Adds the passed +record+ to satisfy the query. Only intended to be
        used in conjunction with associations (i.e. do not use if self.record
        is None).

        Intended use case (DO THIS):

        post.comments.append(comment)

        NOT THIS:

        Query(Post).where(content="foo").append(post)
        """
        if self.record:
            self._validate_record(record)
            if self.join_args:
                # As always, the related record is created when the primary
                # record is saved
                build_args = dict(self.where_query)
                # The +final_join+ is what connects the record chain to the
                # passed +record+
                final_join = self.join_args[-2]
                # don't need to worry about one-to-many through because
                # there is not enough information to find or create the
                # joining record
                # i.e. in the Forum -> Thread -> Post example
                # forum.posts.append(post) doesn't make sense since there
                # is no information about what thread it will be attached to
                # Thus, this only makes sense on many-to-many. BUT we still
                # have to consider the case where there is a one-many-many
                # To make that work, we need to treat this like when doing
                # building
                joining_relation = getattr(self.record, final_join['table'])
                # Uses the lookup info in the join to figure out what ids to
                # set, and where to get the id value from
                joining_args = {final_join['on'][0]:
                                getattr(record, final_join['on'][1])}
                build_args.update(joining_args)
                joining_record = joining_relation.build(**build_args)
                self.record._related_records.append(joining_record)
            else:
                # Add our id to their foreign key so that the relationship is
                # created
                setattr(record,
                        foreign_key(record, self.record),
                        self.record.id)
                # Add to the list of related records so that it is saved when
                # we are
                self.record._related_records.append(record)