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

Data types for Array of integers, strings and objects are omitted during the model creation

Open kumarordway opened this issue 3 years ago • 3 comments

Data types for Array of integers, strings and objects are omitted during the model creation

If the column has the array of integers as the data type it is omitted in the column type.

expected behavior: The type should be defined for array of integers, or any types of arrays.

kumarordway avatar Feb 09 '22 23:02 kumarordway

Hi there! What do you mean by "Array of integers, strings and objects are omitted during the model creation"?

Could you provide an example?

cheers🍺

spinlud avatar Mar 18 '22 11:03 spinlud

In postgress, type of column can be an array of strings or array integers etc. via json objects. For these columns the datatype is missed example here

 @Column({
    field: 'source_id',
    allowNull: true,
    defaultValue: Sequelize.literal("'{}'::integer[]"),
  })
    sourceId?: any;

See that this is missing type in column definition. this needs to be fixed with

@Column({
    field: 'xxx',
    allowNull: true,
    defaultValue: Sequelize.literal("'{}'::integer[]"),
    type: DataType.ARRAY(DataType.INTEGER),
  })
  sourceId?: any;

column definition in postgres information_schema for this column looks like this

 columns_default = "'{}'::integer[]"
 is_nullable = "YES"
 data_type="ARRAY"

kumarordway avatar Apr 06 '22 16:04 kumarordway