[BUG]runtime error: hash of unhashable type Model.User #935
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
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: xorm/xorm#935
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?
When I try to insert some data ,it panic from xorm.But I have use Insert normally without any other bug
//I don
t know why insert has bug ,//I have try to report this bug
//be careful with session.Insert()
, err = session.InsertOne(&userInfo) //this is ok
//, err = session.Insert(userInfo) //bug here
if err != nil {
session.Rollback()
log.Error(err)
return -1, err
}
`
and the panic log:runtime error: hash of unhashable type Model.User
/usr/local/go/src/runtime/panic.go:491 (0x42cbb2)
/usr/local/go/src/runtime/alg.go:166 (0x40245f)
/usr/local/go/src/runtime/hashmap.go:416 (0x409f02)
/home/curi/go/src/github.com/go-xorm/xorm/session_insert.go:378 (0x9c462b)
/home/curi/go/src/github.com/go-xorm/xorm/session_insert.go:522 (0x9a3e2d)
/home/curi/go/src/github.com/go-xorm/xorm/session_insert.go:48 (0x99ee01)
/home/curi/hiro/HKLover2/Module/User/Service.go:111 (0xa6e6b3)
/home/curi/hiro/HKLover2/Module/User/Service.go:267 (0xa6fffe)
/home/curi/hiro/HKLover2/Module/User/Action.go:101 (0xa7c3bf)
/home/curi/hiro/HKLover2/Server/SingleServer.go:123 (0xa25817)
/home/curi/hiro/HKLover2/Module/User/Action.go:99 (0xa6a4c0)
/home/curi/go/src/github.com/gin-gonic/gin/context.go:107 (0x8deee2)
/home/curi/go/src/github.com/gin-contrib/sessions/sessions.go:67 (0xa1243f)
/home/curi/go/src/github.com/gin-gonic/gin/context.go:107 (0x8deee2)
/home/curi/hiro/HKLover2/Server/GinLogger.go:17 (0xa24059)
/home/curi/go/src/github.com/gin-gonic/gin/context.go:107 (0x8deee2)
/home/curi/go/src/github.com/gin-gonic/gin/recovery.go:46 (0x8f1179)
/home/curi/go/src/github.com/gin-gonic/gin/context.go:107 (0x8deee2)
/home/curi/go/src/github.com/gin-gonic/gin/logger.go:83 (0x8f04ab)
/home/curi/go/src/github.com/gin-gonic/gin/context.go:107 (0x8deee2)
/home/curi/go/src/github.com/gin-gonic/gin/gin.go:359 (0x8e7ff5)
/home/curi/go/src/github.com/gin-gonic/gin/gin.go:326 (0x8e778a)
/usr/local/go/src/net/http/server.go:2619 (0x676c93)
/usr/local/go/src/net/http/server.go:1801 (0x672ddc)
/usr/local/go/src/runtime/asm_amd64.s:2337 (0x45d8e0)
and my struct is like:
type User struct { util.DefaultInfo
xorm:"extends" binding:"-"util.CommonUserInfo
xorm:"extends"`}
type DefaultInfo struct {
ID int
json:"id" form:"id" xorm:"'id' pk autoincr unique"
CreateAt time.Time
json:"createAt" xorm:"'createAt' created"
UpdateAt time.Time
json:"updateAt" xorm:"'updateAt' updated"
DeleteAt time.Time
json:"deleteAt" xorm:"'deleteAt' deleted"
}
type CommonUserInfo struct {
Location string
json:"location" form:"location" xorm:"'location'"
Name string
json:"name" form:"name" xorm:"'name'"
UID int
json:"uid" form:"uid" xorm:"'uid' unique" binding:"required"
Phone string
json:"phone" form:"phone" xorm:"'phone'"
Industry string
json:"industry" form:"industry" xorm:"'industry'"
Intro string
json:"intro" form:"intro" xorm:"'intro'"
Avatar string
json:"avatar" form:"avatar" xorm:"'avatar'"
Status int
json:"status" form:"status" xorm:"'status'"
//!!Watch int
json:"watch" form:"watch" xorm:"'watch' default(0)"
//}
`