jmalloc / ax

A message-driven application toolkit for Go. [EXPERIMENTAL]
MIT License
9 stars 3 forks source link

Always check the number of rows affected after an UPDATE query. #100

Closed jmalloc closed 6 years ago

jmalloc commented 6 years ago
koden-km commented 6 years ago

What should happen if the number of affected rows is 0 or some other less than expected number? What should happen with errors when trying to get number of affected rows?

jmalloc commented 6 years ago

There's an example of how to do this in PR #101: https://github.com/jmalloc/ax/blob/b6deec3bcd151dfabc62cdea8ffabe18d7eb6431/src/axmysql/saga/crud.go#L208

jmalloc commented 6 years ago

I've checking for == 0 there, but it'd probably be better to check specifically for != 1, when it's expected to update exactly one row.

jmalloc commented 6 years ago

BTW, we could put this in a helper function in axmysql/internal, something like updateOneRow(ctx, q, ...)