Makes sure we fetched the fields, and populate them if not.
771097
def ensure_fields(self, fields, force_refetch=False):
        

        # We fetched with fields=None, we should have fetched them all
        if self._fetched_fields is None or self._initialized_with_doc:
            return

        if force_refetch:
            missing_fields = fields
        else:
            missing_fields = [f for f in fields if f not in self._fetched_fields]

        if len(missing_fields) == 0:
            return

        if "_id" not in self:
            raise Exception("Can't ensure_fields because _id is missing")

        self.refetch_fields(missing_fields)
588106
def populate(self, **values):
        """"""
        values = values.copy()
        fields = list(self.iterate_with_name())
        for _, structure_name, field in fields:
            if structure_name in values:
                field.__set__(self, values.pop(structure_name))
        for name, _, field in fields:
            if name in values:
                field.__set__(self, values.pop(name))
963194
void setFields(Field[] fields) {
    this.fields = fields;
    this.resultSetColumnNameIndexMap = null;
    this.cachedMaxResultRowSize = null;
    this.needUpdateFieldFormats = fields != null;
    this.hasBinaryFields = false; // just in case
  }
261059
protected function setup_fields() {
		foreach ( $this->prop( 'fields' ) as $args ) {
			$field = $this->builder
				->get_field( $args, $this )
				->set_option( 'context', $this->args( 'context' ) )
				->initialize();

			if ( ! $field->check_capabilities() ) {
				continue;
			}

			if ( 'hidden' === $args['type'] ) {
				$this->builder->add_hidden_field( $args, $this );
				continue;
			}

			$this->fields[ $field->get_id() ] = $field;
		}
	}
1283911
private void populateModel()
   {
      if (m_count != 0)
      {
         m_count = 0;
         Arrays.fill(m_flags, false);
      }

      for (Resource resource : m_parentFile.getResources())
      {
         for (int loop = 0; loop < MPXResourceField.MAX_FIELDS; loop++)
         {
            if (resource.getCachedValue(MPXResourceField.getMpxjField(loop)) != null)
            {
               if (m_flags[loop] == false)
               {
                  m_flags[loop] = true;
                  m_fields[m_count] = loop;
                  ++m_count;
               }
            }
         }
      }

      //
      // Ensure the the model fields always appear in the same order
      //
      Arrays.sort(m_fields);
      System.arraycopy(m_fields, m_fields.length - m_count, m_fields, 0, m_count);
   }
358772
public void setupFields()
    {
        FieldInfo field = null;
        for (int iFieldSeq = DBConstants.MAIN_FIELD; iFieldSeq < 256; iFieldSeq++)
        {
            field = this.setupField(iFieldSeq);     // Allocate this Field (may be overidden)
            if (field == null)
                break;                              // End of fields
        }
    }
183535
function populateRelatedFields(record, includedMap, parents) {

        // IF: Object has relationships, update so this record is listed as a parent
        if (record.relationships) {
            parents = parents ? parents.concat([record]) : [record] ;
        }

        each(
            record.relationships,
            function(relationship, property) {
                // IF: relationship describes non-record specific meta;
                // append relationship meta to the record
                if (relationship && isObject(relationship.meta)) {
                    record.meta = record.meta || {};
                    record.meta[property] = relationship.meta;
                }

                // IF: No relationship data, don't add anything
                if (!relationship.data) {
                    return;
                }

                // IF: Relationship has multiple matches, create an array for matched records
                // ELSE: Assign relationship directly to the property
                if (isArray(relationship.data)) {
                    record.attributes[property] = map(
                        relationship.data,
                        function(data) {
                            return getMatchingRecord(data, includedMap, parents);
                        }
                    );
                }
                else {
                    record.attributes[property] = getMatchingRecord(
                        relationship.data,
                        includedMap,
                        parents
                    );
                }
            }
        );
    }
713191
def populate_values(self):
        '''
        
        '''
        obj = self._get_base_state()
        self.base_state = json.dumps(obj)
317889
public void setupFields()
    {
        FieldInfo field = null;
        field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field.setHidden(true);
        field = new FieldInfo(this, LAST_CHANGED, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Date.class);
        field.setHidden(true);
        field = new FieldInfo(this, DELETED, 10, null, new Boolean(false));
        field.setDataClass(Boolean.class);
        field.setHidden(true);
        field = new FieldInfo(this, CLASS_NAME, 40, null, null);
        field = new FieldInfo(this, SEQUENCE_NO, 4, null, null);
        field.setDataClass(Integer.class);
        field = new FieldInfo(this, KEY_NAME, 40, null, null);
        field = new FieldInfo(this, VALUE_NAME, 255, null, null);
    }
11526
private void populateField(FieldContainer container, FieldType target, FieldType baseline, FieldType actual)
   {
      Object value = container.getCachedValue(actual);
      if (value == null)
      {
         value = container.getCachedValue(baseline);
      }
      container.set(target, value);
   }
