Golang Gorm db.raw with CloudSQL for Update SQL 查询不起作用?
Golang Gorm db.raw with CloudSQL for Update SQL query not working?
我有这个 SQL 查询,它单独工作正常,受影响的 2 行绝对没问题
update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > 0
但是当我在 golang 中尝试 gorm 的执行变体语句时
err := h.db.Raw("update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > ? ", 0).Error
或
numRecsToProcess := h.db.Raw("update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > ? ", 0).RowsAffected
None 这些更新语句正在影响基础数据库中的任何更改。 Gorm 使用功能中是否缺少某些内容?
尝试 h.db.Exec
而不是 h.db.Raw
。
我有这个 SQL 查询,它单独工作正常,受影响的 2 行绝对没问题
update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > 0
但是当我在 golang 中尝试 gorm 的执行变体语句时
err := h.db.Raw("update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > ? ", 0).Error
或
numRecsToProcess := h.db.Raw("update chores set life_status ='Processing' where life_status = 'Active' and chore_type ='Shared' and money_assigned > ? ", 0).RowsAffected
None 这些更新语句正在影响基础数据库中的任何更改。 Gorm 使用功能中是否缺少某些内容?
尝试 h.db.Exec
而不是 h.db.Raw
。