Open im4LF opened 8 years ago
Anybody?
I am experiencing this as well, however I think the root cause is within the pg module, specifically this issue: https://github.com/brianc/node-postgres/issues/220.
The thread suggests monkey-patching https://github.com/brianc/node-postgres/blob/715e5009dde23c0fb5b127f9b536aa6ed5245fc2/lib/utils.js#L30, I'm not sure if that's still the only solution.
My solution is to try guess the type by first value:
Postgres.prototype.visitArrayCall = function(arrayCall) {
var type = 'text';
if (arrayCall.nodes.length) {
var test = arrayCall.nodes[0].value();
if ('number' === typeof test)
type = !!(test % 1) ? 'double precision' : 'integer';
}
var txt = 'ARRAY[' + arrayCall.nodes.map(this.visit.bind(this)).join(', ') + ']::' + type + '[]';
return [txt];
};
Simple object with integer[] type of one field
Query generates:
But when send query to postgres by
Its generate type cast error: