From 1b1de8763841b122c579d011557f5c209c6348f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Hamal=20Dvo=C5=99=C3=A1k?= Date: Wed, 22 Jan 2025 18:36:13 +0100 Subject: [PATCH] Support .toPostgres() on Array-derived objects Related to #2012. Since we cannot disambiguate between Arrays that should be converted to PostgreSQL array types and Arrays that should be treated as JSON, make it at least possible to define custom Array-derived types. This also makes it possible to properly serialize Array-derived multirange collections where elements must not be independently escaped. --- packages/pg/lib/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/pg/lib/utils.js b/packages/pg/lib/utils.js index 09b8d3dd8..362bbc5e7 100644 --- a/packages/pg/lib/utils.js +++ b/packages/pg/lib/utils.js @@ -66,7 +66,7 @@ var prepareValue = function (val, seen) { return dateToString(val) } } - if (Array.isArray(val)) { + if (Array.isArray(val) && val.toPostgres !== 'function') { return arrayString(val) } if (typeof val === 'object') {