升级以后insert定义其它字段为主键不生效? #2410
Labels
No Label
backport/done
backport/v1
blocked
db
oracle
db
sqlserver
duplicate
feature
cache
frontport/done
frontport/main
invalid
kind
breaking
kind
bug
kind
build
kind
dependencies
kind
docs
kind
driver
kind
enhancement
kind
feature
kind
performance
kind
proposal
kind
question
kind
refactor
kind
testing
need
feedback
need
test
proposal:accepted
RaspBerry Pi
regression
skip-changelog
upstream
wip
wontfix
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#2410
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
type Data struct {
PkId int64
json:"pkId" xorm:"pk autoincr"
Id int64
json:"id"
Name string
json:"name"
}
row := *row.Data {
Id:230033782619625,
Name: "LiWei"
}
入库前打印值:
fmt.Prinln(row.PkId, row.Id, row.Name) //输出 0, 230033782619625, LiWei
line, err := engine.Insert(row)
执行成功以后打印值:
fmt.Prinln(row.PkId, row.Id, row.Name) //输出 0, 1, LiWei
升级前正确的值输出为:
fmt.Prinln(row.PkId, row.Id, row.Name) //输出 1, 230033782619625, LiWei
问题:它入库成功后的自增pkId值错误地赋值给了Id, 主键PkId却没有值。
看了源以后,正确输出的结构体加上xorm:
type Data struct {
PkId int64
json:"pkId" xorm:"pk autoincr"
Id int64
json:"id" xorm:"id"
Name string
json:"name"
}
处理:每个结构体字段都加上xorm,以前是不需要的。
It's impossible. The CI has been passed for every commit. Please check your code.