diff --git a/README.md b/README.md index 36e20a53..a6fb6fcd 100644 --- a/README.md +++ b/README.md @@ -898,7 +898,7 @@ Prepared statements will automatically be created for any queries where it can b ## Custom Types -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.)_ Adding Query helpers is the cleanest approach which can be done like this: diff --git a/src/types.js b/src/types.js index 93ddaa29..521b2d95 100644 --- a/src/types.js +++ b/src/types.js @@ -243,7 +243,7 @@ export const arraySerializer = function arraySerializer(xs, serializer) { if (Array.isArray(first) && !first.type) return '{' + xs.map(x => arraySerializer(x, serializer)).join(',') + '}' - return '{' + xs.map(x => + return '{' + xs.map(x => x == null ? 'null' : '"' + arrayEscape(serializer ? serializer(x.type ? x.value : x) : '' + x) + '"' ).join(',') + '}' }