128229
private void ensureReturnFields(String[] requestedReturnFields) {

        if ((requestedReturnFields != null) && (requestedReturnFields.length > 0)) {
            List<String> result = new ArrayList<String>();
            for (String field : requestedReturnFields) {
                String commasep = field.replaceAll(" ", ",");
                List<String> list = CmsStringUtil.splitAsList(commasep, ',');
                if (!list.contains("*")) {
                    for (String reqField : CmsStringUtil.splitAsList(MINIMUM_FIELDS, ",")) {
                        if (!list.contains(reqField)) {
                            list.add(reqField);
                        }
                    }
                }
                result.addAll(list);
            }
            setParam(CommonParams.FL, CmsStringUtil.arrayAsString(result.toArray(new String[0]), ","));
        }
    }
1328589
private void populate(Field field, Object target, Map<String, Option> options) {
        field.setAccessible(true);
        try {
            final Object fieldValue = field.getType().newInstance();
            injectParameters(fieldValue, options);
            field.set(target, fieldValue);
        } catch (IllegalAccessException | InstantiationException e) {
            throw new RuntimeException("Could not populate field " + field, e);
        }
    }
301445
public void setupFields()
    {
        FieldInfo field = null;
        field = new FieldInfo(this, ID, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Integer.class);
        field.setHidden(true);
        field = new FieldInfo(this, LAST_CHANGED, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field.setDataClass(Date.class);
        field.setHidden(true);
        field = new FieldInfo(this, DELETED, 10, null, new Boolean(false));
        field.setDataClass(Boolean.class);
        field.setHidden(true);
        field = new FieldInfo(this, NAME, 30, null, null);
        field = new FieldInfo(this, DESCRIPTION, 40, null, null);
        field = new FieldInfo(this, SHORT_DESC, 128, null, null);
        field = new FieldInfo(this, TITLE, 40, null, null);
        field = new FieldInfo(this, ICON, Constants.DEFAULT_FIELD_LENGTH, null, null);
        field = new FieldInfo(this, FILE_LOCATION, 255, null, null);
    }
693898
protected function checkFields(){
        return $this->fields = is_array($this->fields) ? $this->getFields($this->fields) :  $this->getFields([$this->fields]);
    }
94327
private function bindResultFields()
    {
        $resultMetadata = $this->mysqliStatement->result_metadata();

        if ($resultMetadata !== false) {
            $this->resultFields = array();

            foreach ($resultMetadata->fetch_fields() as $field) {
                $this->resultFields[] = $field->name;
            }

            $resultMetadata->free();
        }
    }
1350592
public function populate()
    {
        if ($this->parentIdentifier && !$this->parentObj) {
            $this->determineParentObj();
        }

        $set = DataList::create($this->subjectClass);
        if ($this->parentObj) {
            $set = $set->filter(array(
                $this->parentField => $this->parentObj->ID
            ));
        }
        foreach ($set as $obj) {
            $obj->fill(array(
                'only_empty' => $this->onlyEmpty,
                'include_relations' => $this->includeRelations,
                'download_images' => $this->downloadImages,
                'relation_create_limit' => $this->relationCreateLimit
            ));

            if ($this->isSiteTree) {
                $obj->write();
                $obj->publish("Stage", "Live");
            }

            $this->log("Updated {$this->subjectClass} \"{$obj->getTitle()}\".");
        }
    }
748277
def _init_fields(self):
        """"""
        if self.opts.fields:
            available_field_names = self.set_class(self.opts.fields)
        else:
            available_field_names = self.set_class(self.declared_fields.keys())
            if self.opts.additional:
                available_field_names |= self.set_class(self.opts.additional)

        invalid_fields = self.set_class()

        if self.only is not None:
            # Return only fields specified in only option
            field_names = self.set_class(self.only)

            invalid_fields |= field_names - available_field_names
        else:
            field_names = available_field_names

        # If "exclude" option or param is specified, remove those fields.
        exclude_field_names = set(self.opts.exclude) | set(self.exclude)
        if exclude_field_names:
            # Note that this isn't available_field_names, since we want to
            # apply "only" for the actual calculation.
            field_names = field_names - exclude_field_names

            invalid_fields |= exclude_field_names - available_field_names

        if invalid_fields:
            message = 'Invalid fields for {}: {}.'.format(self, invalid_fields)
            raise ValueError(message)

        fields_dict = self.dict_class()
        for field_name in field_names:
            field_obj = self.declared_fields.get(field_name, ma_fields.Inferred())
            self._bind_field(field_name, field_obj)
            fields_dict[field_name] = field_obj

        dump_data_keys = [
            obj.data_key or name for name, obj in iteritems(fields_dict) if not obj.load_only
        ]
        if len(dump_data_keys) != len(set(dump_data_keys)):
            data_keys_duplicates = {x for x in dump_data_keys if dump_data_keys.count(x) > 1}
            raise ValueError(
                'The data_key argument for one or more fields collides '
                "with another field's name or data_key argument. "
                'Check the following field names and '
                'data_key arguments: {}'.format(list(data_keys_duplicates)),
            )

        load_attributes = [
            obj.attribute or name for name, obj in iteritems(fields_dict) if not obj.dump_only
        ]
        if len(load_attributes) != len(set(load_attributes)):
            attributes_duplicates = {x for x in load_attributes if load_attributes.count(x) > 1}
            raise ValueError(
                'The attribute argument for one or more fields collides '
                "with another field's name or attribute argument. "
                'Check the following field names and '
                'attribute arguments: {}'.format(list(attributes_duplicates)),
            )

        return fields_dict