tests: check max length is available for TEXT cols

This commit is contained in:
Pierre-Louis Bonicoli 2022-04-13 04:00:16 +02:00
parent ea9bba0d14
commit d283a4ddae
No known key found for this signature in database
GPG Key ID: 06914C4A5EDAA6DD
1 changed files with 33 additions and 0 deletions

View File

@ -288,3 +288,36 @@ func TestGetColumnsComment(t *testing.T) {
assert.Equal(t, comment, hasComment) assert.Equal(t, comment, hasComment)
assert.Zero(t, noComment) assert.Zero(t, noComment)
} }
func TestGetColumnsLength(t *testing.T) {
var max_length int
switch testEngine.Dialect().URI().DBType {
case
schemas.POSTGRES:
max_length = 0
case
schemas.MYSQL:
max_length = 65535
default:
t.Skip()
return
}
type TestLengthStringStruct struct {
Content string `xorm:"TEXT NOT NULL"`
}
assertSync(t, new(TestLengthStringStruct))
tables, err := testEngine.DBMetas()
assert.NoError(t, err)
tableLengthStringName := testEngine.GetColumnMapper().Obj2Table("TestLengthStringStruct")
for _, table := range tables {
if table.Name == tableLengthStringName {
col := table.GetColumn("content")
assert.Equal(t, col.Length, max_length)
assert.Zero(t, col.Length2)
break
}
}
}