// This returns a field descriptor for FieldType_NULL (i.e., Field_null)
178726
func NewNullFieldDescriptor(nullable NullableColumn) FieldDescriptor {
	// A null field can be nullable ...
	return newFixedLengthFieldDescriptor(
		mysql_proto.FieldType_NULL,
		nullable,
		0,
		func(b []byte) interface{} { return nil })
}
255521
func (s *sqlite3) DataTypeOf(field *StructField) string {
	var dataValue, sqlType, size, additionalType = ParseFieldStructForDialect(field, s)

	if sqlType == "" {
		switch dataValue.Kind() {
		case reflect.Bool:
			sqlType = "bool"
		case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uintptr:
			if s.fieldCanAutoIncrement(field) {
				field.TagSettingsSet("AUTO_INCREMENT", "AUTO_INCREMENT")
				sqlType = "integer primary key autoincrement"
			} else {
				sqlType = "integer"
			}
		case reflect.Int64, reflect.Uint64:
			if s.fieldCanAutoIncrement(field) {
				field.TagSettingsSet("AUTO_INCREMENT", "AUTO_INCREMENT")
				sqlType = "integer primary key autoincrement"
			} else {
				sqlType = "bigint"
			}
		case reflect.Float32, reflect.Float64:
			sqlType = "real"
		case reflect.String:
			if size > 0 && size < 65532 {
				sqlType = fmt.Sprintf("varchar(%d)", size)
			} else {
				sqlType = "text"
			}
		case reflect.Struct:
			if _, ok := dataValue.Interface().(time.Time); ok {
				sqlType = "datetime"
			}
		default:
			if IsByteArrayOrSlice(dataValue) {
				sqlType = "blob"
			}
		}
	}

	if sqlType == "" {
		panic(fmt.Sprintf("invalid sql type %s (%s) for sqlite3", dataValue.Type().Name(), dataValue.Kind().String()))
	}

	if strings.TrimSpace(additionalType) == "" {
		return sqlType
	}
	return fmt.Sprintf("%v %v", sqlType, additionalType)
}
843046
func getFieldRef(obj runtime.Object, from *corev1.EnvVarSource) (string, error) {
	return extractFieldPathAsString(obj, from.FieldRef.FieldPath)
}
440168
func (mc MongoClient) getValueDescriptor(q bson.M) (models.ValueDescriptor, error) {
	s := mc.getSessionCopy()
	defer s.Close()

	var m models.ValueDescriptor
	if err := s.DB(mc.database.Name).C(db.ValueDescriptorCollection).Find(q).One(&m); err != nil {
		return models.ValueDescriptor{}, errorMap(err)
	}
	return m, nil
}
113561
func fieldName(x Expr) *Ident {
	switch t := x.(type) {
	case *Ident:
		return t
	case *SelectorExpr:
		if _, ok := t.X.(*Ident); ok {
			return t.Sel
		}
	case *StarExpr:
		return fieldName(t.X)
	}
	return nil
}
940850
func Fields(obj interface{}) ([]reflect.StructField, error) {
	if !hasValidType(obj, []reflect.Kind{reflect.Struct, reflect.Ptr}) {
		return nil, errors.New("Cannot use GetField on a non-struct interface")
	}

	objValue := reflectValue(obj)
	objType := objValue.Type()
	fieldsCount := objType.NumField()

	var fields []reflect.StructField
	for i := 0; i < fieldsCount; i++ {
		field := objType.Field(i)
		if !isExportableField(field) {
			continue
		}

		fields = append(fields, field)
		if k := objValue.Field(i).Kind(); k == reflect.Struct || k == reflect.Ptr {
			nestedFields, _ := Fields(objValue.Field(i).Interface())
			fields = append(fields, nestedFields...)
		}
	}

	return fields, nil
}
1153361
func NewDateTime2FieldDescriptor(nullable NullableColumn, metadata []byte) (
	fd FieldDescriptor,
	remaining []byte,
	err error) {

	d := &datetime2FieldDescriptor{}

	remaining, err = d.init(
		mysql_proto.FieldType_DATETIME2,
		nullable,
		5,
		metadata)

	if err != nil {
		return nil, nil, err
	}

	return d, remaining, nil
}
616101
func (f *FilterOp) Type(fieldType string) *FilterOp {
	f.TypeProp = &TypeFilter{Value: fieldType}
	return f
}
4995
func (p *gc_parser) parse_struct_type() ast.Expr {
	var fields []*ast.Field
	parse_field := func() {
		fld := p.parse_field()
		fields = append(fields, fld)
	}

	p.expect_keyword("struct")
	p.expect('{')
	if p.tok != '}' {
		parse_field()
		for p.tok == ';' {
			p.next()
			parse_field()
		}
	}
	p.expect('}')
	return &ast.StructType{Fields: &ast.FieldList{List: fields}}
}
386782
func NewDecimalFieldDescriptor(nullable NullableColumn) FieldDescriptor {
	return &decimalFieldDescriptor{
		baseFieldDescriptor: baseFieldDescriptor{
			fieldType:  mysql_proto.FieldType_DECIMAL,
			isNullable: nullable,
		},
	}
}
48864
func newFieldDef(apiDef *raml.APIDefinition, structName string, prop raml.Property, pkg string) fieldDef {
	var (
		fieldType = prop.TypeString()               // the field type
		basicType = commons.GetBasicType(fieldType) // basic type of the field type
	)

	// for the types, check first if it is user defined type
	if _, ok := apiDef.Types[basicType]; ok {
		titledType := strings.Title(basicType)

		// check if it is a recursive type
		if titledType == strings.Title(structName) {
			titledType = "*" + titledType // add `pointer`, otherwise compiler will complain
		}

		// use strings.Replace instead of simple assignment because the fieldType
		// might be an array
		fieldType = strings.Replace(fieldType, basicType, titledType, 1)
	}
	fieldType = convertToGoType(fieldType, prop.Items.Type)

	fd := fieldDef{
		Name:      formatFieldName(prop.Name),
		fieldType: fieldType,
		IsOmitted: !prop.Required,
	}

	fd.buildValidators(prop)

	if prop.IsEnum() {
		fd.Enum = newEnum(structName, prop, pkg, false)
		fd.fieldType = fd.Enum.Name
	}

	return fd
}
1072200
func (db *DB) schemaFieldKey(name, fieldType string) (key []byte, err error) {
	if name == "" {
		return nil, errors.New("field name can not be blank")
	}
	if fieldType == "" {
		return nil, errors.New("field type can not be blank")
	}
	s, err := db.getSchema()
	if err != nil {
		return nil, err
	}
	var found bool
	for n, f := range s.Fields {
		if n == name {
			if f.Type != fieldType {
				return nil, fmt.Errorf("field %q of type %q stored as %q in db", name, fieldType, f.Type)
			}
			break
		}
	}
	if !found {
		s.Fields[name] = fieldSpec{
			Type: fieldType,
		}
		err := db.putSchema(s)
		if err != nil {
			return nil, err
		}
	}
	return append([]byte{keyPrefixFields}, []byte(name)...), nil
}
879001
func (fs *UnstructAdapter) GetFieldValue(path string) (string, error) {
	fields, err := parseFields(path)
	if err != nil {
		return "", err
	}
	s, found, err := unstructured.NestedString(
		fs.UnstructuredContent(), fields...)
	if found || err != nil {
		return s, err
	}
	return "", fmt.Errorf("no field named '%s'", path)
}
190633
func (c *Column) GetTypeDesc() string {
	desc := c.FieldType.CompactStr()
	if mysql.HasUnsignedFlag(c.Flag) && c.Tp != mysql.TypeBit && c.Tp != mysql.TypeYear {
		desc += " unsigned"
	}
	if mysql.HasZerofillFlag(c.Flag) && c.Tp != mysql.TypeYear {
		desc += " zerofill"
	}
	return desc
}
844462
func NewTimestampFieldDescriptor(nullable NullableColumn) FieldDescriptor {
	return newFixedLengthFieldDescriptor(
		mysql_proto.FieldType_TIMESTAMP,
		nullable,
		4,
		func(b []byte) interface{} {
			return time.Unix(int64(LittleEndian.Uint32(b)), 0).UTC()
		})
}
1185069
func parseFieldDefinition(parser *Parser) (interface{}, error) {
	start := parser.Token.Start
	description, err := parseDescription(parser)
	if err != nil {
		return nil, err
	}
	name, err := parseName(parser)
	if err != nil {
		return nil, err
	}
	args, err := parseArgumentDefs(parser)
	if err != nil {
		return nil, err
	}
	_, err = expect(parser, lexer.COLON)
	if err != nil {
		return nil, err
	}
	ttype, err := parseType(parser)
	if err != nil {
		return nil, err
	}
	directives, err := parseDirectives(parser)
	if err != nil {
		return nil, err
	}
	return ast.NewFieldDefinition(&ast.FieldDefinition{
		Name:        name,
		Description: description,
		Arguments:   args,
		Type:        ttype,
		Directives:  directives,
		Loc:         loc(parser, start),
	}), nil
}
889857
func (fn FieldValueFactorFunction) Field(field string) FieldValueFactorFunction {
	fn.field = field
	return fn
}