Inserting on a table containing a nullable field with type uuid[] fails if the same insert contains rows with NULL and non-NULL values.
return arr.map(x => Value.constant(valueType.of, x).cast(to.of).get(raw, t));
^
TypeError: Cannot read properties of null (reading 'map')
💥 This is a nasty error, which was unexpected by pg-mem. Also known "a bug" 😁 Please file an issue !
*️⃣ Failed SQL statement:
insert into "foo" ("id", "values")
values (1, null),
(2, ARRAY ['a23c2492-786b-4792-8c34-801bb36cdd55'])
;
👉 You can file an issue at https://github.com/oguimbal/pg-mem along with a way to reproduce this error (if you can), and the stacktrace:
at Evaluator.val (/home/lotus/project/node_modules/pg-mem/src/datatypes/datatypes.ts:478:32)
at Evaluator.get (/home/lotus/project/node_modules/pg-mem/src/evaluator.ts:223:21)
at Insert.performMutation (/home/lotus/project/node_modules/pg-mem/src/execution/records-mutations/insert.ts:134:62)
at Insert._doExecuteOnce (/home/lotus/project/node_modules/pg-mem/src/execution/records-mutations/mutation-base.ts:61:29)
at Insert.enumerate (/home/lotus/project/node_modules/pg-mem/src/execution/records-mutations/mutation-base.ts:73:31)
at enumerate.next (<anonymous>)
at SelectExec.execute (/home/lotus/project/node_modules/pg-mem/src/execution/select.ts:280:54)
at /home/lotus/project/node_modules/pg-mem/src/execution/statement-exec.ts:199:42
at pushExecutionCtx (/home/lotus/project/node_modules/pg-mem/src/utils.ts:391:16)
at /home/lotus/project/node_modules/pg-mem/src/execution/statement-exec.ts:188:54 {
location: { start: 0, end: 0 },
[Symbol(errorDetailsIncluded)]: true
}
To Reproduce
CREATE TABLE foo
(
id int NOT NULL PRIMARY KEY,
values uuid[]
);
insert into "foo" ("id", "values")
values (1, null),
(2, ARRAY ['a23c2492-786b-4792-8c34-801bb36cdd55']);
The error only happens when both values are inserted in the same operation, this work fine:
CREATE TABLE foo
(
id int NOT NULL PRIMARY KEY,
values uuid[]
);
insert into "foo" ("id", "values")
values (1, null);
insert into "foo" ("id", "values")
values (2, ARRAY ['a23c2492-786b-4792-8c34-801bb36cdd55']);
Describe the bug
Inserting on a table containing a nullable field with type
uuid[]
fails if the same insert contains rows with NULL and non-NULL values.To Reproduce
The error only happens when both values are inserted in the same operation, this work fine:
pg-mem version
2.6.3