Skip to content

Update Pool.js to allow calling Pool.prototype.query with no callback #585

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
wants to merge 2 commits into from
Closed

Conversation

wizardfrag
Copy link

Add a check in Pool.prototype.query to see if the callback is a function, to allow calling it with no callback specified (i.e. for UPDATE/INSERT type queries)

Added a check in Pool.prototype.query to see if the callback is a function, to allow calling it with no callback specified (i.e. for UPDATE/INSERT type queries)
Addendum to previous commit to check if callback is a function when we receive an error from getConnection()
@felixge
Copy link
Collaborator

felixge commented Sep 9, 2013

Wouldn't it be simpler to do: cb = cb || function() {} on top of the function?

@dougwilson
Copy link
Member

Or at the very least cb && cb(null) type construct, as the typeof may mask mistakes like accidentally passing a string in the callback argument.

@tolgaek
Copy link
Contributor

tolgaek commented Sep 18, 2013

Yeah I think that's more of a standard that I see more and it can be used with the return statement that he has in his patch return cb && cb();

@tellnes
Copy link
Collaborator

tellnes commented Sep 20, 2013

Do we really want to silently swallow any errors in this case?

@dresende
Copy link
Collaborator

That's up to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants