Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

returning column problem in update or insert sql #78

Closed
gzliudan opened this issue Apr 11, 2019 · 4 comments
Closed

returning column problem in update or insert sql #78

gzliudan opened this issue Apr 11, 2019 · 4 comments

Comments

@gzliudan
Copy link

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;

@leafo
Copy link
Owner

leafo commented Apr 11, 2019

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.

@gzliudan
Copy link
Author

Sorry to trouble you, I got the reason, there is a mistake in my codes.

@gzliudan
Copy link
Author

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.

@gzliudan gzliudan reopened this Apr 12, 2019
@leafo
Copy link
Owner

leafo commented Oct 15, 2021

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.

@leafo leafo closed this as completed Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants