Comparing version 3.2.3 to 3.2.4
@@ -357,3 +357,3 @@ const net = require('net') | ||
socket.on('data', data) | ||
keep_alive != null && socket.setKeepAlive(true, 1000 * keep_alive) | ||
keep_alive && socket.setKeepAlive(true, 1000 * keep_alive) | ||
const s = StartupMessage() | ||
@@ -735,3 +735,3 @@ write(s) | ||
options.parsers[typarray].array = true | ||
options.serializers[typarray] = (xs) => arraySerializer(xs, options.serializers[oid]) | ||
options.serializers[typarray] = (xs) => arraySerializer(xs, options.serializers[oid], options) | ||
} | ||
@@ -738,0 +738,0 @@ |
@@ -234,3 +234,3 @@ const { Query } = require('./query.js') | ||
const arraySerializer = module.exports.arraySerializer = function arraySerializer(xs, serializer) { | ||
const arraySerializer = module.exports.arraySerializer = function arraySerializer(xs, serializer, options) { | ||
if (Array.isArray(xs) === false) | ||
@@ -247,5 +247,13 @@ return xs | ||
return '{' + xs.map(x => | ||
'"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"' | ||
).join(',') + '}' | ||
return '{' + xs.map(x => { | ||
if (x === undefined) { | ||
x = options.transform.undefined | ||
if (x === undefined) | ||
throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed') | ||
} | ||
return x === null | ||
? 'null' | ||
: '"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"' | ||
}).join(',') + '}' | ||
} | ||
@@ -252,0 +260,0 @@ |
{ | ||
"name": "postgres", | ||
"version": "3.2.3", | ||
"version": "3.2.4", | ||
"description": "Fastest full featured PostgreSQL client for Node.js", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -901,3 +901,3 @@ <img align="left" width="440" height="180" alt="Fastest full PostgreSQL nodejs client" src="https://raw.githubusercontent.com/porsager/postgres/master/postgresjs.svg?sanitize=true"> | ||
You can add ergonomic support for custom types, or simply use `sql.typed(value, type)` inline, where type is the PostgreSQL `oid` for the type and the correctly serialized string. _(`oid` values for types can be found in the `pg_catalog.pg_types` table.)_ | ||
You can add ergonomic support for custom types, or simply use `sql.typed(value, type)` inline, where type is the PostgreSQL `oid` for the type and the correctly serialized string. _(`oid` values for types can be found in the `pg_catalog.pg_type` table.)_ | ||
@@ -904,0 +904,0 @@ Adding Query helpers is the cleanest approach which can be done like this: |
@@ -357,3 +357,3 @@ import net from 'net' | ||
socket.on('data', data) | ||
keep_alive != null && socket.setKeepAlive(true, 1000 * keep_alive) | ||
keep_alive && socket.setKeepAlive(true, 1000 * keep_alive) | ||
const s = StartupMessage() | ||
@@ -735,3 +735,3 @@ write(s) | ||
options.parsers[typarray].array = true | ||
options.serializers[typarray] = (xs) => arraySerializer(xs, options.serializers[oid]) | ||
options.serializers[typarray] = (xs) => arraySerializer(xs, options.serializers[oid], options) | ||
} | ||
@@ -738,0 +738,0 @@ |
@@ -234,3 +234,3 @@ import { Query } from './query.js' | ||
export const arraySerializer = function arraySerializer(xs, serializer) { | ||
export const arraySerializer = function arraySerializer(xs, serializer, options) { | ||
if (Array.isArray(xs) === false) | ||
@@ -247,5 +247,13 @@ return xs | ||
return '{' + xs.map(x => | ||
'"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"' | ||
).join(',') + '}' | ||
return '{' + xs.map(x => { | ||
if (x === undefined) { | ||
x = options.transform.undefined | ||
if (x === undefined) | ||
throw Errors.generic('UNDEFINED_VALUE', 'Undefined values are not allowed') | ||
} | ||
return x === null | ||
? 'null' | ||
: '"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"' | ||
}).join(',') + '}' | ||
} | ||
@@ -252,0 +260,0 @@ |
195569
4870