Associates an object to a one-to-one association.
Other associations are done in CollectionProxy.
189830
public function setAssociation($name, $value, $raw = false)
    {
        if ($raw) {
            $this->loadedAssociations[$name] = $value;
        } else {
            return (new Setter())->set($this, $name, $value);
        }
    }
265771
public Association getAssociation() {
		if ( association == null ) {
			AssociationKey key = getAssociationKey();

			if ( hostingEntity != null ) {
				OgmEntityEntryState entryState = OgmEntityEntryState.getStateFor( session, hostingEntity );
				if ( entryState.hasAssociation( associationKeyMetadata.getCollectionRole() ) ) {
					association = entryState.getAssociation( associationKeyMetadata.getCollectionRole() );
				}
				else {
					association = gridDialect.getAssociation( key, getAssociationContext() );
					OgmEntityEntryState.getStateFor( session, hostingEntity )
							.setAssociation( associationKeyMetadata.getCollectionRole(), association );
				}
			}
			else {
				association = gridDialect.getAssociation( key, getAssociationContext() );
			}

			if ( association == null ) {
				association = gridDialect.createAssociation( key, getAssociationContext() );
				if ( hostingEntity != null ) {
					OgmEntityEntryState.getStateFor( session, hostingEntity )
							.setAssociation( associationKeyMetadata.getCollectionRole(), association );
				}
			}
		}
		return association;
	}
21320
def associate_model(model, field):
    
    class_field = model._meta.get_field(field)
    if hasattr(class_field, "field"):
        return class_field.field.related.related_model
    else:
        return class_field.related_model
87837
def association(name) #:nodoc:
      association = association_instance_get(name)

      if association.nil?
        unless reflection = self.class._reflect_on_association(name)
          raise AssociationNotFoundError.new(self, name)
        end
        association = reflection.association_class.new(self, reflection)
        association_instance_set(name, association)
      end

      association
    end
1368344
def load_associated_records
      array = @owner.class.session.connection.get_relationships(@owner.class._module.name, @owner.id, @association.to_s)
      @loaded = true
      # we use original to track the state of the collection at start
      @collection = Array.wrap(array).dup
      @original   = Array.wrap(array).freeze
    end
80111
protected function loadAssociationObjectsToObject(array $item, $object)
    {
        foreach ($this->objectMetadata->getAssociationMappings() as $associationMapping) {

            $value = null;
            if (isset($item[$associationMapping['fieldName']]) && !is_object($item[$associationMapping['fieldName']])) {
                $value = $this->objectManager->getReference($associationMapping['targetEntity'], $item[$associationMapping['fieldName']]);
            }

            if (null === $value) {
                continue;
            }

            $setter = 'set' . ucfirst($associationMapping['fieldName']);
            $this->setValue($object, $value, $setter);
        }
    }
759835
def _association(args, default_options={})
      return if options.nil?

      options = args.first

      if options.is_a?(Hash)
        options     = {}.merge(options)
        name        = options.keys.first
        properties  = options.delete(name)

        @associations[name] = default_options.merge({ :include => properties }).merge(options)
      elsif options.is_a?(Array)
        options.each do |option|
          association option
        end
      else
        @associations[options] = args[1] || {}
      end
    end
937704
function (connection, collections, cb) {

      if (!connection.identity) return cb(Errors.IdentityMissing);
      if (connections[connection.identity]) return cb(Errors.IdentityDuplicate);

      // Store the connection
      connections[connection.identity] = {
        config: connection,
        collections: collections,
        client: null
      };


      // connect to database
      new Connection(connection, function (err, client) {

        if (err) return cb(err);

        connections[connection.identity].client = client;

        // Build up a registry of collections
        Object.keys(collections).forEach(function (key) {
          connections[connection.identity].collections[key] = new Collection(collections[key], client);
        });

        // execute callback
        cb();
      });

    }
961824
def allow_relation(self, obj1, obj2, **hints):
        
        if obj1._meta.app_label != 'oldimporter' and obj2._meta.app_label != 'oldimporter':
            return True
        return None
