Update 更新问题, 一不小心就全表更新了 #1708

Closed
opened 2020-06-12 07:43:17 +00:00 by pixelvm · 1 comment
engine.Table("book_textbook_pictures").ID(id).Update(map[string]bool{"deleted": true})   //   [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ?  [true]
	engine.Table("book_textbook_pictures").ID(id).Cols("deleted").Update(map[string]bool{"deleted": true}) //  [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ?  [true]
engine.Table("book_textbook_pictures").Where("id = ?", id).Cols("deleted").Update(map[string]bool{"deleted": true})  // [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ? WHERE (id = ?) [true 484]
	updata := &TextbookPicture{Deleted: true}
engine.ID(id).Update(updata) // 出错 没有任何 SQL 输出
engine.Table(updata).ID(id).Update(updata) // 出错 没有任何 SQL 输出
engine.Table(updata).ID(id).Cols("deleted").Update(updata) // 出错 没有任何 SQL 输出
engine.Table(updata).Where("id = ?", id).Cols("deleted").Update(updata) // 出错 没有任何 SQL 输出
engine.Table(new(TextbookPicture)).ID(id).Update(map[string]bool{"deleted": true}) // [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ? WHERE `id`=? AND deleted=? [true 481 0]
``` 尝试了
```go engine.Table("book_textbook_pictures").ID(id).Update(map[string]bool{"deleted": true}) // [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ? [true] engine.Table("book_textbook_pictures").ID(id).Cols("deleted").Update(map[string]bool{"deleted": true}) // [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ? [true] engine.Table("book_textbook_pictures").Where("id = ?", id).Cols("deleted").Update(map[string]bool{"deleted": true}) // [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ? WHERE (id = ?) [true 484] updata := &TextbookPicture{Deleted: true} engine.ID(id).Update(updata) // 出错 没有任何 SQL 输出 engine.Table(updata).ID(id).Update(updata) // 出错 没有任何 SQL 输出 engine.Table(updata).ID(id).Cols("deleted").Update(updata) // 出错 没有任何 SQL 输出 engine.Table(updata).Where("id = ?", id).Cols("deleted").Update(updata) // 出错 没有任何 SQL 输出 engine.Table(new(TextbookPicture)).ID(id).Update(map[string]bool{"deleted": true}) // [SQL] UPDATE `book_textbook_pictures` SET `deleted` = ? WHERE `id`=? AND deleted=? [true 481 0] ``` 尝试了
lunny added the
duplicate
label 2020-06-12 13:51:58 +00:00
Owner

duplicated with #1700

duplicated with #1700
lunny closed this issue 2020-06-12 13:52:11 +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#1708
No description provided.