Closed gzliudan closed 2 years ago
Can you share the code you're using to do this? returning
definitely works with pgmoon, I use it heavily in all of my projects.
Sorry to trouble you, I got the reason, there is a mistake in my codes.
There's another problem, when I delete a non exist record in database: if my sql is: delete from t1 where id=0, then the pgmoon returns {"affected_rows":0} if my sql is: delete from t1 where id=0 returning id, then the pgmoon returns {} I expect pgmoon should returns affected_rows at any time.
I'm kinda undecided on the behavior but I think it's safer to leave it as is. returning
converts the query into something that has a result set, so if you want to could the number of affected rows you will have to could the number of results.
When I run INSERT or UPDATE sql with returning some columns, the result only contains affected_rows, I cannot find returned columns in my sql. such as: update t1 set name='b' where id=1 returning id,name;