You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, everyone,I encountered a strange phenomenon:
if the array object contains the key "type", an error occurs during insertion.
Reproduction Code
constpostgres=require('postgres');constsql=postgres('postgresql://xxxxxxxxxxxxxx',{max: 17});/**AppPage DDL:CREATE TABLE "public"."AppPage" ( "id" int4 NOT NULL DEFAULT nextval('"AppPage_id_seq"'::regclass), "name" text COLLATE "pg_catalog"."default" NOT NULL, "desc" text COLLATE "pg_catalog"."default", "nodes" jsonb[] DEFAULT ARRAY[]::jsonb[], "pageSetId" int4, CONSTRAINT "AppPage_pkey" PRIMARY KEY ("id")); */asyncfunctionmain(){awaitsql`SELECT 1`;consttitle1='test1';constdesc1='desc1';constnodes1=[{foo: 'bar'}];// okawaitsql`INSERT INTO "AppPage" ("name", "desc", "nodes") VALUES (${title1}, ${desc1}, ${nodes1});`;consttitle2='test2';constdesc2='desc2';constnodes2=[{type: 'bar'}];// If the object includes the type key, it will throw an errorawaitsql`INSERT INTO "AppPage" ("name", "desc", "nodes") VALUES (${title2}, ${desc2}, ${nodes2});`;/** ERROR: ${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\types.js:237 .replace(escapeBackslash, '\\\\') ^ TypeError: Cannot read properties of undefined (reading 'replace') at arrayEscape (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\types.js:237:6) at ${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\types.js:264:15 at Array.map (<anonymous>) at arraySerializer (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\types.js:255:19) at options.serializers.<computed> (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\connection.js:761:45) at ${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\connection.js:934:36 at Array.forEach (<anonymous>) at Bind (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\connection.js:928:16) at prepared (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\connection.js:204:7) at toBuffer (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\connection.js:190:15) at cachedError (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\query.js:170:23) at new Query (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\query.js:36:24) at sql (${workspace}\node_modules\.pnpm\postgres@3.4.4\node_modules\postgres\cjs\src\index.js:112:11) at main (${workspace}\postgres.js:30:12) */}main();
Hi, everyone,I encountered a strange phenomenon:
if the array object contains the key "type", an error occurs during insertion.
Reproduction Code
Env
Nodejs: v20.11.1
Postgres.js: 3.4.4
PostgreSQL: 15.3
The text was updated successfully, but these errors were encountered: