sequelize-typescript-generator icon indicating copy to clipboard operation
sequelize-typescript-generator copied to clipboard

Postgres: Sets 'allowNull' on all non primary-key columns

Open AndreKlang opened this issue 2 years ago • 1 comments

On this line: https://github.com/spinlud/sequelize-typescript-generator/blob/6e2238d819eed8b98f0eba2931a6344c47de1333/src/dialects/DialectPostgres.ts#L306 column.is_nullable is always a string, YES or NO (ie. the datatype yes_or_no), so !!column.is_nullable will always be true.

This can (probably) be fixed by adding c.is_nullable = 'YES' as is_nullable, to the select. It may however conflict with the c.*, which in my opinion should be replaced by the actual columns used for clarity.

Tested on PostgreSQL 13.9 (Debian 13.9-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit

AndreKlang avatar Jul 04 '23 06:07 AndreKlang

Is there any update on this? We are trying to use this package as well and also running into this issue.

viligante8 avatar Jun 25 '24 15:06 viligante8