update使用map[string]interface{},id主键不生效,造成全表更新 #1700
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#1700
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?
使用map[string]interface{}作为更新条件时,ID主键不生效。
affected, err := engine.Table("quick_reply").ID(11).Update(map[string]interface{}{"reply": "hello reply2"}
SQL:
UPDATE
quick_replySET
reply= ? [hello reply2]
源码中:
if statement.idParam == nil || statement.RefTable == nil
是有问题的,这边是不是这个判断条件可以考虑进去,如果指定了表名,实际主键ID是可以存在的。But how do we know which column is the primary key? I think the bug is it should return error but not continue to update.
it's a solution to prevent a disaster, hope next version,it could be fixed.Thanks.