Add related primary keys to a Question instance.
506746
def question_default_add_related_pks(self, obj):
        """"""
        if not hasattr(obj, '_choice_pks'):
            obj._choice_pks = list(obj.choices.values_list('pk', flat=True))
610652
protected function fill()
    {
        $this->primaryKeys = $this->blueprint->primaryKey();

        // Process columns
        foreach ($this->blueprint->columns() as $column) {
            $this->parseColumn($column);
        }

        if (! $this->loadRelations) {
            return;
        }

        foreach ($this->blueprint->relations() as $relation) {
            $model = $this->makeRelationModel($relation);
            $belongsTo = new BelongsTo($relation, $this, $model);
            $this->relations[$belongsTo->name()] = $belongsTo;
        }

        foreach ($this->factory->referencing($this) as $related) {
            $factory = new ReferenceFactory($related, $this);
            $references = $factory->make();
            foreach ($references as $reference) {
                $this->relations[$reference->name()] = $reference;
            }
        }
    }
55211
protected function addRelation()
    {
        if ($this->relationType == 'hasAndBelongsToMany')
        {
            $junction = $this->getJunction();

            try
            {
                Validate::table($junction)->exists();
            }
            catch (dbException $e)
            {
                Database::create($junction, [
                    $this->tables['local'] . '_id'   => 'integer',
                    $this->tables['foreign'] . '_id' => 'integer',
                ]);

                $this->insertRelationData($junction, $this->tables['local'], 'hasMany', [
                    'local'   => $this->tables['local'] . '_id',
                    'foreign' => $this->keys['local']
                ]);

                $this->insertRelationData($junction, $this->tables['foreign'], 'hasMany', [
                    'local'   => $this->tables['foreign'] . '_id',
                    'foreign' => $this->keys['foreign']
                ]);
            }
        }
        $this->insertRelationData($this->tables['local'], $this->tables['foreign'], $this->relationType, $this->keys);
    }
1353240
def add_relations(self, relations):
        """"""
        for source, destination in relations:
            self.add_relation(source, destination)
744797
def add(self, _mapping=None, **kwargs):
        
        if _mapping is not None:
            _mapping.update(kwargs)
            mapping = _mapping
        else:
            mapping = _mapping
        return self.database.zadd(self.key, mapping)
819353
def add_query_params(self, query_params):
        '''
        '''
        query_params = as_multi_dict(query_params)
        for k in query_params:
            self.query_params.pop(k, None)
            for v in query_params.getlist(k):
                self.query_params[k] = v
        self.apply_param_schema()
        return self
71990
def question_default_serializer(self, obj):
        """"""
        if not obj:
            return None
        self.question_default_add_related_pks(obj)
        return dict((
            ('id', obj.id),
            ('question_text', obj.question_text),
            self.field_to_json('DateTime', 'pub_date', obj.pub_date),
            self.field_to_json(
                'PKList', 'choices', model=Choice, pks=obj._choice_pks),
        ))
518698
public void addForeignkey(String relationName, String remoteTable, List localColumns, List remoteColumns)
    {
        ForeignkeyDef foreignkeyDef = new ForeignkeyDef(relationName, remoteTable);

        // the field arrays have the same length if we already checked the constraints
        for (int idx = 0; idx < localColumns.size(); idx++)
        {
            foreignkeyDef.addColumnPair((String)localColumns.get(idx),
                                        (String)remoteColumns.get(idx));
        }

        // we got to determine whether this foreignkey is already present 
        ForeignkeyDef def = null;

        for (Iterator it = getForeignkeys(); it.hasNext();)
        {
            def = (ForeignkeyDef)it.next();
            if (foreignkeyDef.equals(def))
            {
                return;
            }
        }
        foreignkeyDef.setOwner(this);
        _foreignkeys.add(foreignkeyDef);
    }
800597
public void addExample(DistanceInstance answeredQuery) {
		MyMultiDistanceInstance di = asMultiDistanceInstance( answeredQuery );
		for (int i=0; i<innerLearners.length; i++) {
			innerLearners[i].addExample( di.get(i) );
		}
		comboAddExample( di );
	}
533815
def skos_related(rdf):
    """"""
    for s, o in rdf.subject_objects(SKOS.related):
        rdf.add((o, SKOS.related, s))
1177266
def add_relation(app_f, app_t, weight=1):
        '''
        
        '''
        recs = TabRel.select().where(
            (TabRel.post_f_id == app_f) & (TabRel.post_t_id == app_t)
        )
        if recs.count() > 1:
            for record in recs:
                MRelation.delete(record.uid)

        if recs.count() == 0:
            uid = tools.get_uuid()
            entry = TabRel.create(
                uid=uid,
                post_f_id=app_f,
                post_t_id=app_t,
                count=1,
            )
            return entry.uid
        elif recs.count() == 1:
            MRelation.update_relation(app_f, app_t, weight)
        else:
            return False
