File tree Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Expand file tree Collapse file tree 1 file changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ import (
18
18
"gorm.io/gorm/logger"
19
19
"gorm.io/gorm/migrator"
20
20
"gorm.io/gorm/schema"
21
- "gorm.io/gorm/utils"
22
21
)
23
22
24
23
type Config struct {
@@ -349,23 +348,20 @@ func (d Dialector) DataTypeOf(field *schema.Field) string {
349
348
delete (field .TagSettings , "RESTRICT" )
350
349
351
350
var sqlType string
352
-
353
351
switch field .DataType {
354
352
case schema .Bool :
355
353
sqlType = "NUMBER(1)"
356
- case schema .Int , schema .Uint , schema . Float :
354
+ case schema .Int , schema .Uint :
357
355
sqlType = "INTEGER"
358
-
359
- switch {
360
- case field .DataType == schema .Float :
361
- sqlType = "FLOAT"
362
- case field .Size > 0 && field .Size <= 8 :
356
+ if field .Size > 0 && field .Size <= 8 {
363
357
sqlType = "SMALLINT"
364
358
}
365
359
366
- if val , ok := field .TagSettings [ "AUTOINCREMENT" ]; ok && utils . CheckTruth ( val ) {
360
+ if field .AutoIncrement {
367
361
sqlType += " GENERATED BY DEFAULT AS IDENTITY"
368
362
}
363
+ case schema .Float :
364
+ sqlType = "FLOAT"
369
365
case schema .String , "VARCHAR2" :
370
366
size := field .Size
371
367
defaultSize := d .DefaultStringSize
@@ -387,10 +383,8 @@ func (d Dialector) DataTypeOf(field *schema.Field) string {
387
383
} else {
388
384
sqlType = "CLOB"
389
385
}
390
-
391
386
case schema .Time :
392
387
sqlType = "TIMESTAMP WITH TIME ZONE"
393
-
394
388
case schema .Bytes :
395
389
sqlType = "BLOB"
396
390
default :
@@ -403,7 +397,6 @@ func (d Dialector) DataTypeOf(field *schema.Field) string {
403
397
if sqlType == "" {
404
398
panic (fmt .Sprintf ("invalid sql type %s (%s) for oracle" , field .FieldType .Name (), field .FieldType .String ()))
405
399
}
406
-
407
400
}
408
401
409
402
return sqlType
You can’t perform that action at this time.
0 commit comments