This commit is contained in:
CyJaySong 2023-07-21 11:12:31 +08:00
parent 269811a497
commit 21b54e5d61
2 changed files with 7 additions and 4 deletions

View File

@ -320,8 +320,11 @@ func (db *mssql) SQLType(c *schemas.Column) string {
res += "(MAX)"
}
case schemas.TimeStamp, schemas.DateTime:
c.Length = 7
return "DATETIME2"
if c.Length > 3 {
res = "DATETIME2"
} else {
return schemas.DateTime
}
case schemas.TimeStampz:
res = "DATETIMEOFFSET"
c.Length = 7

View File

@ -1209,7 +1209,7 @@ func TestInsertNotDeleted(t *testing.T) {
type TestInsertNotDeletedStructNotRight struct {
ID uint64 `xorm:"'ID' pk autoincr"`
DeletedAt time.Time `xorm:"'DELETED_AT' deleted notnull"`
DeletedAt time.Time `xorm:"'DELETED_AT' DATETIME(6) deleted notnull"`
}
// notnull tag will be ignored
err := testEngine.Sync(new(TestInsertNotDeletedStructNotRight))
@ -1217,7 +1217,7 @@ func TestInsertNotDeleted(t *testing.T) {
type TestInsertNotDeletedStruct struct {
ID uint64 `xorm:"'ID' pk autoincr"`
DeletedAt time.Time `xorm:"'DELETED_AT' deleted"`
DeletedAt time.Time `xorm:"'DELETED_AT' DATETIME(6) deleted"`
}
assert.NoError(t, testEngine.Sync(new(TestInsertNotDeletedStruct)))