client.query(sqlString, params[], function) alters the given params[]
When supplying a parameters array to client.query the given array is modified (in my case it originally was an array of numbers and got transformed to an array of strings). This is not correct behaviour, I see the problem in the source code (query.js, line 143):
self.values[i] = utils.prepareValue(self.values[i]);
If transformation is needed it should be done on a clone of the passed array so that it doesn't break any logic in case the original array is reused somewhere else after the query.
I think a quick fix would be to change (query.js, line 14) from:
this.values = config.values;
to
this.values = config.values.slice();
yeah that totally sucks! Sorry about that. Do you wanna submit a PR for that change w/ a little test? If not, I can bang one together.
Hi Brian, maybe it's faster if you do the change directly, I've never done a Pull request... but I promise I will start learning and contribute :)
@ngervasi Many people are on the fence like yourself, so was I, for a while, till I tried and then was laughing how easy it really was ;) And if you don't like GIT, use Source Tree - it is a huge help: http://www.sourcetreeapp.com/
You're right Vitaly, it's time to actively contribute to the project, I sent my pull requests but I didn't create the tests, I'm unsure about how to do that properly. Can someone give me a hint about it? I'm not familiar with node tests... btw: thanks Brian for this impressive project!
All tests are in \test sub-folder. Typically, you either amend an existing test or add a new one. Given the nature of the issue, I'd say you have to create a new test. The syntax is very easy, and for details just look at the test library ;)
@brianc , @ngervasi Any progress here? I'm stuck with some tests here on parameters, they are altered, unexpectedly.
This is kind of a big issue.
Unfortunately not, I'm very busy and I wasn't able to learn how to setup the test, if you have time have a look at my patch and feel free to submit it on your own. Sorry bout that but it's a tough time.