refactor/mssql: change default sizing of binary columns to max
This commit is contained in:
parent
7fd6356a85
commit
d8394dfdc5
|
@ -299,10 +299,10 @@ func (db *mssql) SQLType(c *schemas.Column) string {
|
|||
c.IsPrimaryKey = true
|
||||
c.Nullable = false
|
||||
res = schemas.BigInt
|
||||
case schemas.Bytea, schemas.Blob, schemas.Binary, schemas.TinyBlob, schemas.MediumBlob, schemas.LongBlob:
|
||||
case schemas.VarBinary, schemas.Bytea, schemas.Blob, schemas.Binary, schemas.TinyBlob, schemas.MediumBlob, schemas.LongBlob:
|
||||
res = schemas.VarBinary
|
||||
if c.Length == 0 {
|
||||
c.Length = 50
|
||||
res += "(MAX)"
|
||||
}
|
||||
case schemas.TimeStamp:
|
||||
res = schemas.DateTime
|
||||
|
|
|
@ -106,6 +106,29 @@ func TestGetBytes(t *testing.T) {
|
|||
assert.Equal(t, "test", string(b.Data))
|
||||
}
|
||||
|
||||
func TestGetBytesMax(t *testing.T) {
|
||||
assert.NoError(t, PrepareEngine())
|
||||
|
||||
type Varbinary struct {
|
||||
Data []byte `xorm:"VARBINARY"`
|
||||
}
|
||||
|
||||
err := testEngine.Sync2(new(Varbinary))
|
||||
assert.NoError(t, err)
|
||||
|
||||
cnt, err := testEngine.Insert(&Varbinary{
|
||||
Data: []byte("test"),
|
||||
})
|
||||
assert.NoError(t, err)
|
||||
assert.EqualValues(t, 1, cnt)
|
||||
|
||||
var b Varbinary
|
||||
has, err := testEngine.Get(&b)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, has)
|
||||
assert.Equal(t, "test", string(b.Data))
|
||||
}
|
||||
|
||||
type ConvString string
|
||||
|
||||
func (s *ConvString) FromDB(data []byte) error {
|
||||
|
|
Loading…
Reference in New Issue