refactor/mssql: change default sizing of binary columns to max
This commit is contained in:
parent
c349d36e95
commit
9d8ae4ec3c
|
@ -232,10 +232,10 @@ func (db *mssql) SqlType(c *core.Column) string {
|
||||||
c.IsPrimaryKey = true
|
c.IsPrimaryKey = true
|
||||||
c.Nullable = false
|
c.Nullable = false
|
||||||
res = core.BigInt
|
res = core.BigInt
|
||||||
case core.Bytea, core.Blob, core.Binary, core.TinyBlob, core.MediumBlob, core.LongBlob:
|
case core.VarBinary, core.Bytea, core.Blob, core.Binary, core.TinyBlob, core.MediumBlob, core.LongBlob:
|
||||||
res = core.VarBinary
|
res = core.VarBinary
|
||||||
if c.Length == 0 {
|
if c.Length == 0 {
|
||||||
c.Length = 50
|
res += "(MAX)"
|
||||||
}
|
}
|
||||||
case core.TimeStamp:
|
case core.TimeStamp:
|
||||||
res = core.DateTime
|
res = core.DateTime
|
||||||
|
|
|
@ -9,8 +9,8 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"xorm.io/core"
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
"xorm.io/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestArrayField(t *testing.T) {
|
func TestArrayField(t *testing.T) {
|
||||||
|
@ -99,6 +99,29 @@ func TestGetBytes(t *testing.T) {
|
||||||
assert.Equal(t, "test", string(b.Data))
|
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
|
type ConvString string
|
||||||
|
|
||||||
func (s *ConvString) FromDB(data []byte) error {
|
func (s *ConvString) FromDB(data []byte) error {
|
||||||
|
|
Loading…
Reference in New Issue