go-gorm / sqlserver

GORM sqlserver driver
MIT License
56 stars 39 forks source link

Add sqlserver config options: DefaultStringSize. #33

Closed poneding closed 3 years ago

poneding commented 3 years ago

Add sqlserver config options: DefaultStringSize.

for example:

sqlserverConf := sqlserver.Config{
    DSN:               dns,
    DefaultStringSize: 50,
}
whitetiger21022014 commented 3 years ago

@med1tator I run cmd: go get -u gorm.io/driver/sqlserver and have the problem as below

../../../../../gorm.io/driver/sqlserver/sqlserver.go:176:35: cannot use 0 (type untyped int) as type string ../../../../../gorm.io/driver/sqlserver/sqlserver.go:177:10: cannot use dialector.Config.DefaultStringSize (type string) as type int in assignment

DefaultStringSize in struct is string, but assign as integer type Config struct { DriverName string DSN string DefaultStringSize string Conn gorm.ConnPool }

..... if dialector.DefaultStringSize > 0 { size = dialector.DefaultStringSize } else { size = 256 }

poneding commented 3 years ago

@med1tator I run cmd: go get -u gorm.io/driver/sqlserver and have the problem as below

../../../../../gorm.io/driver/sqlserver/sqlserver.go:176:35: cannot use 0 (type untyped int) as type string ../../../../../gorm.io/driver/sqlserver/sqlserver.go:177:10: cannot use dialector.Config.DefaultStringSize (type string) as type int in assignment

DefaultStringSize in struct is string, but assign as integer type Config struct { DriverName string DSN string DefaultStringSize string Conn gorm.ConnPool }

..... if dialector.DefaultStringSize > 0 { size = dialector.DefaultStringSize } else { size = 256 }

my bad, sorry. i have created an new pull request to fix it.