Skip to content

Problem doing Upsert in version 0.5.4 #59

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

Closed
jribeiro opened this issue Oct 27, 2011 · 3 comments
Closed

Problem doing Upsert in version 0.5.4 #59

jribeiro opened this issue Oct 27, 2011 · 3 comments

Comments

@jribeiro
Copy link

Hi there! Congrats on the excelent job!

I'm trying to do an upsert using node-postgres. The logic I was trying to implement was if an update returned error it should do the insert.

Both updates and inserts work but the code always executes both because the update statement returns the same values for success and error.

Have anyone tried this? Can anyone give a help please?

You can find full details (code + debug) here:
http://stackoverflow.com/questions/7910174/upsert-in-postgres-using-node-js

Thanks and congrats

@brianc
Copy link
Owner

brianc commented Oct 27, 2011

It's possible to retrieve number of rows affected by an insert and update. It's not fully implemented in the native bindings, but does work in the pure javascript version. I'll work on this within the next week or two. In the mean time use pure javascript version and have a look here:

https://github.com/brianc/node-postgres/blob/master/test/integration/client/result-metadata-tests.js

@jribeiro
Copy link
Author

Thanks!!

I'll keep an eye out for the new release! ;)

@brianc
Copy link
Owner

brianc commented May 31, 2012

This should work now. Finally got around to some bug squashing.

@brianc brianc closed this as completed May 31, 2012
brianc added a commit that referenced this issue Dec 18, 2019
brianc added a commit that referenced this issue Dec 20, 2019
* Upgrade dependencies

- There was a security vuln with mocha, so upgraded mocha.
- Upgraded versions of node we're going to check in travis
- Switched to yarn from npm
- Removed --no-exit as that's standard mocha behavior now

* Enable postgres on newer version of travis
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