-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
node-postgres blocks with faulty SQL #1082
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
Conversation
Your error is not related to this library, it is a pure server-side error, which states clearly that your insert query violates the unique |
Having the same issue so I monkey patched client.query method. const query = client.query;
client.query = (sql, params) => new Promise((resolve, reject) => {
query(sql, params, (error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
}); |
Or you can use pg-promise to avoid monkey-patching like this 😉 |
Looks like there might be an issue with query not rejecting properly on On Tuesday, July 19, 2016, Vitaly Tomilov notifications@github.com wrote:
|
select true
-- works as expected select tru_______e -- little typo here
-- no errors thrown (as expected) Using |
Just to be clear, you're using babel to transpile your code, correct? |
With |
yeah you're spot on, just wrote a failing test now - fix incoming...I think I know what's going on. |
The promise adapter I had implemented wasn't spec compliant: it didn't accept both `onSuccess` and `onFailure` in the call to `query#then`. This subtly broke yield & async/await because they both rely on `onError` being passed into `Promise#then`. The pool was also not returning the promise after a client was acquired, which broke awaiting on `pool.connect` - this is also fixed now.
I'm using babel with async-to-bluebird-promises transformation module. Buğra Ekuklu Github, Bitbucket, Stack Overflow: @Chatatata SO Ready To Help Please information if this is considered spam. 19 Tem 2016 tarihinde 17:19 saatinde, Brian C notifications@github.com şunları yazdı:
|
@brikou - I've pushed a fix up here; once the tests pass I'll merge & push out a new patch version - thanks for reporting this and the information you supplied in helping me identify the bug! 💃 |
@brianc Thank you, can't wait for the release :) |
var co = require('co') | ||
|
||
var tid = setTimeout(function() { | ||
throw new Error('Tests did not complete in tme') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah thanks - i'll fix on master when I push the new version.
Published version with fix: |
I'm using ES6 with async/await and node-postgres with connection pooling.
Let there is a table with a column which has UNIQUE constraint and a primary key column, the following code block blocks on
client.query
:However, I'm expecting to see this in somewhere:
Am I doing something wrong?