Skip to content

Conversation

swekaj
Copy link
Contributor

@swekaj swekaj commented Mar 8, 2014

...n an options object is passed as the first object and no callback is passed, options.values is unset.

…hen an options object is passed as the first object and no callback is passed, options.values is unset.
@sidorares
Copy link
Member

can you add more comments here (and probably unit / regression test )? It's not immediately obvious what use case your change solves

…(connection.query({sql: 'SELECT ?', values: [ 'value' ]}))
@swekaj
Copy link
Contributor Author

swekaj commented Mar 8, 2014

Sorry about that. The use-case is for when one passes an options object to connection.query() with the intent to stream the results (i.e. no callback is passed). Previously options.values would be overridden to an undefined variable (the values argument) if no callback was set.

example (as demonstrated in the test file):

var query = connection.query({
  sql: 'SELECT ?',
  values: [ 'value' ]
});
query.on('err', ...)
query.on('result', ...)

@sidorares
Copy link
Member

thanks, makes sense now

sidorares added a commit that referenced this pull request Mar 8, 2014
Only set options.values = values when values is defined.  Otherwise, whe...
@sidorares sidorares merged commit 625d7ca into mysqljs:master Mar 8, 2014
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.

2 participants