使用sync2时,无法新增表中的字段 #1892

Closed
opened 2021-04-11 15:15:24 +00:00 by campusstella · 4 comments

只能全表删除了以后再新建。

只能全表删除了以后再新建。
Author

检查了一下,发现是增加 not null以后就不会自动同步,这个是不是feature啊?如果要加not null,如何设置缺省值呢?

检查了一下,发现是增加 not null以后就不会自动同步,这个是不是feature啊?如果要加not null,如何设置缺省值呢?
Owner

Could you paste your example codes?

Could you paste your example codes?
lunny added the
need
feedback
label 2021-04-11 15:37:39 +00:00
Author
type AbpiProject struct {
	Id             int       `xorm:"id pk not null autoincr"`
	AaedenProject  string    `xorm:"TEXT not null unique(ps)"`
	AaedtProject   string    `xorm:"TEXT not null"`
	AbpifsProject  string    `xorm:"TEXT not null unique(ps)"`
	AbpifstProject time.Time `xorm:"DATETIME created unique(ps)"`
	AbpifetProject time.Time `xorm:"DATETIME"`
	AbpifkProject  string    `xorm:"TEXT"`
	AbpiiProject   string    `xorm:"TEXT"`
	DeletedMark    time.Time `xorm:"deleted"`
}


tableErr := autoSession.Sync2(new(AbpiProject))

例如,我有一个表结构AbpiProject,此时在中间新增了一个AaedtProject字段,然后使用Sync2同步到数据库,但发现无法同步……如果在数据库中直接新建,则在ORM中无法读取。

```go type AbpiProject struct { Id int `xorm:"id pk not null autoincr"` AaedenProject string `xorm:"TEXT not null unique(ps)"` AaedtProject string `xorm:"TEXT not null"` AbpifsProject string `xorm:"TEXT not null unique(ps)"` AbpifstProject time.Time `xorm:"DATETIME created unique(ps)"` AbpifetProject time.Time `xorm:"DATETIME"` AbpifkProject string `xorm:"TEXT"` AbpiiProject string `xorm:"TEXT"` DeletedMark time.Time `xorm:"deleted"` } tableErr := autoSession.Sync2(new(AbpiProject)) ``` 例如,我有一个表结构AbpiProject,此时在中间新增了一个AaedtProject字段,然后使用Sync2同步到数据库,但发现无法同步……如果在数据库中直接新建,则在ORM中无法读取。
Owner

Cannot reproduce this.

Cannot reproduce this.
lunny closed this issue 2021-07-11 13:34:39 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: xorm/xorm#1892
No description provided.