@@ -261,64 +261,66 @@ func TestParseFieldWithPermission(t *testing.T) {
261
261
}
262
262
}
263
263
264
- type ID int64
265
- type INT int
266
- type INT8 int8
267
- type INT16 int16
268
- type INT32 int32
269
- type INT64 int64
270
- type UINT uint
271
- type UINT8 uint8
272
- type UINT16 uint16
273
- type UINT32 uint32
274
- type UINT64 uint64
275
- type FLOAT32 float32
276
- type FLOAT64 float64
277
- type BOOL bool
278
- type STRING string
279
- type TypeAlias struct {
280
- ID
281
- INT `gorm:"column:fint"`
282
- INT8 `gorm:"column:fint8"`
283
- INT16 `gorm:"column:fint16"`
284
- INT32 `gorm:"column:fint32"`
285
- INT64 `gorm:"column:fint64"`
286
- UINT `gorm:"column:fuint"`
287
- UINT8 `gorm:"column:fuint8"`
288
- UINT16 `gorm:"column:fuint16"`
289
- UINT32 `gorm:"column:fuint32"`
290
- UINT64 `gorm:"column:fuint64"`
291
- FLOAT32 `gorm:"column:ffloat32"`
292
- FLOAT64 `gorm:"column:ffloat64"`
293
- BOOL `gorm:"column:fbool"`
294
- STRING `gorm:"column:fstring"`
295
- }
264
+ type (
265
+ ID int64
266
+ INT int
267
+ INT8 int8
268
+ INT16 int16
269
+ INT32 int32
270
+ INT64 int64
271
+ UINT uint
272
+ UINT8 uint8
273
+ UINT16 uint16
274
+ UINT32 uint32
275
+ UINT64 uint64
276
+ FLOAT32 float32
277
+ FLOAT64 float64
278
+ BOOL bool
279
+ STRING string
280
+ TypeAlias struct {
281
+ ID
282
+ INT `gorm:"column:fint"`
283
+ INT8 `gorm:"column:fint8"`
284
+ INT16 `gorm:"column:fint16"`
285
+ INT32 `gorm:"column:fint32"`
286
+ INT64 `gorm:"column:fint64"`
287
+ UINT `gorm:"column:fuint"`
288
+ UINT8 `gorm:"column:fuint8"`
289
+ UINT16 `gorm:"column:fuint16"`
290
+ UINT32 `gorm:"column:fuint32"`
291
+ UINT64 `gorm:"column:fuint64"`
292
+ FLOAT32 `gorm:"column:ffloat32"`
293
+ FLOAT64 `gorm:"column:ffloat64"`
294
+ BOOL `gorm:"column:fbool"`
295
+ STRING `gorm:"column:fstring"`
296
+ }
297
+ )
296
298
297
- func TestTypeAliasField (t * testing.T ){
299
+ func TestTypeAliasField (t * testing.T ) {
298
300
alias , err := schema .Parse (& TypeAlias {}, & sync.Map {}, schema.NamingStrategy {})
299
301
if err != nil {
300
302
t .Fatalf ("Failed to parse TypeAlias with permission, got error %v" , err )
301
303
}
302
304
303
305
fields := []* schema.Field {
304
- {Name : "ID" , DBName : "id" , BindNames : []string {"ID" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 64 , PrimaryKey : true , HasDefaultValue : true , AutoIncrement : true },
305
- {Name : "INT" , DBName : "fint" , BindNames : []string {"INT" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fint"` },
306
- {Name : "INT8" , DBName : "fint8" , BindNames : []string {"INT8" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 8 , Tag : `gorm:"column:fint8"` },
307
- {Name : "INT16" , DBName : "fint16" , BindNames : []string {"INT16" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 16 , Tag : `gorm:"column:fint16"` },
308
- {Name : "INT32" , DBName : "fint32" , BindNames : []string {"INT32" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 32 , Tag : `gorm:"column:fint32"` },
309
- {Name : "INT64" , DBName : "fint64" , BindNames : []string {"INT64" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fint64"` },
310
- {Name : "UINT" , DBName : "fuint" , BindNames : []string {"UINT" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fuint"` },
311
- {Name : "UINT8" , DBName : "fuint8" , BindNames : []string {"UINT8" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 8 , Tag : `gorm:"column:fuint8"` },
312
- {Name : "UINT16" , DBName : "fuint16" , BindNames : []string {"UINT16" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 16 , Tag : `gorm:"column:fuint16"` },
313
- {Name : "UINT32" , DBName : "fuint32" , BindNames : []string {"UINT32" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 32 , Tag : `gorm:"column:fuint32"` },
314
- {Name : "UINT64" , DBName : "fuint64" , BindNames : []string {"UINT64" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fuint64"` },
315
- {Name : "FLOAT32" , DBName : "ffloat32" , BindNames : []string {"FLOAT32" }, DataType : schema .Float , Creatable : true , Updatable : true , Readable : true , Size : 32 , Tag : `gorm:"column:ffloat32"` },
316
- {Name : "FLOAT64" , DBName : "ffloat64" , BindNames : []string {"FLOAT64" }, DataType : schema .Float , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:ffloat64"` },
317
- {Name : "BOOL" , DBName : "fbool" , BindNames : []string {"BOOL" }, DataType : schema .Bool , Creatable : true , Updatable : true , Readable : true , Tag : `gorm:"column:fbool"` },
318
- {Name : "STRING" , DBName : "fstring" , BindNames : []string {"STRING" }, DataType : schema .String , Creatable : true , Updatable : true , Readable : true , Tag : `gorm:"column:fstring"` },
306
+ {Name : "ID" , DBName : "id" , BindNames : []string {"ID" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 64 , PrimaryKey : true , HasDefaultValue : true , AutoIncrement : true },
307
+ {Name : "INT" , DBName : "fint" , BindNames : []string {"INT" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fint"` },
308
+ {Name : "INT8" , DBName : "fint8" , BindNames : []string {"INT8" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 8 , Tag : `gorm:"column:fint8"` },
309
+ {Name : "INT16" , DBName : "fint16" , BindNames : []string {"INT16" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 16 , Tag : `gorm:"column:fint16"` },
310
+ {Name : "INT32" , DBName : "fint32" , BindNames : []string {"INT32" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 32 , Tag : `gorm:"column:fint32"` },
311
+ {Name : "INT64" , DBName : "fint64" , BindNames : []string {"INT64" }, DataType : schema .Int , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fint64"` },
312
+ {Name : "UINT" , DBName : "fuint" , BindNames : []string {"UINT" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fuint"` },
313
+ {Name : "UINT8" , DBName : "fuint8" , BindNames : []string {"UINT8" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 8 , Tag : `gorm:"column:fuint8"` },
314
+ {Name : "UINT16" , DBName : "fuint16" , BindNames : []string {"UINT16" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 16 , Tag : `gorm:"column:fuint16"` },
315
+ {Name : "UINT32" , DBName : "fuint32" , BindNames : []string {"UINT32" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 32 , Tag : `gorm:"column:fuint32"` },
316
+ {Name : "UINT64" , DBName : "fuint64" , BindNames : []string {"UINT64" }, DataType : schema .Uint , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:fuint64"` },
317
+ {Name : "FLOAT32" , DBName : "ffloat32" , BindNames : []string {"FLOAT32" }, DataType : schema .Float , Creatable : true , Updatable : true , Readable : true , Size : 32 , Tag : `gorm:"column:ffloat32"` },
318
+ {Name : "FLOAT64" , DBName : "ffloat64" , BindNames : []string {"FLOAT64" }, DataType : schema .Float , Creatable : true , Updatable : true , Readable : true , Size : 64 , Tag : `gorm:"column:ffloat64"` },
319
+ {Name : "BOOL" , DBName : "fbool" , BindNames : []string {"BOOL" }, DataType : schema .Bool , Creatable : true , Updatable : true , Readable : true , Tag : `gorm:"column:fbool"` },
320
+ {Name : "STRING" , DBName : "fstring" , BindNames : []string {"STRING" }, DataType : schema .String , Creatable : true , Updatable : true , Readable : true , Tag : `gorm:"column:fstring"` },
319
321
}
320
322
321
323
for _ , f := range fields {
322
324
checkSchemaField (t , alias , f , func (f * schema.Field ) {})
323
325
}
324
- }
326
+ }
0 commit comments