panic: index out of range when try to .cols("xxx", "xxx", "xxx").find(&map[int64]*xxx) #1396

Closed
opened 2019-08-19 06:58:00 +00:00 by SilverChard · 0 comments
SilverChard commented 2019-08-19 06:58:00 +00:00 (Migrated from github.com)

b78ac8ce0a/session_find.go (L316)

in session_find.go:259 ~ 271

containerValueSetFunc = func(newValue *reflect.Value, pk core.PK) error {
	keyValue := reflect.New(keyType)
	err := convertPKToValue(table, keyValue.Interface(), pk)
	if err != nil {
		return err
	}
	if isPointer {
		containerValue.SetMapIndex(keyValue.Elem(), newValue.Elem().Addr())
	} else {
		containerValue.SetMapIndex(keyValue.Elem(), newValue.Elem())
	}
	return nil
}	

session_find.go:306 containerValueSetFunc(&newValue, nil) . pk will be nil.
but in convertPKToValue. return convertAssign(dst, pk[0])
so ... nil[0] ....

https://github.com/go-xorm/xorm/blob/b78ac8ce0a8c507fb5045363ca9b0c4dcebb5723/session_find.go#L316 in session_find.go:259 ~ 271 ```golang containerValueSetFunc = func(newValue *reflect.Value, pk core.PK) error { keyValue := reflect.New(keyType) err := convertPKToValue(table, keyValue.Interface(), pk) if err != nil { return err } if isPointer { containerValue.SetMapIndex(keyValue.Elem(), newValue.Elem().Addr()) } else { containerValue.SetMapIndex(keyValue.Elem(), newValue.Elem()) } return nil } ``` session_find.go:306 `containerValueSetFunc(&newValue, nil)` . pk will be nil. but in convertPKToValue. `return convertAssign(dst, pk[0])` so ... nil[0] ....
lunny added this to the 1.0.0 milestone 2020-03-04 02:17:44 +00:00
lunny closed this issue 2020-03-06 08:55:19 +00:00
Sign in to join this conversation.
No Milestone
No Assignees
1 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#1396
No description provided.