-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
insert or update native javascript array doesn't work #220
Comments
Have you seen the prepareValue function? https://github.com/brianc/node-postgres/blob/master/lib/utils.js#L98 Somehow it should be possible to overwrite this function and get the desired functionality. |
yeah, that's there for exactly to let you override or extend the type coercion. One thing to note in your example, you'll want to pass an array as the first item of the params array: client.query('INSERT INTO awesome_array_table(val) VALUES($1)', [ [1,2,3] ], ...) |
@brianc but how do I overwrite the prepareValue function if I don't want to do something like: require('./node_modules/pg/lib/utils') Where do we export the prepareValue function other than the utils module? Or what is the recommended way to overwrite the function? |
Yeah, it's not currently exported on the main object returned from |
thanks @booo for hinting at arrays are a base data type in postgres, are there any reasons not to make a pull request and add a conversion mechanism for arrays? (i corrected my example code) |
There's no reason not to. It's rather difficult to encode all the On Tue, Nov 20, 2012 at 2:10 AM, Mark Engel notifications@github.comwrote:
|
back from holiday :) it would be awesome if node-pg could translate all different types of arrays, for sure. |
absolutely. On Wed, Jan 9, 2013 at 6:05 AM, Mark Engel notifications@github.com wrote:
|
Closing. Awaiting pull request(s) for array types. |
Hey folks,
It is currently not possible to pass an javascript array to pg.
If I have a table
i can't use this
I receive: 'error: array value must start with "{" or dimension information]
but have to do this
It would be great if pg could auto convert javascript arrays to pg arrays.
What do you guys think?
The text was updated successfully, but these errors were encountered: