Open krumft opened 1 year ago
A simple test to reproduce the problem:
it('can insert rows with differently specified default values in a single statement', () => {
none(`create table test(id character varying NOT NULL, col text array NOT NULL DEFAULT '{}');
insert into test(id, col) values ('0', '{}'), ('1', default);
`);
});
Our application is using
typeorm
version0.3.16
against a Postgres database, and we maintain our DB schema in TypeScript migrations. These are getting executed successfully by the ORM framework against the 'real' Postgres db.We are using
pg-mem
version2.6.12
to create some unit and integration tests for our application. We have recently noticed following interesting behaviour about this database tabletest
that has a column of typetext array NOT NULL DEFAULT '{}'
:Scenario 1: We insert two rows in the table, one specifies the column value as
'{}'
and the other uses the keywordDEFAULT
:Result: execution is successful.
Scenario 2: We insert the same two rows in the table but within a single
INSERT
statement:Result: execution fails with:
Using two rows inside the single
INSERT
statement is done by thetypeorm
framework, for optimisation purposes I believe.