353256
public function add_related_objects() {

		PodsField_Pick::$related_objects['table'] = array(
			'label' => __( 'Database Tables', 'pods' ),
			'group' => __( 'Advanced Objects', 'pods' ),
		);

		if ( is_multisite() ) {
			PodsField_Pick::$related_objects['site'] = array(
				'label' => __( 'Multisite Sites', 'pods' ),
				'group' => __( 'Advanced Objects', 'pods' ),
			);

			PodsField_Pick::$related_objects['network'] = array(
				'label' => __( 'Multisite Networks', 'pods' ),
				'group' => __( 'Advanced Objects', 'pods' ),
			);
		}

		PodsField_Pick::$related_objects['theme'] = array(
			'label'         => __( 'Themes', 'pods' ),
			'group'         => __( 'Advanced Objects', 'pods' ),
			'simple'        => true,
			'data_callback' => array( $this, 'data_themes' ),
		);

		PodsField_Pick::$related_objects['page-template'] = array(
			'label'         => __( 'Page Templates', 'pods' ),
			'group'         => __( 'Advanced Objects', 'pods' ),
			'simple'        => true,
			'data_callback' => array( $this, 'data_page_templates' ),
		);

		PodsField_Pick::$related_objects['sidebar'] = array(
			'label'         => __( 'Sidebars', 'pods' ),
			'group'         => __( 'Advanced Objects', 'pods' ),
			'simple'        => true,
			'data_callback' => array( $this, 'data_sidebars' ),
		);

		PodsField_Pick::$related_objects['post-types'] = array(
			'label'         => __( 'Post Type Objects', 'pods' ),
			'group'         => __( 'Advanced Objects', 'pods' ),
			'simple'        => true,
			'data_callback' => array( $this, 'data_post_types' ),
		);

		PodsField_Pick::$related_objects['taxonomies'] = array(
			'label'         => __( 'Taxonomy Objects', 'pods' ),
			'group'         => __( 'Advanced Objects', 'pods' ),
			'simple'        => true,
			'data_callback' => array( $this, 'data_taxonomies' ),
		);
	}
1266263
def insert_many(self, it):
        """"""
        unique_indexes = self._uniqueIndexes  # [ind for ind in self._indexes.values() if ind.is_unique]
        NO_SUCH_ATTR = object()
        new_objs = list(it)
        if unique_indexes:
            for ind in unique_indexes:
                ind_attr = ind.attr
                new_keys = dict((getattr(obj, ind_attr, NO_SUCH_ATTR), obj) for obj in new_objs)
                if not ind.accept_none and (None in new_keys or NO_SUCH_ATTR in new_keys):
                    raise KeyError("unique key cannot be None or blank for index %s" % ind_attr, 
                                    [ob for ob in new_objs if getattr(ob, ind_attr, NO_SUCH_ATTR) is None])
                if len(new_keys) < len(new_objs):
                    raise KeyError("given sequence contains duplicate keys for index %s" % ind_attr)
                for key in new_keys:
                    if key in ind:
                        obj = new_keys[key]
                        raise KeyError("duplicate unique key value '%s' for index %s" % (getattr(obj, ind_attr), ind_attr), 
                                       new_keys[key])
                    
        for obj in new_objs:
            self.obs.append(obj)
            for attr, ind in self._indexes.items():
                obval = getattr(obj, attr)
                ind[obval] = obj

        return self
354015
public AbstractSpecWithPrimaryKey<T> withPrimaryKey(PrimaryKey primaryKey) {
        if (primaryKey == null)
            this.keyComponents = null;
        else {
            this.keyComponents = primaryKey.getComponents();
        }
        return this;
    }
43494
def qs_add(self, *args, **kwargs):
        ''''''
        query = self.query.copy()
        if args:
            mdict = MultiDict(args[0])
            for k, v in mdict.items():
                query.add(k, v)
        for k, v in kwargs.items():
            query.add(k, v)
        return self._copy(query=query)
809913
private void addRelations(List<RelationHolder> rlHolders, Map<String, Object> values)
    {
        if (rlHolders != null)
        {
            for (RelationHolder relation : rlHolders)
            {
                values.put(relation.getRelationName(), relation.getRelationValue());
            }
        }
    }
1005688
def choice_default_add_related_pks(self, obj):
        """"""
        if not hasattr(obj, '_voter_pks'):
            obj._voter_pks = obj.voters.values_list('pk', flat=True)