How to write expressions in update fields?
The query I want to write is akin to:
UPDATE "users" SET "login_count" = "login_count" + 1 WHERE "id" = 1;
I cannot for the life of me find a way to use an expression in the changes object. I'm sure I can just do this with db.query
, but it feels like pretty basic functionality to not be part of the query builder, and I feel silly for not being able to figure out how to do it.
If this isn't something that can be done yet, I feel a little less silly, but I'd be happy to look into creating an MR to add it. Yes, this functionality introduces the possibility of SQL injection if used carelessly, but Massive already supports the expr
field in query objects with appropriate warnings, and I figure something similar here could be sufficient.