增加websocket支持
This commit is contained in:
		
							
								
								
									
										21
									
								
								vendor/gorm.io/gorm/schema/field.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										21
									
								
								vendor/gorm.io/gorm/schema/field.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -49,14 +49,11 @@ const ( | ||||
| 	Bytes  DataType = "bytes" | ||||
| ) | ||||
|  | ||||
| const DefaultAutoIncrementIncrement int64 = 1 | ||||
|  | ||||
| // Field is the representation of model schema's field | ||||
| type Field struct { | ||||
| 	Name                   string | ||||
| 	DBName                 string | ||||
| 	BindNames              []string | ||||
| 	EmbeddedBindNames      []string | ||||
| 	DataType               DataType | ||||
| 	GORMDataType           DataType | ||||
| 	PrimaryKey             bool | ||||
| @@ -90,12 +87,6 @@ type Field struct { | ||||
| 	Set                    func(context.Context, reflect.Value, interface{}) error | ||||
| 	Serializer             SerializerInterface | ||||
| 	NewValuePool           FieldNewValuePool | ||||
|  | ||||
| 	// In some db (e.g. MySQL), Unique and UniqueIndex are indistinguishable. | ||||
| 	// When a column has a (not Mul) UniqueIndex, Migrator always reports its gorm.ColumnType is Unique. | ||||
| 	// It causes field unnecessarily migration. | ||||
| 	// Therefore, we need to record the UniqueIndex on this column (exclude Mul UniqueIndex) for MigrateColumnUnique. | ||||
| 	UniqueIndex string | ||||
| } | ||||
|  | ||||
| func (field *Field) BindName() string { | ||||
| @@ -113,7 +104,6 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { | ||||
| 		Name:                   fieldStruct.Name, | ||||
| 		DBName:                 tagSetting["COLUMN"], | ||||
| 		BindNames:              []string{fieldStruct.Name}, | ||||
| 		EmbeddedBindNames:      []string{fieldStruct.Name}, | ||||
| 		FieldType:              fieldStruct.Type, | ||||
| 		IndirectFieldType:      fieldStruct.Type, | ||||
| 		StructField:            fieldStruct, | ||||
| @@ -129,7 +119,7 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { | ||||
| 		NotNull:                utils.CheckTruth(tagSetting["NOT NULL"], tagSetting["NOTNULL"]), | ||||
| 		Unique:                 utils.CheckTruth(tagSetting["UNIQUE"]), | ||||
| 		Comment:                tagSetting["COMMENT"], | ||||
| 		AutoIncrementIncrement: DefaultAutoIncrementIncrement, | ||||
| 		AutoIncrementIncrement: 1, | ||||
| 	} | ||||
|  | ||||
| 	for field.IndirectFieldType.Kind() == reflect.Ptr { | ||||
| @@ -405,9 +395,6 @@ func (schema *Schema) ParseField(fieldStruct reflect.StructField) *Field { | ||||
| 				ef.Schema = schema | ||||
| 				ef.OwnerSchema = field.EmbeddedSchema | ||||
| 				ef.BindNames = append([]string{fieldStruct.Name}, ef.BindNames...) | ||||
| 				if _, ok := field.TagSettings["EMBEDDED"]; ok || !fieldStruct.Anonymous { | ||||
| 					ef.EmbeddedBindNames = append([]string{fieldStruct.Name}, ef.EmbeddedBindNames...) | ||||
| 				} | ||||
| 				// index is negative means is pointer | ||||
| 				if field.FieldType.Kind() == reflect.Struct { | ||||
| 					ef.StructField.Index = append([]int{fieldStruct.Index[0]}, ef.StructField.Index...) | ||||
| @@ -669,7 +656,7 @@ func (field *Field) setupValuerAndSetter() { | ||||
| 				if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond { | ||||
| 					field.ReflectValueOf(ctx, value).SetInt(data.UnixNano()) | ||||
| 				} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond { | ||||
| 					field.ReflectValueOf(ctx, value).SetInt(data.UnixMilli()) | ||||
| 					field.ReflectValueOf(ctx, value).SetInt(data.UnixNano() / 1e6) | ||||
| 				} else { | ||||
| 					field.ReflectValueOf(ctx, value).SetInt(data.Unix()) | ||||
| 				} | ||||
| @@ -678,7 +665,7 @@ func (field *Field) setupValuerAndSetter() { | ||||
| 					if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond { | ||||
| 						field.ReflectValueOf(ctx, value).SetInt(data.UnixNano()) | ||||
| 					} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond { | ||||
| 						field.ReflectValueOf(ctx, value).SetInt(data.UnixMilli()) | ||||
| 						field.ReflectValueOf(ctx, value).SetInt(data.UnixNano() / 1e6) | ||||
| 					} else { | ||||
| 						field.ReflectValueOf(ctx, value).SetInt(data.Unix()) | ||||
| 					} | ||||
| @@ -743,7 +730,7 @@ func (field *Field) setupValuerAndSetter() { | ||||
| 				if field.AutoCreateTime == UnixNanosecond || field.AutoUpdateTime == UnixNanosecond { | ||||
| 					field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixNano())) | ||||
| 				} else if field.AutoCreateTime == UnixMillisecond || field.AutoUpdateTime == UnixMillisecond { | ||||
| 					field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixMilli())) | ||||
| 					field.ReflectValueOf(ctx, value).SetUint(uint64(data.UnixNano() / 1e6)) | ||||
| 				} else { | ||||
| 					field.ReflectValueOf(ctx, value).SetUint(uint64(data.Unix())) | ||||
| 				} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user