1349964
function Association(oClass, name, info) {
		info = typeof info !== 'object' ? { type: info } : info;
		this.name = name;
		this.type = info.type || 'sap.ui.core.Control';
		this.multiple = info.multiple || false;
		this.singularName = this.multiple ? info.singularName || guessSingularName(name) : undefined;
		this.deprecated = info.deprecated || false;
		this.visibility = info.visibility || 'public';
		this.appData = remainder(this, info);
		this._oParent = oClass;
		this._sUID = 'association:' + name;
		this._iKind = this.multiple ? Kind.MULTIPLE_ASSOCIATION : Kind.SINGLE_ASSOCIATION;
		var N = capitalize(name);
		this._sGetter = 'get' + N;
		if ( this.multiple ) {
			var N1 = capitalize(this.singularName);
			this._sMutator = 'add' + N1;
			this._sRemoveMutator = 'remove' + N1;
			this._sRemoveAllMutator = 'removeAll' + N;
		} else {
			this._sMutator = 'set' + N;
			this._sRemoveMutator =
			this._sRemoveAllMutator = undefined;
		}
	}
146135
def addobject1(bunchdt, data, commdct, key, **kwargs):
    """"""
    obj = newrawobject(data, commdct, key)
    abunch = obj2bunch(data, commdct, obj)
    data.dt[key].append(obj)
    bunchdt[key].append(abunch)
    # adict = getnamedargs(*args, **kwargs)
    for kkey, value in iteritems(kwargs):
        abunch[kkey] = value
    return abunch
659282
function (next, model) {
            var loaded = this.associationLoaded(model), val;
            if (loaded && (val = this.getAssociation(model))) {
                this._setAssociationKeys(model, val);
                val.save().classic(next);
            } else {
                next();
            }
        }
137838
def _save_one(self, model, ctx):
        
        assert isinstance(ctx, ResourceQueryContext)

        self._orm.add(model)
        self._orm.flush()
180384
def insert_one(self, *args, **kwargs):
        
        # print(f"database.collection: '{self.database.name}.{self.collection.name}'")
        result = self.collection.insert_one(*args, **kwargs)
        return result.inserted_id
1121643
def addRelation(sourceSynset,relationName,targetSynset):
    
    if not isinstance(sourceSynset, Synset):
        raise TypeError("sourceSynset not Synset instance")
    elif not isinstance(targetSynset, Synset):
        raise TypeError("targetSynset not Synset instance")
    elif relationName not in RELATION_NAMES:
        raise TypeError("relationName not in RELATION_NAMES")
    else:
        sourceSynset.addRelation(
            Relation(relationName,targetSynset)
            )
        return sourceSynset
734748
function createAssociations(models, done) {
    Object.keys(models).forEach((key) => {
      let modelObj = models[key],
        instanceObj = modelObj.getInstance();
      modelObj.relations.forEach((relation) => {
        let targetModel = models[relation.name];
        if (!targetModel) {
          throw thorin.error('SQL.INVALID_ASSOCIATION', 'Target association: ' + relation.type + " " + relation.name + ' does not exist for ' + modelObj.code);
        }
        let targetInstanceObj = targetModel.getInstance();
        let opt = thorin.util.extend(getAssociationOptions(targetModel.tableName, relation.options, modelObj), {
          as: targetModel.code
        }, relation.options);
        relation.options = opt;
        if (opt.private) {
          modelObj.privateAttributes.push(opt.foreignKey.name);
        }
        try {
          instanceObj[relation.type](targetInstanceObj, opt);
        } catch (e) {
          console.error('Thorin.sql: could not create sequelize association: %s %s %s', modelObj.code, relation.type, targetModel.code, e.stack);
        }
      });
    });
    done();
  }
657696
function getCollectionsCompact(forEntity, includeNew) {
  let associations = forEntity.getMeta().fetch('associations');
  let collections  = {};

  Object.getOwnPropertyNames(associations).forEach(index => {
    let association = associations[index];

    if (association.type !== 'collection') {
      return;
    }

    collections[index] = [];
    if (!Array.isArray(forEntity[index])) {
      return;
    }

    forEntity[index].forEach(entity => {
      if (typeof entity === 'number') {
        collections[index].push(entity);

        return;
      }

      if (!(entity instanceof Entity)) {
        return;
      }

      if (entity.getId()) {
        collections[index].push(entity.getId());

        return;
      }

      if (includeNew) {
        collections[index].push(entity);

        return;
      }
    });
  });

  return collections;
}