We're hitting this error during a database migration that tries to perform a runSql:
[ERROR] TypeError: self.values.map is not a function
at [object Object].Query.prepare (/home/ubuntu/RedoxEngine/node_modules/pg/lib/query.js:150:31)
at [object Object].Query.submit (/home/ubuntu/RedoxEngine/node_modules/pg/lib/query.js:113:10)
at [object Object].Client._pulseQueryQueue (/home/ubuntu/RedoxEngine/node_modules/pg/lib/client.js:298:24)
at [object Object].Client.query (/home/ubuntu/RedoxEngine/node_modules/pg/lib/client.js:326:8)
at Class.Base.extend.runSql (/home/ubuntu/RedoxEngine/node_modules/db-migrate/lib/driver/pg.js:339:31)
at /home/ubuntu/RedoxEngine/migrations/20160328204315-add-vhost-to-Source.js:18:10
at /home/ubuntu/RedoxEngine/node_modules/async/lib/async.js:689:13
at iterate (/home/ubuntu/RedoxEngine/node_modules/async/lib/async.js:265:13)
at /home/ubuntu/RedoxEngine/node_modules/async/lib/async.js:277:29
at /home/ubuntu/RedoxEngine/node_modules/async/lib/async.js:44:16
at [object Object].<anonymous> (/home/ubuntu/RedoxEngine/node_modules/async/lib/async.js:694:17)
at [object Object].callback (/home/ubuntu/RedoxEngine/node_modules/async/lib/async.js:173:37)
at [object Object].Query.handleReadyForQuery (/home/ubuntu/RedoxEngine/node_modules/pg/lib/query.js:89:10)
at [object Object].<anonymous> (/home/ubuntu/RedoxEngine/node_modules/pg/lib/client.js:163:19)
at emitOne (events.js:82:20)
at [object Object].emit (events.js:169:7)
at Socket.<anonymous> (/home/ubuntu/RedoxEngine/node_modules/pg/lib/connection.js:109:12)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at readableAddChunk (_stream_readable.js:153:18)
at Socket.Readable.push (_stream_readable.js:111:10)
at TCP.onread (net.js:531:20)
We must be returning some non-array object when running the query, so .map fails.
Ah, it breaks this:
var a = 1;
var query = 'update row set val = ?';
db.runSql(query, a, next);
In this case, self.values = 1.
You need to pass an array as the parameter representing the parameters to your query, even if your query only has 1 parameter.
Also ? is not valid postgresql compliant query text - you need to use valid parameters like $1 $2 etc
Had the same problem. Just writing as it might help others. Turned out that I was using single quotes inside my query and and using single quotes for the query itself with pg. Changing to double quotes for the query solved the issue.
Most helpful comment
You need to pass an array as the parameter representing the parameters to your query, even if your query only has 1 parameter.